Reputation: 61
I am trying to activate my environment with " conda activate myenv " but an error appears so when I do "conda init bash" it indicates
no change /usr/local/condabin/conda
no change /usr/local/bin/conda
no change /usr/local/bin/conda-env
no change /usr/local/bin/activate
no change /usr/local/bin/deactivate
no change /usr/local/etc/profile.d/conda.sh
no change /usr/local/etc/fish/conf.d/conda.fish
no change /usr/local/shell/condabin/Conda.psm1
no change /usr/local/shell/condabin/conda-hook.ps1
no change /usr/local/lib/python3.6/site-packages/xontrib/conda.xsh
no change /usr/local/etc/profile.d/conda.csh
modified /root/.bashrc
==> For changes to take effect, close and re-open your current shell. <==
Someone help me how can I close and re-open the bash shell?
Upvotes: 4
Views: 11331
Reputation: 189487
For some additional context, what it is telling you is that the shell's initialization files have been updated. But the current shell was initialized before those changes were made, so the easiest way to reload everything reliably is to type exit
and start a new shell. Whatever you did to start the current shell (probably running in a terminal window, or on a text console if you're really old school), do it again.
There is no compelling need to stop the current shell instance; just understand that it does not contain the modifications which Conda made to its initialization files. You could simply leave it open and open a second terminal where a new shell will be loaded with the up-to-date configuration. (But obviously, remember that the old shell running in the first terminal window does not have the full capabilities to support Conda that the new one does.)
You could stop reading here.
If you know what you are doing, you can selectively load the changed files, or examine what was added, and run it at the command line in the old shell.
The simple and brutal solution in your example is to type source /root/.bashrc
at the Bash prompt in the terminal where you received this message. But understand that this could duplicate some previous actions which were taken the first time the .bashrc
was sourced, when your current shell instance was started. You should examine your Bash startup files and understand what's in them before you blindly plunge ahead ... or be prepared to notice that it didn't work like you hoped, and fall back to exiting the current shell and starting a new one.
In some more detail, a properly written .bashrc
should be idempotent, i.e. make sure that it can be run a second or third etc time without adverse side effects. Typically this happens by examining whether a change to the environment is necessary before making it. So, for example, a crude hack would be to just add $HOME/bin
to the beginning of the PATH
unconditionally, which means that if you source .bashrc
again, you end up with the same directory in your PATH
twice (not generally a significant problem, but there could be consequences if you have stuff in your private PATH
which should not override some other tool's preferred implementation)
PATH=$HOME/bin:$PATH
... whereas if done completely properly, your Bash startup files would only add the directory to your PATH
if it's not there already:
case :$PATH: in
*:$HOME/bin:*) ;; # it's already there; do nothing
*) PATH=$HOME/bin:$PATH ;; # it's not there; add it
esac
Your shell's startup file could contain basically anything. If starting a new shell has the side effect of launching a manned mission to Mars, you will now have two of them. But this brief exposition ends here.
If you know what was in your .bashrc
before, you can see what was added, and just run that. Maybe you see something like
bash$ diff /root/.bashrc~ /root/.bashrc # lucky I made a backup in /root/.bashrc~
2022a2023,2025
>
> # Stuff added by Conda
> eval $(/opt/random/path/to/conda.init.bash)
(I don't know what Conda adds; this is just a speculative example.)
Here, you can see that eval $(/opt/random/path/to/conda.init.bash)
was the thing which was added since the previous time you edited your .bashrc
, so that's the thing you want to run in your current shell as well in order to bring it up to date.
Generally, you can expect the changes to be added to the end of the file, though there is no guarantee that some tools might not make more sophisticated changes.
If other files were changed, you have to understand what they are for, and manually execute the same changes in the current shell.
Upvotes: 0
Reputation: 699
Command + Q
on your open terminal.Upvotes: 0