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 issues with -i #30847

Closed
joaomoreno opened this issue Jul 17, 2017 · 7 comments
Closed

Path issues with -i #30847

joaomoreno opened this issue Jul 17, 2017 · 7 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug macos Issues with VS Code on MAC/OS X wont-fix workbench-os-integration Native OS integration issues
Milestone

Comments

@joaomoreno
Copy link
Member

@idan says

@joaomoreno, so happy to have run across this issue after tearing all my hair out trying to understand why my extensions had a path of /usr/bin:/bin:/usr/sbin:/sbin. I'm on OSX, fish 2.5.0., 1.14.0.

Getting the same behavior as @lunaryorn above — removing the -i or changing the spawn's stdio to ['pipe', 'pipe', process.stderr] results in returned output containing the correct PATH. If I dig into result.envPairs it's still PATH=/usr/bin:/bin:/usr/sbin:/sbin though, I don't grok what's going on there.

This is causing the vscode flow extension to blow up, claiming that node isn't in the PATH, because node isn't installed in any one of /usr/bin:/bin:/usr/sbin:/sbin.

I tried the insiders build you linked in your last comment here, but it doesn't seem to solve anything. Any pointers on how I can try running a build with the changes from #29864? Do I just need to figure out how to build VSCode? Are there any shortcuts there?

Thanks for all of your hard work on this — it's really appreciated! ✨ 🍰

@joaomoreno joaomoreno added the info-needed Issue requires more information from poster label Jul 17, 2017
@joaomoreno joaomoreno self-assigned this Jul 17, 2017
@joaomoreno
Copy link
Member Author

@idan I've removed your original post from #21655. Let's look at your issue independently.

You can find out how to compile VS Code over here. It would be awesome if you went through it and try to figure out what is going on, as I fail to reproduce these issues in Fish.

Another idea involves you sending me your full Fish configuration, so I could try to repro this.

@idan
Copy link

idan commented Jul 23, 2017

@joaomoreno beh, apologies, I got mixed up with the different issues and wrote an update on #29864.

tl;dr I've managed to cobble together a working build, but haven't been able to figure out how to make a double-clickable thing that I don't run from a terminal. gulp vscode-darwin doesn't seem to produce something I can use, or else I'm not clear on where to find it, and the build docs are mute on the matter.

As for my fish config, here's the relevant files from my ~/.config/fish dir:

config.fish

# Disable the greeting
set fish_greeting

set -x EDITOR "/usr/local/bin/code --wait"

alias ls "ls -FG"
alias git "hub"
alias h 'heroku'
alias hp 'heroku pg:psql'
alias d. 'desk .'

# chruby
. /usr/local/share/chruby/chruby.fish
. /usr/local/share/chruby/auto.fish
chruby 2.3.1

# Add node binpath by default
. ~/.config/fish/node_bin_path.fish

# Hook for desk activation
test -n "$DESK_ENV"; and . "$DESK_ENV"

# n-install
set -gx N_PREFIX $HOME/n
set -gx PATH $N_PREFIX/bin $PATH

eval (direnv hook fish)

node_bin_path.fish

function __node_binpath_cwd -v PWD
  set -l node_modules_path "$PWD/node_modules/.bin"
  if test -e "$node_modules_path"
    set -g __node_binpath "$node_modules_path"
    set -x PATH $PATH $__node_binpath
  else
    set -q __node_binpath
      and set -l index (contains -i -- $__node_binpath $PATH)
      and set -e PATH[$index]
      and set -e __node_binpath
  end
end

__node_binpath_cwd $PWD

There's also a fish_prompt.fish and a fish_right_prompt.fish but I can't imagine that they'd be relevant to this as they're purely for display.

Thank you so much for helping me track this down!

@joaomoreno
Copy link
Member Author

joaomoreno commented Jul 24, 2017

@idan And what are the exact variables that Code fails to pick up? Just one is sufficient.

@idan
Copy link

idan commented Jul 26, 2017

@joaomoreno Ok, tried with the insiders build you linked in 29864, and unfortunately still getting the bad path behavior, where process.env.PATH is incorrect (/usr/bin: /bin:/usr/sbin:/sbin) when I launch from the finder (vs invoking via terminal)

PATH is the variable I'm interested in, since it's the blocker right now.

@joaomoreno joaomoreno added this to the August 2017 milestone Jul 27, 2017
@joaomoreno joaomoreno added bug Issue identified by VS Code Team member as probable bug workbench-os-integration Native OS integration issues macos Issues with VS Code on MAC/OS X and removed info-needed Issue requires more information from poster labels Jul 27, 2017
@joaomoreno joaomoreno modified the milestones: September 2017, Backlog Sep 27, 2017
@kergoth
Copy link

kergoth commented Sep 11, 2018

Just a note that, afaik, mac apps launched by usual means (finder, etc) don't have access to the user's PATH. It's controlled by launchd and LSEnvironment in the app .plist. The default PATH can be altered via /etc/paths or /etc/paths.d, but this is global. If you google for setting PATH in gui mac apps you'll see numerous threads of people complaining about .MacOSX/environment.plist no longer working.

If it's launched via code at a command-line, LSEnvironment is no longer applied, and the PATH in the app will reflect the user's PATH. The same behavior occurs in sublime text and other gui mac apps which launch processes via the PATH.

Extensions can of course alter their own search paths, the python one locates python in virtual environments, etc. It'd be nice if there was a global setting to alter PATH for the entire code process and extensions rather than having to adjust a ton of .path settings in settings.json.

@amyspark
Copy link

amyspark commented Dec 3, 2019

Changing shells via chsh does not break (or unbreak) PATH until and unless I log off and back in. If I set Bash as my shell and relog, all the variables I specify in .bashrc/.bash_profile are picked up. If I set Fish as my shell, every variable is dropped.

Is there any way I can help you track this down?

@jacobeatsspam
Copy link

@idan Are you using direnv to modify PATH in this case?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug macos Issues with VS Code on MAC/OS X wont-fix workbench-os-integration Native OS integration issues
Projects
None yet
Development

No branches or pull requests

5 participants