-
Notifications
You must be signed in to change notification settings - Fork 379
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: Adapt root prefix' precedence for envs_dirs
#3813
base: main
Are you sure you want to change the base?
Conversation
This adds the case to simulate what happens when ${MAMBA_ROOT_PREFIX}/envs already exists.
envs_dirs
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.
Thank you for your contribution, @holzman!
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.
Can you add at least a test based on the outputs that you have given in the description of the PR?
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.
Done.
cliroot = tmp_path / "cliroot" | ||
userenv = tmp_path / "userenv" / "envs" | ||
|
||
map(lambda p: os.makedirs(p), (envroot, cliroot, userenv)) |
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.
Is this required because of #3790?
map(lambda p: os.makedirs(p), (envroot, cliroot, userenv)) | |
map(lambda p: os.makedirs(p, exist_ok=True), (envroot, cliroot, userenv)) |
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.
Yes
|
||
map(lambda p: os.makedirs(p), (envroot, cliroot, userenv)) | ||
|
||
monkeypatch.setenv("MAMBA_ROOT_PREFIX", str(envroot)) |
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.
Can you set it at the really top of this test?
if user_envs_dirs: | ||
monkeypatch.setenv("CONDA_ENVS_DIRS", str(userenv)) |
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.
Identically, can you set it at the top of the test?
envroot = tmp_path / "envroot" | ||
cliroot = tmp_path / "cliroot" | ||
userenv = tmp_path / "userenv" / "envs" |
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.
Can you distinguish the prefixes from their envs
folders?
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.
Sorry, I don't quite understand what you're asking.
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.
I meant to have something like:
envroot = tmp_path / "envroot" | |
cliroot = tmp_path / "cliroot" | |
userenv = tmp_path / "userenv" / "envs" | |
envroot = tmp_path / "envroot" | |
cliroot = tmp_path / "cliroot" | |
userenv = tmp_path / "userenv" | |
env_root_envs = envroot / "envs" | |
cliroot_envs = cliroot / "envs" | |
userenv_envs = userenv / "envs |
if user_envs_dirs: | ||
monkeypatch.setenv("CONDA_ENVS_DIRS", str(userenv)) | ||
|
||
res = helpers.create(*cmd) |
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.
Can you check that foo
is successfully created and that, depending the test case, foo
is created under envroot/envs
, cliroot/envs
or (after distinguishing prefixes from their envs
folder) userenv/envs
?
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.
In addition to checking the output from --print-config
or in addition to it?
if root_prefix_env_exists: | ||
os.mkdir(Path(os.environ["MAMBA_ROOT_PREFIX"]) / "envs") | ||
|
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.
Why is this needed?
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.
Because of #3790.
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.
if root_prefix_env_exists: | |
os.mkdir(Path(os.environ["MAMBA_ROOT_PREFIX"]) / "envs") | |
# TODO: Remove once https://github.com/mamba-org/mamba/issues/3790 is fixed. | |
if root_prefix_env_exists: | |
os.mkdir(Path(os.environ["MAMBA_ROOT_PREFIX"]) / "envs", exist_ok=True) |
Adds a new test and fixes #3806. With this PR it now has the desired behavior:
One note - in order for this approach to work, I needed to ensure that the minimum vector size for configuration items was 1 so that
--print-config
didn't crash. (Alternatively I could change the print-config code to ignore a zero-size vector, but this seemed like a more robust approach).