How to set path variables on osx el capitan? - oracle

I've not had success setting up an environment variable on El Capitan. Nothing to do with dock or bash shell. Trying to run a java gui which requires an environment path variable to a JDBC driver to connect to an oracle db:
http://docs.oracle.com/cd/E11882_01/install.112/e38228/inst_task.htm#BABBBHJH
I have tried methods:
in launchd.conf:
setenv JDBC /Users/mac_admin/Downloads/Oracle/instantclient_12_1
osx - Setting environment variables in OS X? - Stack Overflow
in .profile:
export JDBC /Users/mac_admin/Downloads/Oracle/instantclient_12_1
terminal - How do I set environment variables on OS X? - Ask Different
in .bash_profile:
export JDBC=$(/Users/mac_admin/Downloads/Oracle/instantclient_12_1)
Where to Set Environment Variables in Mac OS X
In each case, the export command at Terminal does not show the new variable.
What is correct method for El Capitan?
Is "JDBC" an acceptable name for the variable? Or am I supposed to label it PATH? I notice the export command already lists a PATH item, and I am afraid to overwrite it:
declare -x PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Frameworks/Mono.framework/Versions/Current/Commands"
Is /Users/mac_admin/Downloads/Oracle/instantclient_12_1 an acceptable location for the files?
thx

It kind-of matters where you want to use this. If you are just trying to get some binary utility to run from Terminal shells you launch add an export into ~/.bash_profile and you are good to go: export JDBC='Robert was here'
tcc-rkuhar:scouting robert.kuhar$ source ~/.bash_profile
tcc-rkuhar:scouting robert.kuhar$ echo $JDBC
Robert was here
You need the equals sign to get the environment variable set. Assuming that the value you've put in the export JDBC is a directly that has the binaries you want to execute. The line in your ~/.bash_profile is probably...
export JDBC=/Users/mac_admin/Downloads/Oracle/instantclient_12_1
PATH="${PATH}:$JDBC"
You'll know this worked if you
echo $PATH
/usr/local/bin:...blah...blah...blah::/Users/mac_admin/Downloads/Oracle/instantclient_12_1

Related

How to set custom Environment variable on Mac?

I have a requirement where I need to set a custom environment variable called CLUSTER_ENV = '#fooURL'
The steps I have followed are:
Open terminal, open bash_profile and save CLUSTER_ENV='#foo'. When I do echo $CLUSTER_ENV , I get blank output.
I did the same thing in the bashrc file and in this case, the $CLUSTER_ENV shows the value only when I run it in the same terminal window.
Which is the best or recommended way to permanently set the environment variable on a Mac?
Im running El Capitan.
I have gone through these links for reference:
http://osxdaily.com/2015/07/28/set-enviornment-variables-mac-os-x/
Mac OS X 10.9 - setting permanent environment variables
As you will normally do on any Linux distro: export CLUSTER_ENV=my.url.com which will have to be added to ~/.bash_profile

OSX 10.9 Mavericks environment variables: how to set environment variables

How I can EXPORT environment variable not just for one tab but for all system?
If i will use export JAVA_HOME=/Library/Java/Home it will set JAVA_HOME only for current terminal tab and after system restart I will need do it one more time.
How I can set environment variable globally to make by default?
How I can edit variables in $ env list?
Add an entry to ~/.bash_profile:
export JAVA_HOME=/Library/Java/Home
save it, (or create it if it doesn't exist)
quit Terminal.app
re-launch and you're in business.
This is the best place to add the entry in my opinion, although for the distinct differences on OS X of where to add environment variables specifically for one reason or another see:
https://apple.stackexchange.com/a/13019
And for a more generalized UNIX overview:
What's the difference between .bashrc, .bash_profile, and .environment?
You can set environment variables by adding the export commands to various configuration files. E.g. ~/.profile
You can find out more about what files can be used to modify your bash environment by reading the bash manual (man bash). If you're using a different shell then it's probably similar and its man page should contain the same info. You can also read this answer on unix.stackexchange.com, which has some of these details.
If you want to set environment variables for your entire user environment, including GUI applications, I believe you can do that using ~/.MacOSX/environment.plist.

Environment variable in GNOME, Scientific Linux 6.1

I am using Scientific Linux 6.1. To run a program (DS9) I need to set this environment variable:
export XPA_METHOD=local
So I saved it in .bashrc and there is no problem when I run the program from the bash terminal. But when I run it in the GUI (for example by clicking on "Open with ds9" in nautilus), this variable is not recognized.
I would really appreciate if anyone could help me in setting the environment variable in GNOME.
Add it to ~/.profile instead of .bashrc
Edit: Log off and on again for the change to take effect.

how to set up the environment variables on mac os x

I am trying to download myrna tool on mac os x.
for one of procedures on installation, "Set the MYRNA_HOME environment variable to point to the extracted directory (containing myrna_emr)"
So i tried this way
echo "export MYRNA_HOME=/.../....directory/.." >> ~/.bashrc
but it seems it does not work.(when i type echo MYRNA_HOME in command line, there is nothing OR when i type printenv MYRNA_HOME does not come out.)
anyone who knows how to set up Env Vars??
thank you,
There are several ways to do that. One would be adding your variable to ~/.bash_profile file.
Example:
MYRNA_HOME=/whatever/you/want/
export MYRNA_HOME
Then you can try if it works by logging in again and trying on a terminal:
$ echo $MYRNA_HOME
It should print whatever you set MRYNA_HOME to on ~/.bash_profile.
If you want the environment variable to be available to all users, you can change /etc/bashrc file. But I would prefer just changing one users' environment.

How to set the $PATH as used by applications in os x

I'm using ant to build my project, and use the 'svnversion' executable to insert a version id into my sources for easy tracking of versions.
Running this ant file from the command line works, I've set my $PATH in .profile to include the path to svnversion and it works fine.
Now I try and run this same ant file from inside Eclipse and that does not work - the PATH in eclipse is set in another way than the PATH of the shell, I suspect this has to be set in a plist somewhere, but I don't know where.
Correct -- it's in the plist file
~/.MacOSX/environment.plist
This file actually contains key-value pairs for any environment variables you want to set, for the whole login session. Unlike .profile/.cshrc etc, it's available to GUI programs. Unfortunately, you can't access other environment variables (e.g., you can't use $HOME) or use any other programmatic constructs here.
Update: note that this is no longer supported under OS X 10.8 Mountain Lion, alas.
A quick search at developer.apple.com turned up Setting environment variables for user processes.
On Mac OS X El Capitan (10.11.5), this works for me for per-user PATH entries (and other environment variables, for that matter).
create a file $HOME/.profile
set all PATH related variables in that file
(if using bash), have your .bash_profile source that file, and .bashrc. This should be the entire contents of your .bash_profile:
# $HOME.bash_profile:
source $HOME/.profile
source $HOME/.bashrc
Near as I can tell, Mac OS does not source .bash_profile on login for PATH, presumably because that is often very slow to run (initializing bash completion etc). It does seem to read $HOME/.profile.
You still need a $HOME/.bash_profile to trigger bash to read $HOME/.bashrc, which it otherwise wouldn't do for interactive, non-login terminals as the ones created by Terminal.app.

Resources