How does Atom populate process.env when called via terminal?


#1

Hi, first time posting here.

The problem I’m having is that when started via terminal (atom .), somehow process.env does not only inherits the environment variables from my shell.

For example, setting export HELLO=foo and then running atom ., process.env.HELLO would equal foo as expected.

However, PWD does not behave the same:

$ echo $PWD
Users/bobbypriambodo/Projects/project-path
$ atom .
# then in Atom console
> process.env.PWD
"/"
# `PWD=$PWD atom .` also behaves the same

The messed up parts also include PATH. In developing in OCaml, we rely heavily on shell vars; switching projects means we need to adjust the vars accordingly. However, in Atom those vars somehow got overwritten into the global ones (possibly because PWD="/"?) by who knows what, making Atom unable to find the necessary binaries (which differs between projects) for plugins to work.

How exactly does Atom populate process.env? What files (if any) does it read other than the current shell’s variables? Help is much appreciated.

I’m using MacOS Sierra with Atom 1.21.1.


#2

Someone from Slack pointed out that they can’t reproduce this issue (thanks @tangledhelix), and I retried with clean Atom installations (basically moving my ~/.atom out of the way and reopening Atom) and the problem disappears. Confirmed must be due to my installed plugins. Will need to investigate further.