refactor: standardise target prefix across commands#2311
Open
agriyakhetarpal wants to merge 9 commits intoconda:mainfrom
Open
refactor: standardise target prefix across commands#2311agriyakhetarpal wants to merge 9 commits intoconda:mainfrom
agriyakhetarpal wants to merge 9 commits intoconda:mainfrom
Conversation
826dc98 to
887eac6
Compare
Author
|
Ready for initial review, thank you! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
As a follow-up to #2263, which was contributed in by @soapy1, @danyeaw, and me :)
This is a table of what I made out from the current state, i.e., before this PR. I could have made a mistake as I'm only human, of course – please cross-check! The current state is as follows:
CONDA_PREFIXis used?createtarget_prefix-p--prefix--target-prefixOption<PathBuf>.prefix(runtime)std::path::absoluteruntarget_prefix-p--prefix--target-prefixOption<PathBuf>.prefix(runtime)std::path::absoluteshell_hooktarget_prefix-p--prefix--target-prefixPathBuf.prefix(clapdefault_value)std::path::absolutemenu(i.e., both structs, corresponding toinstaller-menuandremove-menu)target_prefix-t--target-prefixPathBufdefault_value)fs::canonicalizelistprefix-p--prefixOption<PathBuf>Questions
list, since it usesprefix– is backwards compat a concern? (see changes table below)menucommands – similarly, is backwards compat a concern? (see changes table below)CONDA_PREFIX? I am aware that it is an env var set by conda/mamba/Pixi when an environment is activated. It makes sense for "operate on current environment" commands.shell_hook.rs, not as a prefix fallback, but as part of the activation machinery. But it already defaults to.prefix, and the activated shell related context is handled separately viaActivationVariables.listcommand right nowcreateas it's supposed to create or modify a specific prefix, and defaulting to the active prefix sounds kinda destructive 😅 Same formenuas well.run: maybe yes? See 887eac6 (and cc: @danyeaw). My reasoning:rattler run pythonwithout needing-p.rattler listgracefully falls back to the prefix, soruncan too.CONDA_PREFIXChanges I made
createOption<PathBuf>and a runtime fallback. I changed this toPathBufanddefault_value = ".prefix". Removeddebug println!runcreate. I removed an unused env import anddebug println!. I also added theCONDA_PREFIXfallback likelist.shell_hookdefault_valueandstd::path::absolute. We're all good here!menu(InstallOptandRemoveOpt)#[clap(long, short)](it was deriving-t/--target-prefix) and changed it to-p/--prefixwithvisible_alias. Also, I changedfs::canonicalizetostd::path::absolutelike the rest.listprefixtotarget_prefixand addedvisible_alias = "target-prefix"andshort = 'p', again like the rest of them. I have kept theCONDA_PREFIXfallback here! See above for questions.How Has This Been Tested?
I ran and printed the help sections of the commands locally using Pixi tasks after following the instructions in the Contributing guide. Also, I waited for CI to run and be green.
AI Disclosure
No AI-generated content was included in this PR. However, I used Claude Sonnet 4.6 to perform a self-review of my changes, besides a manual review, of course.
Checklist:
I have commented my code, particularly in hard-to-understand areasI have made corresponding changes to the documentationI have added sufficient tests to cover my changes.