Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

$PATH is not available on OSX when not launched from CLI #726

Closed
steelbrain opened this issue Jul 10, 2015 · 141 comments
Closed

$PATH is not available on OSX when not launched from CLI #726

steelbrain opened this issue Jul 10, 2015 · 141 comments

Comments

@steelbrain
Copy link
Owner

Ideas people?
I had thought of parsing ~/.bashrc or similar of users to extract the values ourselves but that doesn't seem like the best solution.

@steelbrain
Copy link
Owner Author

/cc @zcbenz (of Electron)

@steelbrain
Copy link
Owner Author

Resuming from #150 and AtomLinter/linter-jshint#120

@steelbrain
Copy link
Owner Author

Can someone try this and see if it works? https://github.com/sindresorhus/fix-path

@iam4x
Copy link
Contributor

iam4x commented Jul 10, 2015

@steeelbrain We may need to use BufferedNodeProcess from atom to run CLI linters.

@steelbrain
Copy link
Owner Author

@iam4x how does the buffered process solve this? does it support stdin?

@adarhef
Copy link

adarhef commented Jul 10, 2015

I just tried installing fix-path but I don't know how to actually use it, or whether simply installing it is sufficient. After running 'npm install --save fix-path' and reinstalling linter-jshint I still get the error.

@steelbrain
Copy link
Owner Author

@adarhef You will not just have to save it there, but will also have to modify the activate function to invoke it like

activate: ->
    require('fix-path')()

@adarhef
Copy link

adarhef commented Jul 10, 2015

After adding it the result of 'console.log(process.env.PATH)' on my setup is '/usr/bin:/bin:/usr/sbin:/sbin'

Is that what you'd expect? I'm still getting the error.

EDIT: The result before calling fix-path is the same as after activating it.

@steelbrain
Copy link
Owner Author

Ahh :( so we will have to try something else then

@aomader
Copy link

aomader commented Jul 11, 2015

This is not a problem of Atom or any other app, but how Mac OS X handles environment variables for CLI and GUI applications.

In order to update the environment variables for GUI applications without launching them from the shell to inherit the parents environment, you have to explicitly set them using launchctl.

E.g., to make your shells $PATH the default PATH for all GUI applications for the current session, just execute the following:

$ launchctl setenv PATH "$PATH"

A quick Googling should provide you with enough information how to do that on each login.

PS: Just to clarify, this is not a bug of Atom or any other GUI application and you shouldn't use packages like fix-path, because they don't solve the problem. The problem is a misunderstand on the user of the Mac, who should fix his GUI paths using the above methods OR you provide means to let the user specify absolute paths to required executables.

Altering and constructing a PATH from some source like the shell is a big NONO.

PPS: In this superuser question I outlined my current solution for Mac OS X 10.10.4 how to populate my shell environment variables, e.g., PATH, to use in my GUI applications.

@fburleigh
Copy link

I got here from an AtomLinter/linter-jshint issue about Atom's console showing:

Uncaught Error: write EPIPE 
JSHint Result

on opening any JS file. In other words, linting JS files using the "bundled" JS linter fails.

Facts: Atom 1.0.4, linter-jslint is 1.04, linter is 1.2.3. I open Atom from the CLI on OS X 10.10.4.

@ghost
Copy link

ghost commented Jul 11, 2015

Try use Atom from CLI it work for me.
My env: Atom 1.0.2, mac os el capitan beta 3, linter-jshint 1.0.4.

@fburleigh
Copy link

Alas, run from my command line, Atom's linter-jshint fails. I erred above: my Atom is 1.02. So except for OS X, we seem to have the same software. And I use the "bundled" jshint -- that is, I do not have an external JS linter so have not set a path to one. I think that is ok.

@rldona
Copy link

rldona commented Jul 11, 2015

I've found a way to fix it.

  1. Atom
  2. Open Your Init Script
  3. Add the following line:

process.env.PATH = ["/usr/local/bin", process.env.PATH].join(":")

Restart Atom.

That is all. Now everything works correctly :)

captura de pantalla 2015-07-12 a las 0 44 41

Enjoy !!

@jackhsu978
Copy link

@rldona your workaround works for me! thank you!

@AlexKvazos
Copy link

@rldona Thank you for that work around.

@vbourgeois
Copy link

Same as @psko for me too...

@heyyoyo
Copy link

heyyoyo commented Jul 20, 2015

Same error on windows 7.

Uncaught Error: write EOF
C:\Users\XXXX.atom\packages\linter-jshint\lib\main.coffee:75 JSHint Result:

@steelbrain
Copy link
Owner Author

JSHint people see AtomLinter/linter-jshint#145 (comment)

@stdavis
Copy link

stdavis commented Jul 20, 2015

Latest update fixed the issue for me on OSX. Thanks!

@dheerajvs
Copy link

Same as @psko for me on Windows 7 (plugin version 1.1.2)

@distributedlock
Copy link

Getting the same bug as @psko on Windows 7 as well. Proper environment variables have been set and even then it is the same bug. Tried manually changing the executable path setting in the linter-jshint config.

@steelbrain
Copy link
Owner Author

@adamreisnz
Copy link

I've started getting this issue again on OS X unfortunately:

ss

This is with linter-jshint version 1.1.2. It worked for a while without problems though :)

@steelbrain
Copy link
Owner Author

For jshint users, I had to make a change that passes ENV from atom the the spawned linters, It fixed AtomLinter/linter-jshint#140 but introduced AtomLinter/linter-jshint#145
To fix this issue until we do, You can just downgrade helper version of jshint

cd ~/.atom/packages/linter-jshint
npm install atom-linter@2.0.0

@renestalder
Copy link

Just want to add, Atom pointed me to this issue here with the dialogs shown by all the other people. Anyway, I had wrong formating in my .jshintrc file. Fixing the syntax, removed the error. So first check if you are using a .jshintrc configuration and it hasn't any syntax errors.

@augbog
Copy link

augbog commented Aug 10, 2015

Confirming that downgrading to atom-linter@2.0.0 for Mac OS X 10.10.3 fixed the issue for me! Thanks @steelbrain !

@piotr-cz
Copy link

Like @renestalder i had an error in my .jshintrc file.
I suggest to change add to the message advising to check the .jshintrc file.

@aendra-rininsland
Copy link

A stray comma in .jshintrc throws the above error. I'd politely suggest improving that error message, it's fairly misleading.

@cloudbring
Copy link

@Aendrew Making sure my .jshintrc is valid (without trailing commas) fixed it for me.

@steelbrain
Copy link
Owner Author

Here's an announcement for you, we have recently published a release of atom-linter (npm helper module for linter providers) that now automatically determines $PATH even if atom is not launched from terminal. Therefore all linters using it for execution will be working consistently from both dock and cli

@filipesilva
Copy link

Sweet. 👍

@daverogers
Copy link

Thanks 👍

@Arcanemagus
Copy link
Collaborator

Working on publishing updates to plugins that include this now 😉.

@nemoDreamer
Copy link

Woooot! 🍭

@devkinetic
Copy link

Latest version here, using El Capitan and ZSH. Having this issue with a few linters. Adding the following to my init seems to the trick.

exec = require('child_process').exec
exec('source ~/.zshrc')

childProcess = require('child_process')
process.env.PATH = childProcess.execFileSync(process.env.SHELL, ['-i', '-c', 'echo $PATH']).toString().trim()

@Arcanemagus
Copy link
Collaborator

@devkinetic Any linter using atom-linter to execute it's program should be fixed, if you could file an issue on atom-linter with the linter plugins that aren't working for you that would be helpful.

@vlasenkov
Copy link

vlasenkov commented Apr 1, 2017

Similar problem here:
AtomLinter/linter-clang#200

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests