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

Preserve per-window environment variables between workspace changes #108571

Closed
vkk-steigend opened this issue May 6, 2020 · 5 comments
Closed
Assignees
Labels
feature-request Request for new features or functionality insiders-released Patch has been released in VS Code Insiders on-testplan workbench-cli VS Code Command line issues workbench-os-integration Native OS integration issues
Milestone

Comments

@vkk-steigend
Copy link

  • VSCode Version: 1.44.2
  • Local OS Version: Ubuntu 18.04.4 LTS
  • Remote OS Version: Debian Buster (10.3)
  • Remote Extension/Connection Type: Docker

Steps to Reproduce:

  1. Open a terminal in host machine
  2. Start an ssh-agent by eval $(ssh-agent -s)
  3. Add a key (key1) using ssh-add ~/.ssh/id_ed25519_key1
  4. Open VS Code from the same terminal code .
  5. Run ssh-add -l in VS Code terminal (shows the identity of key1) (:+1: )
  6. Open folder in Remote Container
  7. Run ssh-add -l in VS Code terminal (shows the identity of key1) (:+1: )
  8. Open another terminal in host machine
  9. Start a new ssh-agent by eval $(ssh-agent -s)
  10. Add a key (key2) using ssh-add ~/.ssh/id_ed25519_key2
  11. Open VS Code from the same terminal code .
  12. Run ssh-add -l in VS Code terminal (shows the identity of key2) (:+1: )
  13. Open folder in Remote Container
  14. Run ssh-add -l in VS Code terminal (shows the identity of key1) (:-1: )

VS Code somehow only forwards the first ssh-agent to remote container eventhough it has the correct ssh-agent forwarded locally. Am I missing any configuration? Can this be fixed with any settings in devcontainer.json?

Does this issue occur when you try this locally?: No
Does this issue occur when you try this locally and all extensions are disabled?: N/A

@vkk-steigend vkk-steigend changed the title Support different identities (ssh-key) in different VS Code instances (launched simultaneously) inside Remote Containere Support different identities (ssh-key) in different VS Code instances (launched simultaneously) inside Remote Container May 6, 2020
@chrmarti
Copy link
Contributor

@bpasero Opening a second window from an (external) terminal passes the environment variables from that terminal to the second window (which is good). These environment variables are then lost when that window opens another folder/URI and the environment variables from the first window are used (causing the unexpected behavior here).

Simplified steps (on Mac):

  • Close all VS Code windows.
  • In external terminal: FOO=window1 code
    • Verify in integrated terminal: echo $FOO (window1)
  • In external terminal: FOO=window2 code -n
    • Verify in integrated terminal: echo $FOO (window2)
  • Open another folder in second window.
    • Check in integrated terminal: echo $FOO (window1) 🐛

@chrmarti chrmarti transferred this issue from microsoft/vscode-remote-release Oct 13, 2020
@bpasero bpasero added feature-request Request for new features or functionality workbench-cli VS Code Command line issues labels Oct 13, 2020
@bpasero bpasero changed the title Support different identities (ssh-key) in different VS Code instances (launched simultaneously) inside Remote Container Preserve per-window environment variables between workspace changes Oct 13, 2020
@bpasero bpasero added the workbench-os-integration Native OS integration issues label Oct 13, 2020
@bpasero bpasero added this to the Backlog milestone Oct 13, 2020
@bpasero
Copy link
Member

bpasero commented Oct 13, 2020

Slightly related: #15452

@bpasero
Copy link
Member

bpasero commented Nov 20, 2020

Logic is here and I hope it does not break anything. Idea is that we preserve the windows userEnv if it was started from a CLI and the new config is not:

ff1887b#diff-ce055d098d503f8b3309d514fd97e4a84da4515e21ee102618bbb2097087ab2bR687-R689

@bpasero bpasero added the author-verification-requested Issues potentially verifiable by issue author label Nov 23, 2020
@github-actions
Copy link

This bug has been fixed in to the latest release of VS Code Insiders!

@vkk-steigend, you can help us out by confirming things are working as expected in the latest Insiders release. If things look good, please leave a comment with the text /verified to let us know. If not, please ensure you're on version 6026ab5 of Insiders (today's or later - you can use Help: About in the command palette to check), and leave a comment letting us know what isn't working as expected.

Happy Coding!

@vkk-steigend
Copy link
Author

/verified

@github-actions github-actions bot locked and limited conversation to collaborators Jan 13, 2021
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 insiders-released Patch has been released in VS Code Insiders on-testplan workbench-cli VS Code Command line issues workbench-os-integration Native OS integration issues
Projects
None yet
Development

No branches or pull requests

4 participants
@bpasero @chrmarti @vkk-steigend and others