OS X environment variables not set (e.g. $GOPATH)


#1

Currently, my Atom installation no longer inherits environment variables when launched from anything other than a terminal. This is a particular problem for developing in the Go programming language (golang) because an environment variable, $GOPATH, is required to access code completion and linting tools.

This issue is well known and has a long history with Atom. On macOS/OS X, your login shell is not involved in the startup of the OS in the same way as Linux. The desktop environment, dock, etc are started directly by the root process, launchd. Because environment variables declared by your login shell are not set unless your shell is an ancestor in the process tree, apps launched from the dock do not see the same environment as apps launched from your shell.

This OS quirk was circumvented by the environment package for older versions of Atom, and this fix was merged into Atom itself in v1.7.0.

However, this fix seems to have regressed. I am not sure when my machine first started showing this problem again. I am on Atom v1.9.8 and OS X v10.11.6.

My questions: Has this regression affected others? If so, does the dev team know? If not, what are the likely system configurations that could lead to not having the environment I want?

For now, I will revert to launching Atom from my terminal.

P.S. I believe the implementation of this fix caused startup slowdown on my machine, perhaps because of my shell setup.


#2
  1. Yes, it regressed.
  2. Yes, the dev team was made aware of it by one of the official maintainers
  3. We’re working on a fix

#3

This has since been fixed in v1.9.9.


#4

I’m on 1.15.0 and still seeing this issue


#5

I can’t reproduce the problem you’re describing. Here’s what I did:

  1. I have ATOM_REPOS_HOME set to /Users/Lee/Source in my shell environment (this can be seen here)
  2. Exit all instances of Atom to ensure a clean boot
  3. Launch Atom from the icon in my Dock
  4. Open the Developer Tools using Alt+Cmd+I
  5. Click the Console tab
  6. Enter process.env.ATOM_REPOS_HOME

Expected and Actual: /Users/Lee/Source is output in response

I performed these steps using Atom v1.15.0 and v1.17.0-dev-82c49001f on Mac OS X 10.12.3.

If you can give us exact repro steps like I just did, then we can possibly help more with the problem you’re running into.