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

remote-cli code command works in bash, but zsh or tmux #236401

Open
samuela opened this issue Sep 2, 2022 · 6 comments
Open

remote-cli code command works in bash, but zsh or tmux #236401

samuela opened this issue Sep 2, 2022 · 6 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug remote Remote system operations issues terminal-process Problems launching processes, managing ptys, exiting, process leaks, etc. workbench-cli VS Code Command line issues
Milestone

Comments

@samuela
Copy link

samuela commented Sep 2, 2022

Version: 1.71.0 (Universal)
Commit: 784b017
Date: 2022-09-01T07:25:38.437Z
Electron: 19.0.12
Chromium: 102.0.5005.167
Node.js: 16.14.2
V8: 10.2.154.15-electron.0
OS: Darwin arm64 21.6.0
Sandboxed: No

  • VSCode Version: 1.71.0 (Universal)
  • Local OS Version: Darwin arm64 21.6.0
  • Remote OS Version:
  • Remote Extension/Connection Type: SSH
  • Logs: n/a

Steps to Reproduce:

  1. Ensure that terminal.integrated.inheritEnv is set to true (the default).
  2. Connect to remote machine via VSCode SSH.
  3. Open a bash terminal. Run code. Observe that it works.
  4. Open a zsh terminal. (Select from the dropdown menu on the "+" button.) Run code. Observe that it fails.
  5. Try the same for tmux. Observe that it fails as well.

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

It appears as though PATH is propagating correctly for bash, but not the other two:

# bash
my-machine:~$ echo $PATH
/home/sam.ainsworth/.nix-profile/bin:/nix/var/nix/profiles/default/bin:/home/sam.ainsworth/.vscode-server/bin/784b0177c56c607789f9638da7b6bf3230d47a8c/bin/remote-cli:/home/sam.ainsworth/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin:/usr/local/go/bin

# zsh
❯ echo $PATH
/home/sam.ainsworth/.nix-profile/bin:/nix/var/nix/profiles/default/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin:/usr/local/go/bin

# tmux
sam.ainsworth@cs-satze7x4cv-gpu-1662050665:~$ echo $PATH
/home/sam.ainsworth/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin:/usr/local/go/bin

Opening a bash terminal and then running zsh from within that terminal works.

Why is VSCode propagating different environment variables to different shells?

Potentially related: microsoft/vscode-remote-release#4460

@github-actions github-actions bot added the ssh label Sep 2, 2022
@roblourens roblourens removed the ssh label Dec 6, 2022
@meganrogge meganrogge added remote Remote system operations issues bug Issue identified by VS Code Team member as probable bug labels Dec 6, 2022
@Tyriar
Copy link
Member

Tyriar commented Dec 6, 2022

It's not clear what's causing this to me, if bash works and zsh doesn't in the same session I'm guessing it's because zsh is replacing the path against out will?

@meganrogge meganrogge added this to the Backlog milestone Dec 6, 2022
@samuela
Copy link
Author

samuela commented Jan 12, 2023

FWIW I worked around this by adding

      export PATH="''${VSCODE_GIT_ASKPASS_NODE%/*}/bin/remote-cli:$PATH"

to programs.zsh.initExtra in my home-manager config.

Outside of a nix file (.zshrc, .zprofile, etc), you can probably get away without the escaping:

      export PATH="${VSCODE_GIT_ASKPASS_NODE%/*}/bin/remote-cli:$PATH"

@Tyriar
Copy link
Member

Tyriar commented Dec 17, 2024

This is where the remote-cli is set:

const binFolder = environmentService.isBuilt ? join(environmentService.appRoot, 'bin') : join(environmentService.appRoot, 'resources', 'server', 'bin-dev');
const remoteCliBinFolder = join(binFolder, 'remote-cli'); // contains the `code` command that can talk to the remote server
let PATH = readCaseInsensitive(env, 'PATH');
if (PATH) {
PATH = remoteCliBinFolder + delimiter + PATH;
} else {
PATH = remoteCliBinFolder;
}
setCaseInsensitive(env, 'PATH', PATH);

This needs someone to follow the process creation through and see where that PATH variable gets removed.

@Tyriar Tyriar removed the remote Remote system operations issues label Dec 17, 2024
@Tyriar Tyriar transferred this issue from microsoft/vscode-remote-release Dec 17, 2024
@Tyriar Tyriar added remote Remote system operations issues workbench-cli VS Code Command line issues terminal-process Problems launching processes, managing ptys, exiting, process leaks, etc. labels Dec 17, 2024
@Tyriar Tyriar removed this from the Backlog milestone Dec 17, 2024
Copy link

Thanks for creating this issue! It looks like you may be using an old version of VS Code, the latest stable release is 1.96.0. Please try upgrading to the latest version and checking whether this issue remains.

Happy Coding!

@joshspicer
Copy link
Member

There was a report for "git bash" not getting set properly too, I suspect for the same reasons: microsoft/vscode-remote-release#9298

@Tyriar Tyriar added this to the Backlog milestone Dec 19, 2024
@joshspicer joshspicer marked this as not a duplicate of microsoft/vscode-remote-release#9298 Jan 6, 2025
@ELLIOTTCABLE
Copy link

ELLIOTTCABLE commented Jan 17, 2025

This has been happening for me, too, for a long time. Just found this earlier issue; had opened mine on the VSCode-Remote repos:

microsoft/vscode-remote-release#6641

Heck, even the workaround doesn't work for me, as the VScode shell-integration doesn't seem to be working in WSL unless it's set to bash - there's no $VSCODE_GIT_ASKPASS_NODE, nor any other VScode values, defined in the environment. )=

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue identified by VS Code Team member as probable bug remote Remote system operations issues terminal-process Problems launching processes, managing ptys, exiting, process leaks, etc. workbench-cli VS Code Command line issues
Projects
None yet
Development

No branches or pull requests

7 participants