Environment variable not getting set in Mac osx - macos

I usually set environment variables in ~/.bash_profile in my Mac. something like:
export JAVA_HOME=$(/usr/libexec/java_home)
export PATH=$PATH:$JAVA_HOME
export M2_HOME=/opt/mvn3.3.3
export PATH=$PATH:$M2_HOME/bin
This works fine for me.
I have recently installed Anaconda from continuum. I happened to have installed it only for my own account. Thus, the environment variable which I am trying to set is like:
export PATH="/Users/<username>/anaconda/bin:$PATH"
but this is not working.
If I export the same variable for terminal session then I can access the commands for that session in terminal. I think the problem is that Anaconda is being installed only for specific user. Please help.
Do I need to re-install it for all the users?
Can not we set an environment variable pointing to a particular user's path?
The bash_profile is for the same user, then why it is not working?

Related

How do I execute a bash script once a specific anaconda environment is activated

I would like to for a bash script to run automatically once a specific anaconda environment is activated.
Is there a file that behaves like a bashrc for the enviroment?
I tried to look at the files in the /opt/anaconda3/envs/ENV_NAME/ folder, but I wans't able to locate a file that would be excetued every time an environment is activated.
Thank you!
E

Miniconda: issue with shell configuration/initialization

I installed miniconda on our CentOS cluster and it all went fine. Then I asked miniconda to create a python 3.8 environment, and it went fine. However, when I try to activate the environment, I get the following error:
CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'.
To initialize your shell, run
$ conda init <SHELL_NAME>
I verified, and it's a bash environment. So I ran conda init bash and I got the following outputs:
no change /MyPath/miniconda3/condabin/conda
no change /MyPath/miniconda3/bin/conda
no change /MyPath/miniconda3/bin/conda-env
no change /MyPath/miniconda3/bin/activate
no change /MyPath/miniconda3/bin/deactivate
no change /MyPath/miniconda3/etc/profile.d/conda.sh
no change /MyPath/miniconda3/etc/fish/conf.d/conda.fish
no change /MyPath/miniconda3/shell/condabin/Conda.psm1
no change /MyPath/miniconda3/shell/condabin/conda-hook.ps1
no change /MyPath/miniconda3/lib/python3.9/site-packages/xontrib/conda.xsh
no change /MyPath/miniconda3/etc/profile.d/conda.csh
no change /home/users/me/.bashrc
No action taken.
So nothing happens. And when I try to activate the new environment, then I still get the first error.
Any idea how I can fix this?
[Solution] Thanks to the answer below, the issue was that despite testing that I was running/using a bash, I still have to run "bash" in the command line before activating model.
have you tried manually adding to ~/.bashrc?
add export PATH="/home/username/miniconda/bin:$PATH" in your bashrc file. make sure to replace /home/username/miniconda with your actual path now save the file, quit and reopen the terminal should work I guess.

Why when i restart the shell, java is unavailable?

I have installed java 1.7 on my mac, and I have edited ~/.bash_profile as the following:
export JAVA_HOME=/Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin/Content s/Home
export PATH=${JAVA_HOME}/bin:$PATH
When I execute source /.bash_profile, the java become available. But when I restart the shell, I got the following error message:
No Java runtime present, requesting install.
I have to re-execute source /.bash_profile to make it available.
I am so confused, hope someone can help me.
It is because variables you export are only valid in the current ssh session.
Look here for deeper explanation:
Mac OS X 10.9 - setting permanent environment variables
As #trojanfoe stated there:
The .bash_profile is only executed for a login-shell, whereas .bashrc
is executed for every new shell instance
Check this posting out please. I don't believe your problem is a JAVA problem but it looks rather misunderstanding on BASH side.

Apache Spark on EC2. Environment Variable problems. Mac OSX

I am following the tutorial found here to get a Spark Cluster up and running. I am using a Mac OS 10.9. I am new to using a Mac. When attempting to launch the cluster I get an error:
ERROR: The environment variable AWS_ACCESS_KEY_ID must be set
I don't fully understand environment variables etc. I thought I had created a .bash_profile in my home directory but it wasn't the case, as my home directory (~) is not where it should be. As such I located .profile and .bashrc & I know I need to edit one of them however, I can't. I consistently get Access Denied. I'm pretty stumped on what to do next. Any help would be greatly appreciated.
You can create your environment variables in bash like:
export AWS_ACCESS_KEY_ID=accesskeyhere
export AWS_SECRET_ACCESS_KEY=secretkeyhere

Cygwin not executing .bashrc after Heroku Toolbelt Windows install

After installing Heroku Toolbelt, Cygwin is no longer executing .bashrc How do I fix this?
This heroku/toolbelt issue on github Creates/overwrites ENV['HOME'] on Windows, which breaks Cygwin says to
Renaming HOME to %USERPROFILE% evidently fixes this
My HOME System Properties Variable is already named %USERPROFILE%.
Being a noobie I focused on a PATH issue. I began changing my System Path Variable to include the .bashrc PATH
C:\cygwin\home\usermatt
I then tried various system PATH variables, one at a time, restarting my machine each time:
C:\cygdrive\c\home\usermatt\
C:\home\usermatt\
C:\cygwin\c\home\usermatt\
Cygwin's pwd on startup is /cygdrive/c/Users/usermatt. I tried moving .bashrc here without success.
The Cygwin FAQs and the comments in the file itself warn of problems after editing the etc/profile file and I did not try this.
All was well before installing Heroku Toolbelt. How can I get Cygwin to find the .bashrc file?
According to the link you provided:
you need to remove the HOME environment variable from the system
properties. Look how to set/remove variables from Windows permanently.
This will depend on your Windows OS, but in general:
Right click on your "Computer" and select Properties
Click on "Advanced System Settings"
Click on "Environment Variables..."
Find and delete the Home variable
OK your way out and try Cygwin again

Resources