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

Add dev mode command for micromamba shell init #2118

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions micromamba/src/activate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,35 @@ set_activate_command(CLI::App* subcom)
[&]()
{
std::string guessed_shell = guess_shell();
std::string shell_hook_command = "", shell_hook = "";
std::string shell_hook_command = "", shell_hook = "", shell_hook_dev_mode_cmd = "",
shell_hook_dev_mode = "";

if (guessed_shell == "powershell")
shell_hook_command
= "micromamba.exe shell hook -s powershell | Out-String | Invoke-Expression";
else
{
shell_hook_command
= "eval \"$(micromamba shell hook --shell=" + guessed_shell + ")\"";

shell_hook_dev_mode_cmd = "eval \"$(./micromamba/micromamba shell hook --shell="
Copy link
Member

Choose a reason for hiding this comment

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

Won't this path change depending on user? It's not uncommon to put it under build/

Copy link
Member

Choose a reason for hiding this comment

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

In my experience, I also don't need to run the hook again. Since the hook already uses the MAMBA_EXE variable, I can set export MAMBA_EXE="${PWD}/build/micromamba/micromamba. Or perhaps I'm missing something.

Copy link
Member Author

Choose a reason for hiding this comment

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

Won't this path change depending on user? It's not uncommon to put it under build/

If you are testing your built micromamba, I assumed you're in your build directory and so the path would be the same. But we could also make it ./build/micromamba/micromamba, maybe that would be clearer.

Copy link
Member Author

@Hind-M Hind-M Nov 24, 2022

Choose a reason for hiding this comment

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

In my experience, I also don't need to run the hook again. Since the hook already uses the MAMBA_EXE variable, I can set export MAMBA_EXE="${PWD}/build/micromamba/micromamba. Or perhaps I'm missing something.

Well I don't know, maybe I am missing something... Because I had this info from Johan and it didn't work for me... We should probably need to discuss this.

+ guessed_shell + ")\"";

shell_hook_dev_mode = unindent((R"(

Or in dev mode, in your build directory:
$ )" + shell_hook_dev_mode_cmd)
.c_str());
}

if (guessed_shell != "cmd.exe")
{
shell_hook = unindent((R"(

To initialize the current )"
+ guessed_shell + R"( shell, run:
$ )" + shell_hook_command
+ R"(
+ shell_hook_dev_mode + R"(
Copy link
Member

Choose a reason for hiding this comment

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

This is going to be shown to all (non-dev) users? If so I would suggest a better approach would be to put that information in the docs.

Copy link
Member Author

@Hind-M Hind-M Nov 24, 2022

Choose a reason for hiding this comment

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

This is going to be shown to all (non-dev) users?

Yes.

If so I would suggest a better approach would be to put that information in the docs.

Well I thought about it but since the problem occurred while trying to activate an env with the built micromamba, I had this message error (which wasn't solving the problem). So I think that having an error message with the right suggested command would really help because it's the first thing that I/someone would try (follow the suggestion, before searching in the docs), but that doesn't mean not putting it there as well.

and then activate or deactivate with:
$ micromamba activate
)")
Expand Down