VScode集成终端在初始化过程中突然出现错误。

huangapple go评论53阅读模式
英文:

VScode integrated terminal suddenly throws an error during initialization

问题

在Ubuntu 22.10上,我使用最新的VScode,在集成终端中打开ZSH和BASH shell时遇到以下问题。标准的Ubuntu终端可以正常工作。

在启动ZSH集成终端后:

compdump:138: 找不到命令: mv
/home/user/.oh-my-zsh/oh-my-zsh.sh:56: 找不到命令: mkdir
/home/user/.oh-my-zsh/tools/check_for_upgrade.sh:29: 找不到命令: git
/home/user/.oh-my-zsh/oh-my-zsh.sh:115: 找不到命令: rm
getent:6: 找不到命令: grep
_p9k_init_cacheable:59: 找不到命令: uname
_p9k_init_cacheable:61: 找不到命令: uname

BASH

命令'uname'可在以下位置找到
 * /bin/uname
 * /usr/bin/uname
由于没有将'/bin:/usr/bin'包含在PATH环境变量中,找不到该命令。
uname: 找不到命令

就在几小时之前,它还可以正常工作。然后我尝试设置远程SSH连接到另一台Linux机器(Fedora 36),但遇到了相同类型的错误,我无法通过搜索解决。

在设置中使用@modified关键字,我确保没有发生意外的更改。PATH与完全可操作的标准终端中的相同。

想知道可能出现了什么问题。

更新。

PATH变量:

/usr/local/cuda-11.7/bin:/home/user/.conda/envs/env/bin:$PATH

问题。

与标准终端中的完整PATH扩展不同,在集成终端中,PATH只扩展了一部分(省略了/usr/bin等)。

英文:

I'm using the most recent VScode on Ubuntu 22.10 and experiencing the following issues while opening ZSH and BASH shells in the integrated terminal. The standard Ubuntu terminal works without errors.

After starting a ZSH integrated terminal:

compdump:138: command not found: mv
/home/user/.oh-my-zsh/oh-my-zsh.sh:56: command not found: mkdir
/home/user/.oh-my-zsh/tools/check_for_upgrade.sh:29: command not found: git
/home/user/.oh-my-zsh/oh-my-zsh.sh:115: command not found: rm
getent:6: command not found: grep
_p9k_init_cacheable:59: command not found: uname
_p9k_init_cacheable:61: command not found: uname

BASH

Command 'uname' is available in the following places
 * /bin/uname
 * /usr/bin/uname
The command could not be located because '/bin:/usr/bin' is not included in the PATH environment variable.
uname: command not found

Just several hours before, it worked just fine. Then I tried to set up Remote SSH to another Linux machine (Fedora 36, with the same sort of errors I was also unable to resolve by googling).

Using the @modified keyword in Settings, I ensured that no unexpected changes had been made. The PATH is the same as in the fully operational standard terminal.

Wondering what could be the issue.

UPDATES.

PATH variable:

/usr/local/cuda-11.7/bin:/home/user/.conda/envs/env/bin:$PATH

The problem.

Unlike the complete PATH expansion in the standard terminal, PATH was expanded partially (omitting /usr/bin, etc.) in the integrated terminal.

答案1

得分: 1

基于这个错误,

The command could not be located because '/bin:/usr/bin' is not included in the PATH environment variable.

我建议你运行,

export PATH="/usr/bin:$PATH"

/bin:/usr/bin 添加到你的 PATH

在你的 PATH 中使用 :$PATH 意味着 shell 会将变量 $PATH 添加到你的 PATH 的末尾。

英文:

Based on this error,

The command could not be located because '/bin:/usr/bin' is not included in the PATH environment variable.

I suggest you run,

export PATH="/usr/bin:$PATH"

To add /bin:/usr/bin to your PATH

Having :$PATH in your PATH means that the sheell will add the variable $PATH to the end of your PATH

答案2

得分: 0

问题的原因是用户设置中的以下配置:

terminal.integrated.env.linux": {
    "PYTHONPATH": "/media/user:/media/user/common:$PYTHONPATH",
    "PATH": "/media/user:/media/user/common:$PATH"
}

虽然终端中的PYTHONPATH变量被正确扩展,但PATH仅被部分扩展为问题的"UPDATES"部分中显示的内容。根据@Orion447的答案,寻找PATH可能会受损的潜在位置是可能解决问题的方法之一。

英文:

The cause of the issue the following configuration from the User settings:

terminal.integrated.env.linux": {
    "PYTHONPATH": "/media/user:/media/user/common:$PYTHONPATH",
    "PATH": "/media/user:/media/user/common:$PATH"
}

While the PYTHONPATH variable is expanded properly in the integrated terminal, the PATH is expanded partially to something shown in the UPDATES section of the question. To build on top of the answer by @Orion447, looking for any potential place where PATH could get corrupted is the approach that likely solves the problem.

huangapple
  • 本文由 发表于 2023年2月18日 04:20:38
  • 转载请务必保留本文链接:https://go.coder-hub.com/75488924.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定