I have tried many times to initialise conda for shell interaction using the command "conda init bash" on my terminal but it always says "No action taken."
What am I doing wrong?
With so little details in your question it's hard to help you. You should read carefully and paste what conda init bash is outputting (and your .bashrc, .bash_profile and output of PATH).
I was in a similar issue and what happened was that the conda init modifies your .bash_profile and adds some code at the end. But if you are running your .bashrc before that code is being added then conda won't behave correctly during the loading of your bashrc file. So inspect both files and make sure they are the way you expect them (especially because code analysis is undecidable).
Also, make sure your PATH environment variable looks the way you expect. If not make sure your not modifying it in unexpected ways and that the path to conda is there correctly.
See my answer here for more details: Why is conda init updating my .bash_profile incorrectly?
Additionally, if you are using vscode you might have other problems like needing to set the terminal.integrated.inheritEnv to false. Read here for more info: https://code.visualstudio.com/updates/v1_36#_launch-terminals-with-clean-environments
Opening and closing vscode completely seems to help a lot, do this.
Another helpful tip is to go the top left of vscode where it says code click it then go to preferences and then settings. Then you can change the terminal.integrated.inheritEnv to false by unclicking/selecting it.
Related
I am trying to refresh my aliases on my Mac (OS Catalina 10.15.6) after defining new aliases in my .bash_profile file with the command:
source ~/.bash_profile
But terminal keeps giving this error message:-bash: s: command not found
This is confusing because for the longest time this command worked. I even had it included in my .bash_profile file as an alias, where it worked fine.
I'm aware the problem could have to do it with an error in my PATH but I've never made any edits to my PATH so have no idea what the issue could be?
Thanks in advance.
My first instinct would be to check both ~/.bashrc, and /etc/bashrc if it exists. That is where I customarily define aliases, and it looks to me as though a bad alias may be your problem.
I'm not saying it was the one you made, although it might be. Just go through your rc and profile files and look for any aliases which might in any way clash with source.
I suspect the source command is working just fine and the problem is a bad line in the ~/.bash_profile itself that looks like it's trying to run a command named s. I would look in there for the problem.
It might help to run it with xtrace on via bash -x ~/.bash_profile – running it in a separate process like that won't have any of the presumably-desired side effects of sourceing it in your current shell, but you can see what it's trying to do so that you can fix it.
(You can also just set -x before the source and get both xtrace and running in the current shell; just be sure to set +x afterwards or your shell session will be full of debug output.)
I would like to use something like oh-my-bash in vscode using WSL2. However according to the docs:
When VS Code Remote is started in WSL, no shell startup scripts are run. This was done to avoid issues with startup scripts that are tuned for shells. If you want to run additional commands or modify the environment this can be done in a setup script ~/.vscode-server/server-env-setup (Insiders: ~/.vscode-server-insiders/server-env-setup). If present, the script is processed before the server is started.
I have added a ~/.vscode-server/server-env-setup and according to the logs it is found and executed, but my linux skills are quite basic and i can't figure out how to get my profile installed. I have tried
bash ~/.profile
...but that doesn't seem to do anything. I have also tried
#!/bin/bash
source ~/.profile
which gives me an error /mnt/c/Users/cber/.vscode/extensions/ms-vscode-remote.remote-wsl-0.40.3/scripts/wslServer.sh: 3: /home/cber/.vscode-server/server-env-setup: source: not found
UPDATE
The question of how to source a profile is answered below, but my problem with getting powerline-go to work in vs-code on WSL2 persists, but i moved that to a new question in order to close this one.
In order to persist your settings in your current shell, you need to source your config instead of just executing it (see this link for more details).
The problem is that vscode is using dash to load your config file instead of bash.
However, source is a bash keyword, and is not understood by dash. So you'll have to use the more portable syntax, ., in order to make it work with dash.
Try replacing your file by the following content (no need for #!/bin/bash) :
# if the profile file exists, we source it
if [ -f ~/.profile ]
then
. ~/.profile
fi
I added a bunch of aliases to my .profile file. None of them work either.
My .bash_profile has one line: export PATH="$HOME/.npm-packages/bin:$PATH"
I went as far as creating a .bashrc file and putting source ~/.bash_profile in it.
Nothing I have tried is working, other than if I put source ~/.bash_profile into my shell every time I open a new one.
I have tried every stack overflow answer I could find and nothing is working.
Anyone out there can help me?
I am on mac, using fish, but same results in bash.
Fish is not, in general, bash compatible. That means it won't read bash's configuration files and if source works on them that's lucky (e.g. export var=val will work, var=val will not).
You need to either start fish from bash (and have all necessary variables exported), rewrite the necessary configuration for use with fish and add it to config.fish, or use something like https://github.com/edc/bass to read bash's changed environment from fish.
I am trying to run the following:
source activate env-name
But I am receiving an error that tells me that the call to activate must be sourced. In the Conda activate script, there's an if block near the beginning that tests "$(basename "$0")", specifically whether it's equal to activate, in which case it will raise the exception I'm referring to. A little bit of fiddling with the script (i.e., echo $0; return 1) and I found out that it does indeed think that the 0th argument that I am passing in is activate rather than source. This is perplexing because I know that my command includes source in it and that that should be the 0th argument. I'm not sure what else there is to do. Does anybody have any clues?
In case it's important, I am using zsh as my default shell and it seems that the activate script is a bash script, but I don't think that should matter (it doesn't elsewhere for me, only in this specific environment on my work laptop). I am able to get around this whole thing by just commenting out the whole check (and a couple of other minor changes), but I'd rather not have to do that in this particular case.
I've been having the same issue, the only workaround I've found is:
source <PATH TO ANACONDA>/anaconda3/bin/activate <ENV NAME>
EDIT: adding the line:
export PATH=$PATH:<PATH TO ANACONDA>/anaconda3/bin:$PATH
to your bashrc (or zsh etc) will add source to your path and you will be able to use source as normal.
** I DON'T HAVE ENOUGH REPUTATION, SO I REPLY THIS. (I wanna just comment but I can't)
It can be solve that you know this.
"Run 'Source activate envname'" means you have to run this command on correct path or directory.
If you install anaconda3 on /home/user/anaconda3/
your correnct source path is /home/user/anaconda3/bin/
/home/user/anaconda3/bin/ activate tensorflow
or
cd /home/user/anaconda3/bin
. activate tensorflow
So, I already solve this problem through adding path(or move correct path)
I got similar error because I was using asdf-vm which masks actual binaries with shims. As documented here, scripts that need to be sourced must be accessed directly because asdf uses exec system call. So in my case, the following command worked:
source $(asdf which activate) <ENV NAME>
While this answer is specific to asdf, the error you're getting suggests you were in a similar situation where the call to activate was intercepted by some other executable.
I set up some aliases in my .bash_profile on my Max OS X.
It works but when I'm opening a new tab I always have to load my .bash_profile file with this command:
source ~/.bash_profile
How can I make it work for every terminal I'm opening, even if I'm restarting my Mac or Linux computer?
If you use zsh , you can add source ~/.bash_profile
at the end of .zshrc file at the following path: /Users/YOUR USER NAME/.zshrc , then restart your Terminal/iTerm2 app.
Note that this file is hidden. You can press CMD + SHIFT + . in Finder to
see it, Or just open it in default text editor with the following command from terminal:
open ~/.zshrc
Update
You don't need to do this by hand, run the following command:
echo "source ~/.bash_profile" >> ~/.zshrc
* Dont forget to restart your terminal.
The files executed at the start may be several, usually ~/.bashrc for interactive, non-login shells. The kind I assume you are using.
If so, create an ~/.bashrc file and source ~/.bash_profile in it:
if [ -f ~/.bash_profile ]; then
. ~/.bash_profile
fi
This web site has a lot of information about this.
Study this image, as it is a condensed guide
If you do need to find out exactly which file is being executed, take a look at this web page. It has a lot of specific tests to find out what file is setting what.
Specific for Mac-OS (which is an exception and loads ~/.bash_profile) do as is recomended in the site linked in this answer AFTER you confirm that your bash is doing as explained there.
I know this is a pretty old post, but this problem comes and goes quite oftenly and a lot of laborous solutions are offered. The fact is: being aware of a simple info would solve this pretty fast and easy:
LINUX/Unix OS will load the profile files on startup following the rules below (some distros may have other files names, mainly for user local profiles, but the main rule follows this):
Login Shell
First and foremost: /etc/profile is loaded (global settings);
Next: ˜/.bash_profile (local user settings- other files may be found, like ˜/.profile, depending on the distro. Check documentation).
So, if you are in a Login Shell environment, put all your crazy stuff inside ˜/.bash_profile (or the file provided by your distro) and everything will be fine.
Non-login Shell
First and foremost: /etc/bashrc (some distros will load bash.bashrc);
The next file to be seeked and loaded is ˜/.bashrc
And that's why so many people (just like me) got frustrated having to source their ˜/.bash_profile every single time a Terminal was loaded. We were simply inserting info in the "wrong" file- regarding the kind of shell loaded (see above: login, non-login).
More details on variants of the files mentioned above and some info on login vs non-login shell can be found here.
Hope it helps \o/