Git Product home page Git Product logo

Comments (33)

silverwind avatar silverwind commented on August 12, 2024

Which shell is that and where are those path extensions set? Also, is shell-path at 1.0.2?

from fix-path.

davej avatar davej commented on August 12, 2024

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.

silverwind avatar silverwind commented on August 12, 2024

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.

davej avatar davej commented on August 12, 2024
> echo $SHELL
/bin/bash

from fix-path.

silverwind avatar silverwind commented on August 12, 2024

is it /bin/bash in your electron app too?

dialog.showErrorBox("path", process.env.SHELL)

from fix-path.

davej avatar davej commented on August 12, 2024

Yup.

screen shot 2015-08-01 at 14 34 51

from fix-path.

silverwind avatar silverwind commented on August 12, 2024

Hmm, hard one. What about

dialog.showErrorBox("path", require("child_process").execSync('/bin/bash -i -c "echo $PATH"').toString())

from fix-path.

davej avatar davej commented on August 12, 2024

Same as before: /usr/bin:/bin:/usr/sbin:/sbin.

from fix-path.

silverwind avatar silverwind commented on August 12, 2024

Hmm, I honestly have no idea. Does /bin/bash -i -c "echo $PATH" in terminal give the correct path?

from fix-path.

davej avatar davej commented on August 12, 2024

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.

silverwind avatar silverwind commented on August 12, 2024

Does it work in node?

node -p 'require("child_process").execSync("/bin/bash -i -c \"echo $PATH\"").toString()'

from fix-path.

davej avatar davej commented on August 12, 2024

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.

davej avatar davej commented on August 12, 2024

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.

silverwind avatar silverwind commented on August 12, 2024

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.

davej avatar davej commented on August 12, 2024

This also worked by the way (running from bash): > ~/Downloads/Test.app/Contents/MacOS/Electron

screen shot 2015-08-01 at 15 05 37

from fix-path.

davej avatar davej commented on August 12, 2024
>  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.

screen shot 2015-08-01 at 15 09 31

from fix-path.

silverwind avatar silverwind commented on August 12, 2024

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.

davej avatar davej commented on August 12, 2024

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.

silverwind avatar silverwind commented on August 12, 2024

Should be fixed as of shell-path 1.0.4. @davej could you reinstall your modules and retest?

from fix-path.

davej avatar davej commented on August 12, 2024

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.

silverwind avatar silverwind commented on August 12, 2024

I was never able to reproduce on my machine, but I'm pretty sure it's fixed, thanks.

from fix-path.

davej avatar davej commented on August 12, 2024

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.

silverwind avatar silverwind commented on August 12, 2024

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.

davej avatar davej commented on August 12, 2024

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.

silverwind avatar silverwind commented on August 12, 2024

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.

davej avatar davej commented on August 12, 2024

No luck :(
execFileSync also fails. Catching the error is the same, the socket still closes.

from fix-path.

silverwind avatar silverwind commented on August 12, 2024

Do you have any idea which socket this is referring to? I'm not too familar with Electron :)

from fix-path.

davej avatar davej commented on August 12, 2024

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.

silverwind avatar silverwind commented on August 12, 2024

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.

davej avatar davej commented on August 12, 2024

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.

davej avatar davej commented on August 12, 2024

Perhaps a fix-path.async method might be useful though?

from fix-path.

silverwind avatar silverwind commented on August 12, 2024

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.

davej avatar davej commented on August 12, 2024

Sure.

from fix-path.

Related Issues (13)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.