-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Idempotent setup instructions #559
Comments
Getting line 1 done in the install script shouldn't be too difficult (line 2 obviously needs to be done manually no matter what), and I'd be happy to take a crack at it, but perhaps we should first revisit the reason why this was not automated in the first place. And I have no idea what that reason is. 🤷♂️ |
I really don't want to automate the first line: The different ways you can configure your startup scripts are manifold: maybe you use I also just remembered the following: we don't write outside |
I understand your concerns, and here's my POV:
So here's what I'm proposing the install script should do:
For uninitiated CLI users, that should maximize the chance of It Just Works. For the experienced, they're given enough information to tweak after the fact if needed. |
I think we can learn from the setup method of $ conda init -h
usage: conda init [-h] [--all] [--reverse] [--json] [-v] [-q] [-d] [shells [shells ...]]
Initialize conda for shell interaction. [Experimental]
Options:
positional arguments:
shells One or more shells to be initialized. If not given, the default value is 'bash' on unix and 'cmd.exe' on
Windows. Use the '--all' flag to initialize all shells. Currently compatible shells are {bash, fish,
powershell, tcsh, xonsh, zsh}
optional arguments:
-h, --help Show this help message and exit.
--all Initialize all currently available shells.
-d, --dry-run Only display what would have been done.
setup type:
--reverse Undo past effects of conda init.
Output, Prompt, and Flow Control Options:
--json Report all output as json. Suitable for using conda programmatically.
-v, --verbose Use once for info, twice for debug, three times for trace.
-q, --quiet Do not display progress bar.
Key parts of conda's functionality require that it interact directly with the shell
within which conda is being invoked. The `conda activate` and `conda deactivate` commands
specifically are shell-level commands. That is, they affect the state (e.g. environment
variables) of the shell context being interacted with. Other core commands, like
`conda create` and `conda install`, also necessarily interact with the shell environment.
They're therefore implemented in ways specific to each shell. Each shell must be configured
to make use of them.
This command makes changes to your system that are specific and customized for each shell.
To see the specific files and locations on your system that will be affected before, use the
'--dry-run' flag. To see the exact changes that are being or will be made to each location,
use the '--verbose' flag.
IMPORTANT: After running `conda init`, most shells will need to be closed and restarted
for changes to take effect.
$ conda init
no change /home/PanXuehai/Miniconda3/condabin/conda
no change /home/PanXuehai/Miniconda3/bin/conda
no change /home/PanXuehai/Miniconda3/bin/conda-env
no change /home/PanXuehai/Miniconda3/bin/activate
no change /home/PanXuehai/Miniconda3/bin/deactivate
no change /home/PanXuehai/Miniconda3/etc/profile.d/conda.sh
no change /home/PanXuehai/Miniconda3/etc/fish/conf.d/conda.fish
no change /home/PanXuehai/Miniconda3/shell/condabin/Conda.psm1
no change /home/PanXuehai/Miniconda3/shell/condabin/conda-hook.ps1
no change /home/PanXuehai/Miniconda3/lib/python3.8/site-packages/xontrib/conda.xsh
no change /home/PanXuehai/Miniconda3/etc/profile.d/conda.csh
modified /home/PanXuehai/.bashrc
==> For changes to take effect, close and re-open your current shell. <==
$ conda init --all
no change /home/PanXuehai/Miniconda3/condabin/conda
no change /home/PanXuehai/Miniconda3/bin/conda
no change /home/PanXuehai/Miniconda3/bin/conda-env
no change /home/PanXuehai/Miniconda3/bin/activate
no change /home/PanXuehai/Miniconda3/bin/deactivate
no change /home/PanXuehai/Miniconda3/etc/profile.d/conda.sh
no change /home/PanXuehai/Miniconda3/etc/fish/conf.d/conda.fish
no change /home/PanXuehai/Miniconda3/shell/condabin/Conda.psm1
no change /home/PanXuehai/Miniconda3/shell/condabin/conda-hook.ps1
no change /home/PanXuehai/Miniconda3/lib/python3.8/site-packages/xontrib/conda.xsh
no change /home/PanXuehai/Miniconda3/etc/profile.d/conda.csh
no change /home/PanXuehai/.bashrc
no change /home/PanXuehai/.zshrc
modified /home/PanXuehai/.config/fish/config.fish
modified /home/PanXuehai/.xonshrc
modified /home/PanXuehai/.tcshrc
modified /home/PanXuehai/.config/powershell/profile.ps1
==> For changes to take effect, close and re-open your current shell. <== The core function here conda/core/initialize.py. We can provide a command (e.g.
I think this is more clear for users and the Further, we can run the initialize instructions for users in the installer. The conda installer: if [ "$BATCH" = "0" ]; then
# Interactive mode.
BASH_RC="$HOME"/.bashrc
DEFAULT=no
printf "Do you wish the installer to initialize Miniconda3\\n"
printf "by running conda init? [yes|no]\\n"
printf "[%s] >>> " "$DEFAULT"
read -r ans
if [ "$ans" = "" ]; then
ans=$DEFAULT
fi
if [ "$ans" != "yes" ] && [ "$ans" != "Yes" ] && [ "$ans" != "YES" ] && \
[ "$ans" != "y" ] && [ "$ans" != "Y" ]
then
printf "\\n"
printf "You have chosen to not have conda modify your shell scripts at all.\\n"
printf "To activate conda's base environment in your current shell session:\\n"
printf "\\n"
printf "eval \"\$($PREFIX/bin/conda shell.YOUR_SHELL_NAME hook)\" \\n"
printf "\\n"
printf "To install conda's shell functions for easier access, first activate, then:\\n"
printf "\\n"
printf "conda init\\n"
printf "\\n"
else
if [[ $SHELL = *zsh ]]
then
$PREFIX/bin/conda init zsh
else
$PREFIX/bin/conda init
fi
fi
printf "If you'd prefer that conda's base environment not be activated on startup, \\n"
printf " set the auto_activate_base parameter to false: \\n"
printf "\\n"
printf "conda config --set auto_activate_base false\\n"
printf "\\n"
printf "Thank you for installing Miniconda3!\\n"
fi # !BATCH |
Agreed and other commenters online seem to.
Simple solution: don't add it to their |
On Linux and ARM macOS, we ask users to run some variation of these commands:
These commands provide no feedback, so it becomes tempting for users to run them more than once (cf. Homebrew/discussions#1871). This is not ideal because the first command is not idempotent.
I suggest we find a way to make adding
brew
to a user'sPATH
1) idempotent, and 2) provide feedback that this has been completed successfully.Achieving both of these things might require adding a new command to
brew
, but it would be nicer if we could get this done with just the install script.If we don't want to add a new command, we may want to consider tweaking our post-installation instructions to be a bit more handhold-y for users who are less comfortable with working in the terminal. (We'll probably have to give up idempotence, but we can maybe live without it.)
The text was updated successfully, but these errors were encountered: