1

Emacs doesn't use macOS's /etc/launchd.conf env variables. I have the following there:

function addToPATH {
    case ":$PATH:" in
        *":$1:"*) :;; # already there
        *) PATH="$1:$PATH";; # or PATH="$PATH:$1"
    esac
}

export JAVA_HOME8=`/usr/libexec/java_home --version 1.8`
export JAVA_HOME9=`/usr/libexec/java_home --version 9`
export JAVA_HOME=$JAVA_HOME8
addToPATH $JAVA_HOME

But when I use getenv in Emacs to see my JAVA_HOME, it's unset. Setting it using setenv in my init file solves my issue, but this is an ugly workaround.

PS: I also set this variable in .zshenv, which I source in .bashrc, which I source in .bash_profile. So I am really confused that Emacs is not picking this up.

1
  • Many people with OSX use this library to set the path and exec-path: github.com/purcell/exec-path-from-shell I personally prefer to set those variables at the time a process is launched or on a buffer-local basis, but that requires advanced Emacs tinkering with the functions ... To set other environmental variables, you may wish to have a look at the function setenv-internal and set the variable process-environment. Commented Apr 24, 2018 at 15:49

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.