Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nushell hotfix #2841

Merged
merged 5 commits into from
Oct 17, 2023
Merged

Nushell hotfix #2841

merged 5 commits into from
Oct 17, 2023

Conversation

cvanelteren
Copy link
Contributor

@cvanelteren cvanelteren commented Sep 15, 2023

Noticed the deactivation was not working properly. This is fixed now.
This is the same as #2840 but using the correct main as base. It extends #2693.

Copy link
Member

@AntoinePrv AntoinePrv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't checked that locally, does it work as intended for you?

{
fs::create_directories(sh_source_path.parent_path());
}
catch (...)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Catch the correct exception, at least std::exception

}
catch (...)
{
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe log, or let the exception break the current flow?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just pushed a comment to this part. Does this suffice?

@cvanelteren
Copy link
Contributor Author

@AntoinePrv Yes. The originally implementation unset the path variable to empty string which caused some obvious issues for me when deactivating. I see that the current PR is entangled with the other PR I will fix that and look at the review above.

@AntoinePrv
Copy link
Member

I don't understand the practice with catch(...) { }. If failure is not an issue, why do it in the first place?
at least using a log like LOG_WARNING << "Failed to create directory: " << ...; would let user know what went wrong (and maybe recover/investigate themselves.

As an implementation catch(...) is also a bad design, we should prefer catch(const fs::filesystem_error &). According the the reference, this function could also throw std::bad_alloc, which we have no reason to silence.

@cvanelteren
Copy link
Contributor Author

cvanelteren commented Sep 21, 2023

I don't understand the practice with catch(...) { }. If failure is not an issue, why do it in the first place? at least using a log like LOG_WARNING << "Failed to create directory: " << ...; would let user know what went wrong (and maybe recover/investigate themselves.

As an implementation catch(...) is also a bad design, we should prefer catch(const fs::filesystem_error &). According the the reference, this function could also throw std::bad_alloc, which we have no reason to silence.

I'm just following the example listed above. In essence we can remove the entire section since the activation does not generate any files. EDIT: this is also not the core of the current PR. The part being commented on was already merged before.

@zacharyburnett
Copy link

zacharyburnett commented Oct 13, 2023

This works great on my machine (deactivation works as expected); however, I did end up commenting out the prompt modification in $env.config-path as it clobbered my existing prompt:

# # update prompt
# if ($env.CONDA_PROMPT_MODIFIER? != null) {
#   $env.PROMPT_COMMAND = {|| $env.CONDA_PROMPT_MODIFIER + (create_left_prompt)}
# }
# # update prompt
# $env.PROMPT_COMMAND = {|| create_left_prompt}

I am using Starship, which already picks up on an activated environment and uses the following to inject the prompt:

mkdir ~/.cache/starship
starship init nu | save -f ~/.cache/starship/init.nu
source ~/.cache/starship/init.nu

so it might just be an issue of a nonstandard config

@cvanelteren
Copy link
Contributor Author

cvanelteren commented Oct 13, 2023

@zacharyburnett ah I was afraid of that happening to someone. I haven't figured out a good way to extend a closure. Starship seems to additionally override it (see here), implying it is no straightforward (embedded way to do it). I will give this some thought.

@cvanelteren
Copy link
Contributor Author

@zacharyburnett can you checkout the latest push. I believe this may be compatible with starship, and other future prompts.

@zacharyburnett
Copy link

@zacharyburnett can you checkout the latest push. I believe this may be compatible with starship, and other future prompts.

I reran micromamba shell init --shell nu and it works great now, thanks!

@cvanelteren
Copy link
Contributor Author

That is good to hear ;-)

@cvanelteren
Copy link
Contributor Author

Can this be merged @AntoinePrv?

@AntoinePrv
Copy link
Member

Please excuse me for not being very responsive, I'm not very knowledgeable with Nushell.
If it works for both of you, I guess we can merge (waiting for CI once more).

For the prompt, I was never a big fan of Conda modifying the prompt, but it did not matter since advanced bash/zsh prompts are set through PROMPT_COMMAND.
If you want to leave the prompt out of the activation script here, that is also fine. Since Nushell is more powerusers, I expect users like to set their own prompts.

@cvanelteren
Copy link
Contributor Author

cvanelteren commented Oct 17, 2023 via email

@AntoinePrv AntoinePrv merged commit a395cab into mamba-org:main Oct 17, 2023
22 of 23 checks passed
@cvanelteren cvanelteren deleted the nushell_hotfix branch October 17, 2023 11:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants