-
Notifications
You must be signed in to change notification settings - Fork 17.4k
load $PATH when launched as an app #6956
Comments
At least from the node runtime, a process can be found on the
Here's the try
childProcess = require('child_process')
atomProcs = childProcess.execSync("launchctl list | grep #{process.pid} | grep Atom").toString().split()
launchRegex = ///^#{process.pid}\t[0\-]\t.*\.Atom///
matches = (line for line in atomProcs when launchRegex.exec(line))
if matches.length > 0
console.log("Fixing paths for Atom")
process.env.PATH = childProcess.execFileSync('/bin/bash', ['-c', 'echo $PATH']).toString().trim()
process.env.GOPATH = childProcess.execFileSync('/bin/bash', ['-c', 'echo $GOPATH']).toString().trim()
catch exception
console.error("Exception during PATH fixes: #{exception}") It would be great for Atom to detect if it's running from launchd and build the |
From the man page describing the sub command config:
One of the two available parameters is path:
This worked for me:
Using the If you don't want to permanently modify your launchctl config you can also start the following script at bootup, say from Apple Script:
|
Git filter clean smudge doesn't use the correct python version for me, took me a while before I got here. Any updates on this? |
+1 |
+1 |
Just edit process.env.PATH on the init file, you can append more paths there. |
@peduxe Did you read my comment above? I'm talking about hundreds of package authors affected by this issue. And obviously, telling all these packages' users to "just edit their init file" is not an acceptable solution. Letting alone that your suggestion goes completely against DRY -- if I add something to my |
@UltCombo I completely agree with you. Things should just work when you install them, out of the box. |
@UltCombo Yes you're right it should be corrected no matter what, I simply provided a quick solution for those who didn't know about it. |
@peduxe Oh, sorry for the misunderstanding. 😄 By the way, I've added |
The solution suggested by @mathiasringhof didn't work for me on El Capitan, I had to use "user" domain: sudo launchctl config user path /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin |
I don't like hardcoding my path anywhere since it's assembled through my dotfiles and changes when I update node with NVM. Having said that one of the previous solutions posted using
More explanation in the gist: https://gist.github.com/justo/4a92655056f43d32ae72 |
I have fixed the Therefore I've created my own consistent-path npm module that does not modify globals and returns a correct I would recommend this to every Atom package developer who's experiencing this issue |
I think this needs to be solved in core, and not via an npm package or an atom package (and I say this as the author of https://atom.io/packages/environment). I think we need to do two things to fix Atom's handling of the environment:
/cc @lee-dohm |
The hack to set env vars in |
This issue has been automatically locked since there has not been any recent activity after it was closed. If you can still reproduce this issue in Safe Mode then please open a new issue and fill out the entire issue template to ensure that we have enough information to address your issue. Thanks! |
When Atom is launched as an application, it doesn't get the user's PATH, because it was launched by
launchctl
. This means that packages like script and hydrogen have to tell the user to launch Atom from the command line. Some packages (like hydrogen) can't even be installed without the PATH because their dependencies use native extensions built withnode-gyp
. There exist tools such asfix-path
, but they clobber the user's PATH even if they've set something on purpose (with e.g. a virtualenv).Having access to the user's PATH will become more and more important as people build packages that interface more deeply with languages, other tools, and the user's environment. Forcing the user to configure each package with complete paths to the binaries it needs is possible, but inelegant, and becomes intractable with general-purpose tools.
This seems like a clear situation where making this change to Atom itself would dramatically simplify life for many packages and eliminate many bugs arising from poor attempts to capture the PATH.
The text was updated successfully, but these errors were encountered: