the*_*cks 16 zsh nvm visual-studio-code
我正在尝试在 VSCode 中的窗口加载上运行任务,其中终端打开并nvm use && yarn dev默认运行。但是,运行此 shell 任务似乎不会加载我的 zsh 配置文件。
我运行任务得到的输出是:
The terminal process "zsh '-c', 'nvm use && yarn dev'" terminated with exit code: 127.
Terminal will be reused by tasks, press any key to close it.
Run Code Online (Sandbox Code Playgroud)
但是,如果我随后手动启动一个新终端并运行相同的命令(即:按加号,打开一个新的集成终端),它将按预期工作。
怀疑 VSCode 由于某种原因没有加载我的配置文件,我尝试将以下内容添加到我的任务中,但导致了错误/bin/zsh: can't open input file: nvm use && yarn dev The terminal process "zsh '-l', 'nvm use && yarn dev'" terminated with exit code: 127.。
The terminal process "zsh '-c', 'nvm use && yarn dev'" terminated with exit code: 127.
Terminal will be reused by tasks, press any key to close it.
Run Code Online (Sandbox Code Playgroud)
// in dev task
"options": {
"shell": {
"executable": "zsh",
"args": ["-l"]
}
},
Run Code Online (Sandbox Code Playgroud)
Vik*_*ant 26
这对我有用*:
"terminal.integrated.profiles.osx": {
"zsh": {
"path": "/bin/zsh",
"args": ["-l", "-i"]
}
},
Run Code Online (Sandbox Code Playgroud)
* (添加到您的settings.json)
github.com/microsoft/vscode/issues/143061
更新 - 对于默认 shell,提供以下设置 -
"terminal.integrated.defaultProfile.osx": "zsh"
Run Code Online (Sandbox Code Playgroud)
You may need to add an automation profile as well
"terminal.integrated.profiles.osx": {
"zsh": {
"path": "/bin/zsh -l",
"args": ["-l"]
}
},
"terminal.integrated.automationProfile.osx": {
"path": "/bin/zsh"
}
Run Code Online (Sandbox Code Playgroud)
尝试echo $SHELL从 VSCode 的集成终端运行。如果您使用的是 Mac 或 Linux 计算机,则可以将该输出与终端应用程序(VSCode 外部)的输出进行比较。VSCode 中的默认 shell 可能设置不正确,或者在其他位置使用了 zsh 的副本。如果是这样,请通过命令选项板 ( Terminal: Select Default Shell) 设置 VSCode 的默认 shell。
另外,从命令面板中检查 shell 的默认配置文件 ( Terminal: Select Default Profile),并确保将其设置为zsh -l... 使用-c参数(非登录非交互式)将阻止~/.zshrc执行,考虑到错误输出,这听起来像是这里发生的情况。
最后,确认您的配置文件位置正确(位于~/.zshrc)并且 nvm 和yarnPATH均已导出。或者,如果您尝试在本地引用纱线(如果由于某种原因您只在本地安装了它),则需要通过 npx 运行纱线...
| 归档时间: |
|
| 查看次数: |
14434 次 |
| 最近记录: |