Instantly share code, notes, and snippets.

@justo /init.coffee
Last active Jan 15, 2016

Embed
What would you like to do?
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