【发布时间】:2021-01-24 19:10:06
【问题描述】:
我无法让 VS Code code.exe 在 WSL 中正常运行。 (我在这里找到了一个相关的问题,但它并没有解决这个问题 - Launch VS Code from WSL Bash)。
在 WSL(任何发行版)中,我们可以访问 Windows 上的任何可执行文件。例如
alias chrome="\"/mnt/c/Program Files/Google/Chrome/Application/chrome.exe\"" # Open Chrome from WSL
alias notepad++="\"/mnt/c/Program Files/Notepad++/notepad++.exe\"" # Open Notepad++
在 bash 中输入 chrome 将打开 Chrome,notepad++ ~/.bashrc 将在 Notepad++ 中打开 .bashrc
这一切都很好。
但是,我遇到了choco inst VisualStudioCode 安装提供的code.exe 的问题。当我尝试时:
alias vscode="\"/mnt/c/ProgramData/chocolatey/bin/code.exe\""
这真的很失败。
[main 2021-01-24T18:44:17.966Z] update#setState idle
(node:20404) Electron: Loading non-context-aware native module in renderer: '\\?\C:\tools\vscode\resources\app\node_modules.asar.unpacked\vscode-sqlite3\build\Release\sqlite.node'. This is deprecated, see https://github.com/electron/electron/issues/18397.
(node:20404) Electron: Loading non-context-aware native module in renderer: '\\?\C:\tools\vscode\resources\app\node_modules.asar.unpacked\spdlog\build\Release\spdlog.node'. This is deprecated, see https://github.com/electron/electron/issues/18397.
(node:18692) Electron: Loading non-context-aware native module in renderer: '\\?\C:\tools\vscode\resources\app\node_modules.asar.unpacked\spdlog\build\Release\spdlog.node'. This is deprecated, see https://github.com/electron/electron/issues/18397.
所以,我可以忽略这一点,只在 Ubuntu 中使用 code.exe(因为 WSL 将扫描路径以查找可执行文件)。这种有效,但出现以下错误:
'\\wsl$\Ubuntu-20.04\home\boss'
CMD.EXE was started with the above path as the current directory.
UNC paths are not supported. Defaulting to Windows directory.
VS Code确实打开,但如果将文件名作为参数,文件将无法打开(同时注意对于 notepad++ 示例,所有打开的文件都使用上述别名完美运行)。
似乎是在说 code.exe 不支持 UNC 路径,但它确实支持 UNC 路径,正如我从 PowerShell 中看到的那样。 code.exe \\HPEnvy\Drive-D\test.txt 完美打开。
这将真正完善我的 WSL 设置,以便能够打开我正在使用 VS Code 无缝处理的代码。有谁知道为什么会发生这种情况/如何解决?
【问题讨论】:
标签: bash ubuntu windows-subsystem-for-linux chocolatey