10
votes

I don't know if this is a general Emacs issue or clojure/cider specific. Anyway: How do I pass through environment variables which work in the shell and are configured currently in my ~/.profile. Now if I lein repl in my project, this works just fine:

(System/getenv "FOO")
-> "BAR

But when I cider-jack-in in my project, the CIDER repl can't see the variable:

(System/getenv "FOO")
-> nil

I'm using the GUI (Cocoa) version of Emacs version 24.4.50. Cider version is cider-20140718.747.

1
A GUI app will not see settings from your shell config on OSX. I think this answer is what you need (launchd.conf, not .profile, since your GUI apps are not launched by a shell that loads .profile).noisesmith
I'm on the fence about marking this question a duplicate of the question above? @auramo, what do you think?Arthur Ulfeldt
The answer is spot on. The question doesn't mention GUI apps specifically though. If it would, I'd call this just a special case of that question.auramo

1 Answers

4
votes

You can either, as noisesmith points out, set the environment variables system wide so you don't need to cause emacs to use your .profile settings, or you can start emacs from the command line so that it gets the settings from .profile as in this answer: https://stackoverflow.com/a/13243093/90801 Starting it from the command line is nice because you can start several emacs's with different settings. or start them from a script:

FOO="BAR" /Applications/Emacs.app/Contents/MacOS/Emacs project.clj

would start emacs with foo having the value "BAR" without changing anything system wide.