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

Installation Failure on Windows - "Cannot connect to c: resolve failed" #382

Open
awmorgan opened this issue Jan 19, 2025 · 5 comments
Open
Labels

Comments

@awmorgan
Copy link

I'm having trouble installing the Zig Language extension (ziglang.vscode-zig) in VS Code on my Windows machine. The extension won't install correctly.

When I try to install the Zig Language extension, I get the following error message:

Failed to install Zig 0.14.0-dev.2577: Failed to extract Zig tarball: Command failed: C:\Program Files\Git\usr\bin\tar.EXE -xf c:\Users\arthu\AppData\Roaming\Code\User\globalStorage\ziglang.vscode-zig\zig\windows-x86_64-0.14.0-dev.2577+271452d22\zig-windows-x86_64-0.14.0-dev.2577+271452d22.zip -C c:\Users\arthu\AppData\Roaming\Code\User\globalStorage\ziglang.vscode-zig\zig\windows-x86_64-0.14.0-dev.2577+271452d22 --strip-components=1 /usr/bin/tar: Cannot connect to c: resolve failed

It seems like the extension is trying to use the tar command from Git for Windows, and there's some kind of path issue.

@awmorgan
Copy link
Author

in the vscode extension, versionManager.ts is picking the wrong tar to use:

C:\Users\arthu>where tar
C:\Windows\System32\tar.exe
C:\Program Files\Git\usr\bin\tar.exe

it should be using C:\Windows\System32\tar.exe

The path is probably different in the vscode environment where I installed the extension

@awmorgan
Copy link
Author

changing this setting from "Git Bash" to "Command Prompt" fixed the extension installation failure issue:

"terminal.integrated.defaultProfile.windows": "Command Prompt",

@Vexu Vexu added the bug label Jan 19, 2025
@Techatrix
Copy link
Collaborator

I tried to reproduce this issue and here is what I observed:

Visual Studio Code About:

Version: 1.96.4 (user setup)
Commit: cd4ee3b1c348a13bafd8f9ad8060705f6d4b9cba
Date: 2025-01-16T00:16:19.038Z
Electron: 32.2.6
ElectronBuildId: 10629634
Chromium: 128.0.6613.186
Node.js: 20.18.1
V8: 12.8.374.38-electron.0
OS: Windows_NT x64 10.0.19045

I tried playing around with the following changes:

  • which shell is running VS Code: cmd.exe, pwsh.exe or bash.exe (Git Bash)
  • which shell is running inside the integrated terminal: "Command Prompt" or "Git Bash"
  • the available options in the "Adjusting your PATH environment"1 section when installing Git for Windows

I modified the Zig extension to instead log out the $PATH and try to find tar:

import which from "which";
import path from "path";

export async function activate(context: vscode.ExtensionContext) {
    const output = vscode.window.createOutputChannel("zig", { log: true });

    output.info("Shell: ", vscode.env.shell);
    output.info("which tar (all): ", which.sync("tar", { all: true }));
    output.info("which tar: ", await which("tar", { nothrow: true }));
    output.info("PATH: ", process.env.PATH?.split(path.delimiter), "\n");
    vscode.env.onDidChangeShell(async (newShell) => {
        output.info("new Shell: ", newShell);
        output.info("Shell: ", vscode.env.shell);
        output.info("which tar (all): ", which.sync("tar", { all: true }));
        output.info("which tar: ", await which("tar", { nothrow: true }));
        output.info("PATH: ", process.env.PATH?.split(path.delimiter), "\n");
    }, context.subscriptions);
}

Integrated Terminal shell: bash.exe (Git Bash) and then switched to cmd.exe (Command Prompt)
VS Code process shell: cmd.exe (Command Prompt)

Result
2025-01-23 20:17:19.286 [info] Shell:  C:\Program Files\Git\bin\bash.exe
2025-01-23 20:17:19.286 [info] which tar (all):  ["C:\\Windows\\system32\\tar.EXE","C:\\Windows\\system32\\tar.exe"]
2025-01-23 20:17:19.289 [info] which tar:  C:\Windows\system32\tar.EXE
2025-01-23 20:17:19.290 [info] PATH:  ["C:\\Windows\\system32","C:\\Windows","C:\\Windows\\System32\\Wbem","C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\","C:\\Windows\\System32\\OpenSSH\\","C:\\Program Files (x86)\\NVIDIA Corporation\\PhysX\\Common","C:\\Program Files\\dotnet\\","C:\\Program Files\\nodejs\\","C:\\Program Files\\PowerShell\\7\\","C:\\Program Files\\NVIDIA Corporation\\NVIDIA app\\NvDLISR","C:\\Program Files\\Neovim\\bin","C:\\Program Files\\Git\\cmd","C:\\Users\\techatrix\\AppData\\Local\\Programs\\Python\\Python39\\Scripts\\","C:\\Users\\techatrix\\AppData\\Local\\Programs\\Python\\Python39\\","C:\\Users\\techatrix\\AppData\\Local\\Microsoft\\WindowsApps","C:\\Users\\techatrix\\AppData\\Local\\Microsoft\\WinGet\\Links","C:\\Users\\techatrix\\AppData\\Local\\Programs\\VSCodium\\bin","E:\\Software\\musikcube","C:\\Users\\techatrix\\AppData\\Roaming\\npm","C:\\Users\\techatrix\\.zvm\\self","C:\\Users\\techatrix\\.zvm\\bin","C:\\Users\\techatrix\\AppData\\Local\\Programs\\Microsoft VS Code\\bin",""] 

2025-01-23 20:18:13.964 [info] new Shell:  C:\Windows\System32\cmd.exe
2025-01-23 20:18:13.964 [info] Shell:  C:\Windows\System32\cmd.exe
2025-01-23 20:18:13.965 [info] which tar (all):  ["C:\\Windows\\system32\\tar.EXE","C:\\Windows\\system32\\tar.exe"]
2025-01-23 20:18:14.013 [info] which tar:  C:\Windows\system32\tar.EXE
2025-01-23 20:18:14.013 [info] PATH:  ["C:\\Windows\\system32","C:\\Windows","C:\\Windows\\System32\\Wbem","C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\","C:\\Windows\\System32\\OpenSSH\\","C:\\Program Files (x86)\\NVIDIA Corporation\\PhysX\\Common","C:\\Program Files\\dotnet\\","C:\\Program Files\\nodejs\\","C:\\Program Files\\PowerShell\\7\\","C:\\Program Files\\NVIDIA Corporation\\NVIDIA app\\NvDLISR","C:\\Program Files\\Neovim\\bin","C:\\Program Files\\Git\\cmd","C:\\Users\\techatrix\\AppData\\Local\\Programs\\Python\\Python39\\Scripts\\","C:\\Users\\techatrix\\AppData\\Local\\Programs\\Python\\Python39\\","C:\\Users\\techatrix\\AppData\\Local\\Microsoft\\WindowsApps","C:\\Users\\techatrix\\AppData\\Local\\Microsoft\\WinGet\\Links","C:\\Users\\techatrix\\AppData\\Local\\Programs\\VSCodium\\bin","E:\\Software\\musikcube","C:\\Users\\techatrix\\AppData\\Roaming\\npm","C:\\Users\\techatrix\\.zvm\\self","C:\\Users\\techatrix\\.zvm\\bin","C:\\Users\\techatrix\\AppData\\Local\\Programs\\Microsoft VS Code\\bin",""] 

Integrated Terminal shell: bash.exe (Git Bash) and then switched to cmd.exe (Command Prompt)
VS Code process shell: bash.exe (Git Bash)

Result
2025-01-23 20:19:11.890 [info] Shell:  C:\Program Files\Git\usr\bin\bash.exe
2025-01-23 20:19:11.890 [info] which tar (all):  ["C:\\Program Files\\Git\\usr\\bin\\tar.EXE","C:\\Program Files\\Git\\usr\\bin\\tar.exe","C:\\Program Files\\Git\\usr\\bin\\tar.EXE","C:\\Program Files\\Git\\usr\\bin\\tar.exe","C:\\Program Files\\Git\\usr\\bin\\tar.EXE","C:\\Program Files\\Git\\usr\\bin\\tar.exe","C:\\Windows\\system32\\tar.EXE","C:\\Windows\\system32\\tar.exe"]
2025-01-23 20:19:11.953 [info] which tar:  C:\Program Files\Git\usr\bin\tar.EXE
2025-01-23 20:19:11.953 [info] PATH:  ["C:\\Users\\techatrix\\bin","C:\\Program Files\\Git\\mingw64\\bin","C:\\Program Files\\Git\\usr\\local\\bin","C:\\Program Files\\Git\\usr\\bin","C:\\Program Files\\Git\\usr\\bin","C:\\Program Files\\Git\\mingw64\\bin","C:\\Program Files\\Git\\usr\\bin","C:\\Users\\techatrix\\bin","C:\\Windows\\system32","C:\\Windows","C:\\Windows\\System32\\Wbem","C:\\Windows\\System32\\WindowsPowerShell\\v1.0","C:\\Windows\\System32\\OpenSSH","C:\\Program Files (x86)\\NVIDIA Corporation\\PhysX\\Common","C:\\Program Files\\dotnet","C:\\Program Files\\nodejs","C:\\Program Files\\PowerShell\\7","C:\\Program Files\\NVIDIA Corporation\\NVIDIA app\\NvDLISR","C:\\Program Files\\Neovim\\bin","C:\\Program Files\\Git\\cmd","C:\\Users\\techatrix\\AppData\\Local\\Programs\\Python\\Python39\\Scripts","C:\\Users\\techatrix\\AppData\\Local\\Programs\\Python\\Python39","C:\\Users\\techatrix\\AppData\\Local\\Microsoft\\WindowsApps","C:\\Users\\techatrix\\AppData\\Local\\Microsoft\\WinGet\\Links","C:\\Users\\techatrix\\AppData\\Local\\Programs\\VSCodium\\bin","E:\\Software\\musikcube","C:\\Users\\techatrix\\AppData\\Roaming\\npm","C:\\Users\\techatrix\\.zvm\\self","C:\\Users\\techatrix\\.zvm\\bin","C:\\Users\\techatrix\\AppData\\Local\\Programs\\Microsoft VS Code\\bin","C:\\Program Files\\Git\\usr\\bin\\vendor_perl","C:\\Program Files\\Git\\usr\\bin\\core_perl"] 

2025-01-23 20:19:17.216 [info] new Shell:  C:\Windows\System32\cmd.exe
2025-01-23 20:19:17.216 [info] Shell:  C:\Windows\System32\cmd.exe
2025-01-23 20:19:17.216 [info] which tar (all):  ["C:\\Program Files\\Git\\usr\\bin\\tar.EXE","C:\\Program Files\\Git\\usr\\bin\\tar.exe","C:\\Program Files\\Git\\usr\\bin\\tar.EXE","C:\\Program Files\\Git\\usr\\bin\\tar.exe","C:\\Program Files\\Git\\usr\\bin\\tar.EXE","C:\\Program Files\\Git\\usr\\bin\\tar.exe","C:\\Windows\\system32\\tar.EXE","C:\\Windows\\system32\\tar.exe"]
2025-01-23 20:19:17.240 [info] which tar:  C:\Program Files\Git\usr\bin\tar.EXE
2025-01-23 20:19:17.240 [info] PATH:  ["C:\\Users\\techatrix\\bin","C:\\Program Files\\Git\\mingw64\\bin","C:\\Program Files\\Git\\usr\\local\\bin","C:\\Program Files\\Git\\usr\\bin","C:\\Program Files\\Git\\usr\\bin","C:\\Program Files\\Git\\mingw64\\bin","C:\\Program Files\\Git\\usr\\bin","C:\\Users\\techatrix\\bin","C:\\Windows\\system32","C:\\Windows","C:\\Windows\\System32\\Wbem","C:\\Windows\\System32\\WindowsPowerShell\\v1.0","C:\\Windows\\System32\\OpenSSH","C:\\Program Files (x86)\\NVIDIA Corporation\\PhysX\\Common","C:\\Program Files\\dotnet","C:\\Program Files\\nodejs","C:\\Program Files\\PowerShell\\7","C:\\Program Files\\NVIDIA Corporation\\NVIDIA app\\NvDLISR","C:\\Program Files\\Neovim\\bin","C:\\Program Files\\Git\\cmd","C:\\Users\\techatrix\\AppData\\Local\\Programs\\Python\\Python39\\Scripts","C:\\Users\\techatrix\\AppData\\Local\\Programs\\Python\\Python39","C:\\Users\\techatrix\\AppData\\Local\\Microsoft\\WindowsApps","C:\\Users\\techatrix\\AppData\\Local\\Microsoft\\WinGet\\Links","C:\\Users\\techatrix\\AppData\\Local\\Programs\\VSCodium\\bin","E:\\Software\\musikcube","C:\\Users\\techatrix\\AppData\\Roaming\\npm","C:\\Users\\techatrix\\.zvm\\self","C:\\Users\\techatrix\\.zvm\\bin","C:\\Users\\techatrix\\AppData\\Local\\Programs\\Microsoft VS Code\\bin","C:\\Program Files\\Git\\usr\\bin\\vendor_perl","C:\\Program Files\\Git\\usr\\bin\\core_perl"] 

The only way I could reproduce this issue was by using Git Bash to start VS Code. The other options like the integrated terminal did not matter. This is also what I would have expected since the tar command is not being ran from the integrated terminal. The path environment variable comes from the shell that ran VS Code and not from the integrated terminal.


The only way I got where tar to include C:\Program Files\Git\usr\bin\tar.exe when running from the Command Prompt was by selecting the "Use Git and optional Unix Tools from the Command Prompt"1 option when installing Git. Otherwise it would not be included.

To support running from Git Bash, it may make sense to look for %SystemRoot%/system32/tar.exe first before looking it up in the path.

@awmorgan

  • What output do you get when running echo %PATH% from the Command Prompt?
  • How did you start VS Code? From the Start Menu, from a terminal, etc.? Do you still get the same issue when opening the Command Prompt and then running code to start VS Code?
  • Do you recall selecting a different option in "Adjusting your PATH environment"1 menu when installing Git? Could you check if reinstalling Git with the recommended option fixes your issue?

Footnotes

  1. The "Adjusting your PATH environment" menu when installing Git: Image 2 3

@awmorgan
Copy link
Author

What output do you get when running echo %PATH% from the Command Prompt?

C:\Users\arthu>echo %PATH%
C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\WINDOWS\System32\OpenSSH;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Program Files\HP\OMEN-Broadcast\Common;C:\Program Files\HP\HP One Agent;C:\Program Files\nodejs;C:\Program Files\GitHub CLI;C:\Program Files (x86)\Windows Kits\10\Windows Performance Toolkit;C:\Program Files\CMake\bin;C:\Program Files\Git\cmd;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\bin;C:\Users\arthu\AppData\Local\Programs\Python\Python312\Scripts;C:\Users\arthu\AppData\Local\Programs\Python\Python312;C:\Users\arthu\AppData\Local\Programs\Python\Launcher;C:\Users\arthu\AppData\Local\Microsoft\WindowsApps;C:\Users\arthu\git\go\bin;C:\Users\arthu\go\bin;C:\tinygo\bin;C:\Users\arthu\AppData\Local\Programs\Microsoft VS Code\bin;

How did you start VS Code? From the Start Menu, from a terminal, etc.?

It varies, sometimes click on icon on task bar, sometimes start menu, sometimes type code at the terminal and the terminal that i launch it from could be inside or outside of vscode.

Do you still get the same issue when opening the Command Prompt and then running code to start VS Code?

yes, first launch from cmd.exe, then launch code again from within code at git bash prompt which i do frequently.

you should be able to reproduce with this sequence:
before starting reproduction sequence:
have git bash set as the default integrated terminal before running code from cmd.exe.
uninstall zig language extension
delete zig extension directory (replacing user name): C:\Users\arthu\AppData\Roaming\Code\User\globalStorage\ziglang.vscode-zig\zig

reproduce with:
open cmd.exe
check path for tar.exe, you should see C:\Windows\System32\tar.exe is first:
C:\Users\arthu>where tar
C:\Windows\System32\tar.exe
C:\Program Files\Git\usr\bin\tar.exe

C:\Users\arthu>

launch code from cmd.exe
when vscode launches, hit ctrl+j to open git bash terminal and check tar path you see the priority has flipped. git bash version is now first in path:

arthu@anakin MINGW64 ~/tmp
$ where tar
C:\Program Files\Git\usr\bin\tar.exe
C:\Windows\System32\tar.exe

launch code again from git bash prompt
arthu@anakin MINGW64 ~/tmp
$ code -r foo (note: foo is the directory ~/tmp/foo)

install zig language extension.

ctrl+shift+p select "zig setup: install zig"
it will download and the extract will fail and it will start spinning through every mirror downloading and failing every extract

Image

Do you recall selecting a different option in "Adjusting your PATH environment"1 menu when installing Git?

no but i probably picked the bottom option to use unix tools from command prompt

ould you check if reinstalling Git with the recommended option fixes your issue?

no, because i don't think it will because of the scenario i outlined above.

thanks for taking the time to look into this

@zendril
Copy link

zendril commented Feb 6, 2025

I'm not starting vscode from within git-bash.

I intentionally put git utilities on the path as I like to have unix-like utilities available in my cmd shell.
I have terminal set to start it with cmd.exe /k <path-to>\dev-env\win\setup-env.bat and in that setup-env.bat I manually set paths and aliases, etc..

So my PATH includes C:\Program Files\Git\bin;c:\Program Files\Git\usr\bin near the beginning

So if this extension is relying on the windows tar (and its params), then why wouldn't it be just using the C:\Windows\System32\tar.exe path? (Assuming it knows it is installing on windows vs linux)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants