-
Notifications
You must be signed in to change notification settings - Fork 382
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
fix: Create directories from envs_dirs
if they do not exist
#3796
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Burt Holzman <burt@fnal.gov>
envs_dirs
if they do not exist
Ah, my bad. I'll revise the failing tests and update this PR. |
Actually, I think this exposed an issue with #3692: In 2.0.5,
but in 2.0.6:
|
Merging |
I assume the Windows test is failing because it succesfully creates |
Thank you! For your information, looking at the test logs: def test_create_envs_dirs(tmp_root_prefix: Path, tmp_path: Path):
"""Create an environment when the first env dir is not writable."""
os.environ["CONDA_ENVS_DIRS"] = f"{Path('/noperm')},{tmp_path}"
env_name = "myenv"
helpers.create("-n", env_name, "--offline", "--no-rc", no_dry_run=True)
> assert (tmp_path / env_name / "conda-meta" / "history").exists()
E AssertionError: assert False
E + where False = exists()
E + where exists = (((WindowsPath('C:/Users/runneradmin/AppData/Local/Temp/pytest-of-runneradmin/pytest-0/test_create_envs_dirs_False_0') / 'myenv') / 'conda-meta') / 'history').exists
|
So this test was previously successful on both Windows and Linux because |
Ah yes, my bad, I misread the assertion. |
In the meantime, #3836 has been reported. Could we see if this PR fixes it by adding a non-regression test for it? |
Ok, I’m a little stumped on this one; I rolled out a Windows dev environment and the test (as revised) passed… |
7c6a92a
to
eef136f
Compare
@holzman: I tried several alternatives, but I think it would be worth having someone with a Windows machine reproduce and understand the error locally. Feel free to remove / revert my commits. |
Thanks @jjerphan - I did test in a Windows machine, unfortunately. Something must be subtly different about the environment in the actual Windows runner. I'll see if I can figure that out in a separate project; if it turns out it's impossible to make a read-only directory for the test, we should probably just skip the test for Windows. |
eef136f
to
ea0f7ca
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM given 🟢 CI.
I am waiting for a review from someone else in the team before merging.
for _ in range(2): | ||
cmd = ["-n", env_name, "--rc-file", tmp_home / ".condarc"] | ||
helpers.create(*cmd, no_rc=False) | ||
|
||
assert not Path(mamba_root_prefix_envs / env_name).exists() | ||
assert Path(condarc_envs_dirs / env_name).exists() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick: slightly stricter assertions.
for _ in range(2): | |
cmd = ["-n", env_name, "--rc-file", tmp_home / ".condarc"] | |
helpers.create(*cmd, no_rc=False) | |
assert not Path(mamba_root_prefix_envs / env_name).exists() | |
assert Path(condarc_envs_dirs / env_name).exists() | |
for _ in range(2): | |
assert not Path(mamba_root_prefix_envs / env_name).exists() | |
cmd = ["-n", env_name, "--rc-file", tmp_home / ".condarc"] | |
helpers.create(*cmd, no_rc=False) | |
assert Path(condarc_envs_dirs / env_name).exists() |
@@ -490,6 +490,18 @@ namespace mamba | |||
{ | |||
for (const auto& dir : dirs) | |||
{ | |||
if (!fs::exists(dir)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
create_directories
shouldn't report errors when attempting to create an already existing directory, so you can remove that if
and call create_directories
every time (keep the error handling for the other potential errors).
} | ||
catch (const fs::filesystem_error& e) | ||
{ | ||
LOG_WARNING << "Error creating directory " << dir << ": " << e.what() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really want to continue when an error occurs here?
Did you consider not catching the error so that that we stop immediately and let the caller handle the issue?
Fix #3790.
Fix #3836.