简体   繁体   English

在Windows 10上运行VSCode任务时无法加载.bash_profile或.bashrc

[英]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.

相关问题 运行“ Cygwin.bat”和仅运行“ bash”时的区别(.bash_profile与.bashrc) - Difference when running 'Cygwin.bat' and if just running 'bash' (.bash_profile vs. .bashrc) 使Windows Git Bash终端查找.bashrc和.bash_profile的自定义位置 - Make Windows Git Bash terminal look to a custom location for .bashrc & .bash_profile Plink不会在连接时提供bashrc或bash_profile - Plink does not source bashrc or bash_profile on connect Windows 10 中“Bash on Ubuntu on Windows”的 .bashrc 位置 - Location of .bashrc for "Bash on Ubuntu on Windows" in Windows 10 还有哪些其他可能的来源 Git Bash 可能来自 ~/.bashrc 和 ~/.bash_profile - What are some other possible sources Git Bash could be pulling from other than ~/.bashrc and ~/.bash_profile 保持SSH在Windows 10 Bash上运行 - Keep SSH running on Windows 10 Bash Genymotion 无法在 Windows 10 上加载 VirtualBox 引擎 - Genymotion unable to load VirtualBox engine on Windows 10 无法让RabbitMQ在Windows 10上运行 - Unable to get RabbitMQ running on Windows 10 在 Windows 10 上的 VSCode 中测试 GLUT 时收到错误消息 - Receiving error message when testing GLUT in VSCode on Windows 10 在 Windows 10 上运行时出现 Blazegraph 错误 - Blazegraph error when running on Windows 10
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM