[英]Unable to load .bash_profile or .bashrc when running VSCode tasks on windows 10
I am using VSCode
version 1.31.0
on Windows 10 Home. 我使用
VSCode
版本1.31.0
在Windows 10家。 I have enabled WSL, and installed couple of things like nvm, pyenv, and etc. which requires additional scripts needed to run on .bashrc
and .bash_profile
我启用了WSL,并安装了nvm,pyenv等类似的东西,这需要在
.bashrc
和.bash_profile
上运行所需的其他脚本
For example in .bashrc
: 例如在
.bashrc
:
export PATH="/custom/path:$PATH"
When running integrated shell ( CTRL + `
), everything works fine, as I can see the $PATH
includes /custom/path
当运行集成外壳程序(
CTRL + `
)时,一切正常,因为我可以看到$PATH
包含/custom/path
But when I try to run a task scripts ( https://code.visualstudio.com/docs/editor/tasks#vscode ) 但是当我尝试运行任务脚本时( https://code.visualstudio.com/docs/editor/tasks#vscode )
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"type": "eslint",
"problemMatcher": [
"$eslint-stylish"
]
},
{
"label": "Run tests",
"type": "shell",
"command": "./scripts/test.sh",
"presentation": {
"reveal": "always",
"panel": "new"
}
}
]
}
The contents in test.sh test.sh中的内容
echo $PATH
When I try to run the task "Run tests", it doesn't show /custom/path
, or in fact, whatever inside ~/.bashrc
and ~/.bash_profile
are not included. 当我尝试运行“运行测试”任务时,它没有显示
/custom/path
,或者实际上,不包含~/.bashrc
和~/.bash_profile
中的任何内容。
I have even tried something like in test.sh, but still it doesn't load my .bashrc
我什至在test.sh中尝试过类似的方法,但仍然无法加载我的
.bashrc
source /home/user/.bashrc
echo $PATH
Below is my VSCode user settings: 以下是我的VSCode用户设置:
{
"terminal.external.windowsExec": "C:\\windows\\Sysnative\\bash.exe",
"terminal.integrated.shell.windows": "C:\\windows\\Sysnative\\bash.exe",
"terminal.integrated.shellArgs.windows": ["--login"],
"eslint.provideLintTask": true
}
The question is: 问题是:
How can I setup VSCode or windows to run tasks using my .bashrc
or .bash_profile
? 如何设置VSCode或Windows以使用
.bashrc
或.bash_profile
运行任务?
It is because of the following lines in my .bashrc
这是因为我的
.bashrc
中有以下几行
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac#
So after I have updated my VSCode settings like below: 因此,在更新我的VSCode设置后,如下所示:
{
"terminal.external.windowsExec": "C:\\windows\\Sysnative\\bash.exe",
"terminal.integrated.shell.windows": "C:\\windows\\Sysnative\\bash.exe",
"terminal.integrated.shellArgs.windows": ["-i"],
"eslint.provideLintTask": true
}
The remaining commands in my .bashrc
will be executed .bashrc
的其余命令将被执行
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.