Search code examples
bashvisual-studio-codeterminalwindows-subsystem-for-linux

WSL bash in Visual Studio Code running .bashrc but not .bash_profile


Until recently, when I've launched the integrated terminal in Visual Studio Code, bash runs both my .bashrc and my .bash_profile files. But now it's only running the .bashrc file. I need it to run both.

Some details: VSC 1.70.1 (latest), with the "Remote - SSH" extension, running under Windows 10 (updated) with WSL 2 installed. When I launch a Microsoft terminal, it runs both .bashrc and .bash_profile, but VSC's integrated terminal only runs the former. This probably means I have s.t. wrong in my VSC config, but the settings there seem to change frequently and it's hard to keep up. The relevant parts seem to be

"terminal.integrated.defaultProfile.windows": "WSL",
"terminal.integrated.profiles.windows": {
    "bash":{
           "path": "C:\\Windows\\System32\\bash.exe",
           "args": ["-l"]
    },
    "WSL": {
           "path": "C:\\WINDOWS\\System32\\wsl.exe",
           "args": [ ],
           "icon": "terminal-ubuntu"
    }
},

but that doesn't work, nor do any of the variants I've tried on the two "args" parameters, nor changing the defaultProfile to "bash" instead of "WSL".

Before I give in and put all my startup settings in my .bashrc file and get rid of my .bash_profile file, what do I yet lack?


Solution

  • I can't reproduce this after even after upgrading to 1.70.1, so I'd recommend trying out these things:

    • try

       "path": "C:\\WINDOWS\\System32\\wsl.exe",
       "args": ["-e", "bash", "-li"]
      

      to make sure that a login shell is started

    • if this changed after upgrading, read Help -> Release Notes to find out what might be responsible, e.g. the Shell integration is now enabled by default, so you might try "terminal.integrated.shellIntegration.enabled": false

    • sync / backup your settings, re-install vanilla VSC, check if behaviour is still the same