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 environment variable not consistent for Extension Host #106783

Closed
giovdk21 opened this issue Sep 15, 2020 · 6 comments
Closed

PATH environment variable not consistent for Extension Host #106783

giovdk21 opened this issue Sep 15, 2020 · 6 comments
Assignees
Labels
*duplicate Issue identified as a duplicate of another issue(s) info-needed Issue requires more information from poster

Comments

@giovdk21
Copy link

  • VSCode Version: 1.49.0 e790b931385d72cf5669fcefc51cdf65990efa5d
  • OS Version: macOS Catalina 10.15.6 (19G2021)

Steps to Reproduce:

  1. Unfortunately it seems to be random

Description:

When running an extension locally (Extension Host) the result/value of process.env.PATH varies between it reflecting the PATH I have defined in my shell and just /usr/bin:/bin:/usr/sbin:/sbin

Basically most of the time the value of process.env.PATH corresponds to the results of typing printenv PATH in my terminal window (I use fish as my default shell) but sometimes it just returns /usr/bin:/bin:/usr/sbin:/sbin.

My extension uses execFile in order to run a command line tool that I have installed in a bin folder under my user home dir. however when process.env.PATH only return the "default" directories listed above, the command is not found (ENOENT).

While I appreciate there are several workarounds to this, it took me a while to figure out what was causing execFile to fail since the behaviour happens randomly and I would expect the value of process.env.PATH to be consistent.
Furthermore I never managed to reproduce this using the extension debugger (I ended up having to log the value of process.env.PATH to the extension output channel)

@Tyriar
Copy link
Member

Tyriar commented Sep 15, 2020

Is this randomness caused by whether you launch via the CLI or the dock? Note you'll need to close the app with cmd+Q in between checking as the environment won't refresh without fully exiting.

@Tyriar Tyriar added the info-needed Issue requires more information from poster label Sep 15, 2020
@giovdk21
Copy link
Author

I almost always run it from the Dock and when I run it from command line it's usually from the VSCode terminal.

Another way the app is opened is when macOS launches it automatically after a reboot (e.g. if the OS freezes and you need to shut it down holding the power button).

I'll try to see if that is what's causing it, but I'm pretty sure it also happened a few times after running it from the Dock.

Thanks

@iFwu
Copy link

iFwu commented Sep 16, 2020

I can confirm this problem too.

@giovdk21
Copy link
Author

giovdk21 commented Sep 17, 2020

I can confirm that this happens by just launching it from the Dock:

  • launched VSCode the first time from the Dock and the PATH is wrong (/usr/bin:/bin:/usr/sbin:/sbin)
  • reloaded window ("Developer: Reload Window")
  • the PATH is now correct and execFile returns the PID instead of ENOENT
  • closed VSCode (Cmd +Q)
  • launched VSCode the second time from the Dock and the PATH is still correct.

From what I remember using "Developer: Reload Window" does not always work either though (i.e. I'm sure I tried it before and the PATH was still "wrong" after doing it)

@tamuratak
Copy link
Contributor

Related to #30847. And, the comment, #30847 (comment), is helpful.

You can find similar issues searching with the words fish and PATH.

@Tyriar
Copy link
Member

Tyriar commented Nov 6, 2020

/duplicate #30847

@Tyriar Tyriar closed this as completed Nov 6, 2020
@github-actions github-actions bot locked and limited conversation to collaborators Dec 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
*duplicate Issue identified as a duplicate of another issue(s) info-needed Issue requires more information from poster
Projects
None yet
Development

No branches or pull requests

5 participants
@giovdk21 @Tyriar @tamuratak @iFwu and others