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

Resolve standard VS Code variables in "terminal.integrated.env.*" #34337

Closed
rongduan-zhu opened this issue Sep 14, 2017 · 10 comments · Fixed by #40059
Closed

Resolve standard VS Code variables in "terminal.integrated.env.*" #34337

rongduan-zhu opened this issue Sep 14, 2017 · 10 comments · Fixed by #40059
Assignees
Labels
feature-request Request for new features or functionality help wanted Issues identified as good community contribution opportunities terminal General terminal issues that don't fall under another label verification-needed Verification of issue is requested verified Verification succeeded
Milestone

Comments

@rongduan-zhu
Copy link

rongduan-zhu commented Sep 14, 2017

  • VSCode Version: 1.15.1
  • OS Version: macOS Sierra 10.12.6

Steps to Reproduce:

  1. Update workspace settings to something like
{
  "terminal.integrated.env.osx": {
    "PATH": "/home"
  }
}
  1. Now open Terminal and look at PATH
echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/home

On Windows, having the same setting will not result in the current PATH being prepended, but instead, just setting the path to whatever is defined in terminal.integrated.env.*

Reproduces without extensions: Yes

@vscodebot vscodebot bot added the terminal General terminal issues that don't fall under another label label Sep 14, 2017
@Tyriar
Copy link
Member

Tyriar commented Sep 14, 2017

Unless there's a more intuitive way of doing this through the terminal.integrated.env.* settings, I'd rather not support it. This would make replacing PATH impossible and inconsistent with how other keys work.

There is a workaround though by using something like --rcfile to run a script on init.

@Tyriar Tyriar closed this as completed Sep 14, 2017
@Tyriar Tyriar added the *as-designed Described behavior is as designed label Sep 14, 2017
@rongduan-zhu
Copy link
Author

rongduan-zhu commented Sep 15, 2017

Hi @Tyriar , my description was confusing.
So on Mac, with the setting below

{
  "terminal.integrated.env.osx": {
    "PATH": "/home"
  }
}

the resulting PATH in terminal in VS Code will be something like /usr/local/bin:/usr/bin:/bin:/usr/sbin:/home. /usr/local/bin:/usr/bin:/bin:/usr/sbin was added to terminal.integrated.env.osx.PATH

Whereas on Windows, having the "same" setting

{
  "terminal.integrated.env.windows": {
    "PATH": "C:\bin"
  }
}

the resulting PATH in the integrated terminal will be just C:\bin, nothing else will be added to PATH besides whats defined for terminal.integrated.env.windows.PATH.

Having different behavior for Windows and Mac is strange. Also, on Mac, it seems that only the PATH key in terminal.integrated.env.osx is being changed, we have other env variables defined in terminal.integrated.env.osx and they all stayed the same, this is super confusing...

This is really hurting us because our app allows the user to open a project in our app using VS Code, and our app installs a custom Python. We use terminal.integrated.env.osx.PATH to essentially tell the terminal to use the Python installed by our app instead of the Python installed by the user, where the binary could be in, say, /usr/local/bin. This works fine on Windows because VS Code is not modifying anything, but on Mac, things are broken because VS Code is modifying terminal.integrated.env.osx.PATH.

@Tyriar
Copy link
Member

Tyriar commented Sep 15, 2017

It's the same behavior, it's just that Windows PATH is typically set and complete when you login into Windows whereas on Mac it has more entries added to it through the ~/.bash_profile and ~/.bashrc files.

Also, on Mac, it seems that only the PATH key in terminal.integrated.env.osx is being changed, we have other env variables defined in terminal.integrated.env.osx and they all stayed the same, this is super confusing...

Are you sure your start up scripts are not overriding the values here?

but on Mac, things are broken because VS Code is modifying terminal.integrated.env.osx.PATH

It's fairly typical to set the system's python version using alias in one of these files. Could that be messing with it?

@rongduan-zhu
Copy link
Author

Hi @Tyriar , thank you for providing pointers on where to check. I've checked the Mac I'm using, there is no ~/.bash_profile or ~/.bashrc file. After some more investigation, looks like on Mac, there is a path_helper function which appends paths defined in /etc/paths and /etc/paths.d to PATH. And that is invoked in /etc/profile. I think this is causing the issue.

Thank you for the help, agree with you that this is not a VS Code issue.

@yume-chan yume-chan mentioned this issue Sep 25, 2017
@Tyriar
Copy link
Member

Tyriar commented Sep 25, 2017

Apparently tasks.json supports the syntax ${env:Name}. So I'll reopen this feature request to allow the following:

{
  "terminal.integrated.env.windows": {
    "PATH": "${env:PATH};C:\bin"
  }
}

@dbaeumer does this sound consistent with what's supported in tasks.json?

@Tyriar Tyriar added feature-request Request for new features or functionality help wanted Issues identified as good community contribution opportunities and removed *as-designed Described behavior is as designed labels Sep 25, 2017
@Tyriar Tyriar reopened this Sep 25, 2017
@dbaeumer
Copy link
Member

@Tyriar yes, ${env:Name} is consistent with tasks and debug. There is a configuration resolver service you can use to get the values.

@Tyriar
Copy link
Member

Tyriar commented Sep 28, 2017

@dbaeumer great!

This is open to PRs 😃

@Tyriar Tyriar changed the title Prepending current PATH to PATH defined in "terminal.integrated.env.osx" Resolve standard VS Code variables in "terminal.integrated.env.*" Oct 23, 2017
@pvgoran
Copy link

pvgoran commented Oct 25, 2017

This would be a useful feature to have. Just now, I was searching for a way to amend the PATH environment variable, and I was quite surprised that there is no straightforward way to do it. (For now, I went with specifying --rcfile in terminal.integrated.shellArgs.linux, but it's far from a clean solution.)

@JohnKozell
Copy link

+1, just tried appending or prepending the path in user settings, does not work.
Moreover, the terminal environment variables set in user settings, do not seem to apply to tasks - am I understanding that correct?
Another way around this, might be to enable tasks to run multiple commands, then I could add a batch file to set environment variables, such as Path.

@Tyriar
Copy link
Member

Tyriar commented Dec 11, 2017

Related: #2809

@ramya-rao-a ramya-rao-a added this to the December 2017 milestone Dec 12, 2017
@Tyriar Tyriar added the verification-needed Verification of issue is requested label Jan 28, 2018
@vscodebot vscodebot bot locked and limited conversation to collaborators Jan 31, 2018
@ramya-rao-a ramya-rao-a added the verified Verification succeeded label Jan 31, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature-request Request for new features or functionality help wanted Issues identified as good community contribution opportunities terminal General terminal issues that don't fall under another label verification-needed Verification of issue is requested verified Verification succeeded
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants