问题描述
当我使用VSCode集成终端通过远程SSH登录Linux远程工作站时,/etc/profile.d/*
中的shell脚本不会被执行。其他一些脚本(如 ~/.bash_profile
)也可能会被忽略。
例如,如果我有一个导出某些 /etc/profile.d/cuda.sh
的 PATH
文件,那么 PATH
环境变量将在普通 SSH 中进行相应修改,但在 VSCode 终端中不会。
解决方法
由于 VSCode 终端的行为与 SSH 登录不同,您应该在远程 SSH 配置 (File > Preferences > Settings > Remote
) 中添加以下内容:
"terminal.integrated.shellArgs.linux": [
"--login","-i"
],
如果您的工作站是 Windows,您可以参考this question。