Giter Club home page Giter Club logo

Comments (18)

sindresorhus avatar sindresorhus commented on June 11, 2024

What did you get? What did you expect? Operating system? Etc.

from shell-path.

ericbiewener avatar ericbiewener commented on June 11, 2024

I'm trying to execute the shell script brew install taglib (using child_process.exec), but I get the error that the brew command cannot be found. Similarly, using exec to run gem list doesn't return the gems I have installed in my rvm-managed version of ruby.

My full path should look like:

/Users/ericbiewener/.rvm/gems/ruby-2.3.0/bin:/Users/ericbiewener/.rvm/gems/ruby-2.3.0@global/bin:/Users/ericbiewener/.rvm/rubies/ruby-2.3.0/bin:/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin:/Users/ericbiewener/Repos/venv/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/ericbiewener/.rvm/bin

When logging the results of shellPath.sync() from main.js, I get the following:

/usr/bin:/bin:/usr/sbin:/sbin:/Users/ericbiewener/.rvm/bin

When logging the results of shellPath.sync() in the client-side JS, I simply get undefined.

I'm on OS X 10.11.4

from shell-path.

ericbiewener avatar ericbiewener commented on June 11, 2024

And in case it helps, when running as a non-packaged app, I get the following output to my console when running shellPath.sync() (this occurs even if I don't try logging anything, but just call that method):

bash: no job control in this shell
exit

from shell-path.

sindresorhus avatar sindresorhus commented on June 11, 2024

Hmm, weird. You're using Bash, right?

from shell-path.

ericbiewener avatar ericbiewener commented on June 11, 2024

Yes. I came across this module today and am experiencing the same issue:

https://github.com/steelbrain/consistent-path

On Tuesday, May 10, 2016, Sindre Sorhus [email protected] wrote:

Hmm, weird. You're using Bash, right?


You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub
#11 (comment)

from shell-path.

sindresorhus avatar sindresorhus commented on June 11, 2024

Can you try running the following code in the packaged app and share the output:

require('child_process').execFileSync('/bin/bash', ['--version'], {encoding: 'utf8'})
require('child_process').execFileSync('/bin/bash', ['-ic', 'env'], {encoding: 'utf8'})
require('child_process').execFileSync('/bin/bash', ['-ic', 'echo $PATH'], {encoding: 'utf8'})

from shell-path.

silverwind avatar silverwind commented on June 11, 2024

Also might help to know where these paths are defined in your dotfiles.

from shell-path.

ericbiewener avatar ericbiewener commented on June 11, 2024

The output of those three, in order:

GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin15)
Copyright (C) 2007 Free Software Foundation, Inc.
(I removed a few items here that didn't seem relevant and that had the word "private" in them)

SHELL=/bin/bash
TMPDIR=/var/folders/cq/bg8lr0dn3v91kzxnhgk8jf640000gn/T/
USER=ericbiewener
__CF_USER_TEXT_ENCODING=0x1F5:0x0:0x0
PATH=/usr/bin:/bin:/usr/sbin:/sbin:/Users/ericbiewener/.rvm/bin
PWD=/
XPC_FLAGS=0x0
XPC_SERVICE_NAME=com.electron.bowie.194592
SHLVL=1
HOME=/Users/ericbiewener
LOGNAME=ericbiewener
_=/usr/bin/env
/usr/bin:/bin:/usr/sbin:/sbin:/Users/ericbiewener/.rvm/bin

In regards to where the desired paths are defined in my dotfiles:

.bash_profile

  • /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin
  • /Users/ericbiewener/Repos/venv/bin

.bash_rc

  • /Users/ericbiewener/.rvm/bin

Not sure where the ...rvm/gems... paths are defined, but I could probably figure that out from the RVM website if necessary.

from shell-path.

ericbiewener avatar ericbiewener commented on June 11, 2024

Not sure if it helps, but I get the same result even if I try running a bash file via execFile and include the shebang #!/usr/bin/env bash at the top. I had hoped that this would cause the correct environment to get pulled in, but no dice.

from shell-path.

sindresorhus avatar sindresorhus commented on June 11, 2024

I was tipped about path_helper today. Seems like it handles more cases.

@ericbiewener Mind running this in a packaged app?

require('child_process').execFileSync('/usr/libexec/path_helper', {encoding: 'utf8'})

from shell-path.

sindresorhus avatar sindresorhus commented on June 11, 2024

// @adam-moss ⬆️ Can you too?

from shell-path.

adam-moss avatar adam-moss commented on June 11, 2024

@sindresorhus console.log(require('child_process').execFileSync('/usr/libexec/path_helper', {encoding: 'utf8'})); in Atom gives me:

VM2003:2 PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/adam.moss/GitHub/ansible/bin:/Users/adam.moss/.nvm/versions/node/v6.2.2/bin"; export PATH;
MANPATH="/usr/share/man:/usr/local/share/man:/Users/adam.moss/GitHub/ansible/docs/man:/Users/adam.moss/.nvm/versions/node/v6.2.2/share/man:/Library/Developer/CommandLineTools/usr/share/man"; export MANPATH;
undefined

echo $PATH for comparison:

/Users/adam.moss/GitHub/ansible/bin:/Users/adam.moss/.nvm/versions/node/v6.2.2/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

Regards

from shell-path.

ericbiewener avatar ericbiewener commented on June 11, 2024

@sindresorhus It gave me:

PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"; export PATH;

from shell-path.

sindresorhus avatar sindresorhus commented on June 11, 2024

Thanks @adam-moss. So it seems path_helper would at least solve #6.

from shell-path.

sindresorhus avatar sindresorhus commented on June 11, 2024

@ericbiewener Hmm, still no dice. Maybe we can just hard-code some paths in https://github.com/sindresorhus/fix-path

from shell-path.

silverwind avatar silverwind commented on June 11, 2024

path_helper is used in /etc/profile, which in turn should be sourced by all shells. I'd not be opposed to us enriching our paths array with paths from path_helper.

from shell-path.

silverwind avatar silverwind commented on June 11, 2024

I updated shell-env (sindresorhus/shell-env@c704d61) to use -l to obtain a login shell, which in turn should lead to /etc/profile being sourced. @ericbiewener can you verify if this is fixed by reinstalling the module?

from shell-path.

silverwind avatar silverwind commented on June 11, 2024

I'll close this off as I'm pretty certain above update has fixed this issue.

from shell-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.