Reputation: 1602
I am using VSCode
version 1.31.0
on Windows 10 Home. 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
For example in .bashrc
:
export PATH="/custom/path:$PATH"
When running integrated shell (CTRL + `
), everything works fine, as I can see the $PATH
includes /custom/path
But when I try to run a task scripts (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
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.
I have even tried something like in test.sh, but still it doesn't load my .bashrc
source /home/user/.bashrc
echo $PATH
Below is my VSCode user settings:
{
"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
?
Upvotes: 1
Views: 4478
Reputation: 1602
It is because of the following lines in my .bashrc
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac#
So after I have updated my VSCode settings like below:
{
"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
Upvotes: 1