Comments (33)
Which shell is that and where are those path extensions set? Also, is shell-path
at 1.0.2?
from fix-path.
Just the normal OS X bash shell, I run it with terminal. Most of the paths are set in ~/.profile
but there are a couple of others which must be coming from somewhere else (is there a way to find out where they are being set from?).
Yes, shell-path
is 1.0.2.
from fix-path.
I assume it's bash, but could you post echo $SHELL
, just to be sure?
Most paths probably come from /private/etc/profile
.
from fix-path.
> echo $SHELL
/bin/bash
from fix-path.
is it /bin/bash
in your electron app too?
dialog.showErrorBox("path", process.env.SHELL)
from fix-path.
Yup.
from fix-path.
Hmm, hard one. What about
dialog.showErrorBox("path", require("child_process").execSync('/bin/bash -i -c "echo $PATH"').toString())
from fix-path.
Same as before: /usr/bin:/bin:/usr/sbin:/sbin
.
from fix-path.
Hmm, I honestly have no idea. Does /bin/bash -i -c "echo $PATH"
in terminal give the correct path?
from fix-path.
Yes.
> /bin/bash -i -c "echo $PATH"
/Library/Frameworks/Python.framework/Versions/3.4/bin:/Applications/Postgres.app/Contents/Versions/9.3/bin:/usr/local/heroku/bin:/usr/local/sbin:/Users/dave/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/deployd/bin:/usr/local/go/bin:/usr/local/MacGPG2/bin
Hmmm, it's a strange one alright. I have recreated this behaviour on two macbook airs (my own and my friends). They were originally OS X 10.7 and have been upgraded through the years to 10.10. Perhaps some obscure config got mangled in one of the upgrades or something?
from fix-path.
Does it work in node?
node -p 'require("child_process").execSync("/bin/bash -i -c \"echo $PATH\"").toString()'
from fix-path.
Yup, works from node.
> node -p 'require("child_process").execSync("/bin/bash -c \"echo $PATH\"").toString()'
/Library/Frameworks/Python.framework/Versions/3.4/bin:/Applications/Postgres.app/Contents/Versions/9.3/bin:/usr/local/heroku/bin:/usr/local/sbin:/Users/dave/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/deployd/bin:/usr/local/go/bin:/usr/local/MacGPG2/bin
from fix-path.
Updated to latest iojs just in case (system node was 0.11). Same thing:
> node -p 'require("child_process").execSync("/bin/bash -c \"echo $PATH\"").toString()'
/Users/dave/.nvm/versions/io.js/v2.5.0/bin:/Library/Frameworks/Python.framework/Versions/3.4/bin:/Applications/Postgres.app/Contents/Versions/9.3/bin:/usr/local/heroku/bin:/usr/local/sbin:/Users/dave/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/deployd/bin:/usr/local/go/bin:/usr/local/MacGPG2/bin
from fix-path.
Hmm is it even executing the same bash?
dialog.showErrorBox("path", require("child_process").execFileSync("/bin/bash", ["--version"]).toString())
node -p 'require("child_process").execFileSync("/bin/bash", ["--version"]).toString()'
from fix-path.
This also worked by the way (running from bash): > ~/Downloads/Test.app/Contents/MacOS/Electron
from fix-path.
> node -p 'require("child_process").execFileSync("/bin/bash", ["--version"]).toString()'
GNU bash, version 3.2.53(1)-release (x86_64-apple-darwin14)
Copyright (C) 2007 Free Software Foundation, Inc.
from fix-path.
I'm out of ideas, electron seems to do something differently with bash, but I have no idea what. Maybe you could try downgrading electron if there was a recent change or something.
from fix-path.
Ok, thanks for your help. For the moment, I'll just explicitly add potential paths to process.env.PATH
and hope that covers it. Just to reiterate, the paths are working fine with Electron on my Macbook Pro which makes me think it's something to do with the OS X config on the Macbook Air.
I'll try an older version of Electron too. Thanks again.
from fix-path.
Should be fixed as of shell-path
1.0.4. @davej could you reinstall your modules and retest?
from fix-path.
I don't have the macbook air anymore so I won't be able to retest. I guess we can probably close this issue though if you think it should be fixed?
from fix-path.
I was never able to reproduce on my machine, but I'm pretty sure it's fixed, thanks.
from fix-path.
I received a report of this issue again. They were using fix-path 1.1.0 and shell-path 1.0.4. I stopped receiving these errors because I had manually added in common $PATHs (e.g. /usr/local/bin
). I took the hack out when I updated to the latest shell-path and the errors are back now.
I may be able to do some debugging of this on their machine on Thursday, so if you have any suggestions then let me know.
from fix-path.
I'd be interested in the output of
require('child_process').execSync('sudo -Hiu' + process.env.USER + ' echo $PATH', {encoding: 'utf8'})
Reading through electron/electron#550 makes me believe the issue only manifests when the application is not started through a terminal (e.g. through open
when its started through the GUI).
from fix-path.
After some testing on my local machine, I believe that the issue may be caused by usage of the child_process
execSync
method in the Electron renderer.
Basically, the first method (pathFromShellSync
) runs ok but causes an error (write EBADF
), the subsequent method (pathFromSudoSync
) fails because the socket is closed (due to the first error). This only effects the renderer, not the main process.
See here: electron/electron#3482
from fix-path.
Interesting. I don't suppose catching that error makes any difference?
Does execFile
behave differently perhaps?
require('child_process').execFileSync('sudo', ['-Hiu', process.env.USER, 'echo "$PATH"'], {encoding: 'utf8'})
from fix-path.
No luck :(
execFileSync
also fails. Catching the error is the same, the socket still closes.
from fix-path.
Do you have any idea which socket this is referring to? I'm not too familar with Electron :)
from fix-path.
Presumably the socket for streaming data to the child_process. I don't really understand it either though.
Here's the stacktrace: net.js:640
Uncaught Error: This socket is closed.(…)
Socket._writeGeneric @ net.js:640
Socket._write @ net.js:694
doWrite @ _stream_writable.js:292
writeOrBuffer @ _stream_writable.js:278
Writable.write @ _stream_writable.js:207
Socket.write @ net.js:618
execFileSync @ child_process.js:471(anonymous function) @ VM395:2
InjectedScript._evaluateOn @ VM184:904
InjectedScript._evaluateAndWrap @ VM184:837
InjectedScript.evaluate @ VM184:693
from fix-path.
Well, I guess you have to hardcode paths for now, this doesn't look like a simple fix. I'll try to dig deeper thought.
from fix-path.
Yeah, it's an upstream bug, I don't think there's much that can be done except wait for a fix. I might just use the shell-path
async method instead.
from fix-path.
Perhaps a fix-path.async method might be useful though?
from fix-path.
Yeah, that'd be a worthwile addition I think, as shell-path
already provides a async method. Care to file a PR?
from fix-path.
Sure.
from fix-path.
Related Issues (13)
- Ubuntu Linux Also ? HOT 4
- Fix-path breaks quit from dock in packaged electron app on OSX HOT 4
- Webpack warning: Module not found: Error: Can't resolve 'spawn-sync'
- Module not found: Can't resolve 'node:os' HOT 4
- ES Module import error HOT 2
- Must use import to load ES Module HOT 1
- Get $PATH from the real shell HOT 1
- Different PATH with fixPath compared to $PATH in terminal? HOT 17
- ANSI codes appear in process.env.PATH after fix-path HOT 19
- Unexpected token error HOT 7
- No effect in PATH? HOT 2
- Implement $PATH detection using `/usr/libexec/path_helper` HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fix-path.