Skip to content

Commit

Permalink
Fix wrong activated PATH in micromamba shell (#2722)
Browse files Browse the repository at this point in the history
* Fix wrong activated PATH in micromamba shell

* Add PATH check for shell activation

* Simplify stdout check in shell test
  • Loading branch information
AntoinePrv authored Aug 1, 2023
1 parent 00fb86c commit 58acf67
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion micromamba/src/shell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ namespace
};

exit(mamba::run_in_environment(
Context::instance().prefix_params.root_prefix,
Context::instance().prefix_params.target_prefix,
{ get_shell() },
".",
static_cast<int>(STREAM_OPTIONS::ALL_STREAMS),
Expand Down
11 changes: 11 additions & 0 deletions micromamba/tests/test_shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,3 +296,14 @@ def test_shell_run_SHELL(self, prefix_selector, tmp_path):
env={**os.environ, "SHELL": script_path},
)
assert ret.returncode == 42

def test_shell_run_activated(self):
"""Verify environment properly activated in `micromamba shell`."""
skip_if_shell_incompat("bash")
create("-n", self.env_name)
stdout = subprocess.check_output(
[get_umamba(), "shell", "-n", self.env_name],
input="echo $PATH",
text=True,
)
assert self.env_name in stdout.split(os.pathsep)[0]

0 comments on commit 58acf67

Please sign in to comment.