I was trying to access environment variables in an Eclipse Scala Worksheet and it wouldn't work.
Initially it was because my variable was defined in .bashrc
and that is not good, since .bashrc
is only for login shells and not GUI applications. I changed the variables to .profile
, sourced the file and reloaded my session (logging out and logging in, just in case). After that I could access the variables in a normal Scala script (in Eclipse) but still couldn't in the worksheet. Any ideas?
Thanks!
UPDATE:
testworksheet.sc
object testworksheet {
val key = sys.env("my_key")
// Result in a NoSuchElementException in the worksheet,
// though works in a script.
}
~/.profile
export my_key=my_value