Skip to content

Instantly share code, notes, and snippets.

@justo
Last active January 15, 2016 07:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save justo/4a92655056f43d32ae72 to your computer and use it in GitHub Desktop.
Save justo/4a92655056f43d32ae72 to your computer and use it in GitHub Desktop.
Atom mac path inheritance
# Problem: Atom won't inherit the $PATH variable set in your default OS X shell (Terminal).
# Solution: Launch an interactive shell and return $PATH from that. The interactive
# shell will run through all your various .files (.zshrc, .zshenv, etc.) before
# returning. Works well if your path is changed by NVM or RVM. Some existing solutions
# don't work if your shells output a MOTD or any other text before executing
# 'echo $PATH', as that will also be returned. Since your path _should_ be the last
# line output we can grab all text after the last newline character and use that as Atom's path.
#
# Some related issues:
# https://github.com/atom/atom/issues/6956
# https://github.com/atom-community/linter/issues/726
# Add this to your init.coffee script:
childProcess = require('child_process')
shellOutput = childProcess.execFileSync(process.env.SHELL, ['-i', '-c', 'echo $PATH']).toString().trim().split('\n')
process.env.PATH = shellOutput[shellOutput.length - 1]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment