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

[micromamba] Stop run command when given prefix does not exist #2257

Merged
merged 3 commits into from
Feb 2, 2023
Merged
Show file tree
Hide file tree
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
6 changes: 6 additions & 0 deletions libmamba/src/core/run.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,12 @@ namespace mamba
const std::vector<std::string>& env_vars,
const std::string& specific_process_name)
{
if (!fs::exists(Context::instance().target_prefix))
{
LOG_CRITICAL << "The given prefix does not exist: "
<< Context::instance().target_prefix;
return 1;
}
std::vector<std::string> raw_command = command;
// Make sure the proc directory is always existing and ready.
std::error_code ec;
Expand Down
10 changes: 10 additions & 0 deletions micromamba/tests/test_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,16 @@ def test_shell_io_routing(self):
)
assert subprocess.run(test_script_path, shell=True).returncode == 0

def test_run_non_existing_env(self):
env_name = random_string()
try:
run_res = umamba_run("-n", env_name, "python")
except subprocess.CalledProcessError as e:
assert (
"critical libmamba The given prefix does not exist:"
in e.stderr.decode()
)


@pytest.fixture()
def temp_env_prefix():
Expand Down