Starting bash from start menu doesn't process .profile
Bash launched from the start menu will not process the .profile file. This seems to be because bash is not being launched as a login shell, so it doesn't read the .profile.
I would expect bash launched from the start menu to start up a login shell (bash -l)
To start bash as a login shell use "bash.exe -l". You can also start in your home directory by using "bash.exe ~ -l"
Just curious, is it seen as intentional behavior that the default shortcut doesn't start a login shell? I would expect that it would start one.
The shortcut is "bash.exe ~" so it does not start a login shell by default. I agree it probably makes sense as for at least the shortcut to launch a login shell. I'll check with the rest of the team today and see what they think.
Just heard back from the team and non-login shell is going to be the default for the anniversary update. If you'd like to launch bash as a login shell I'd suggest modifying the "Target" of the C:\Users\<username>\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Bash on Ubuntu on Windows.lnk shortcut to read C:\Windows\System32\bash.exe ~ -l
Would y'all consider changing this in a future release? Worth creating a UserVoice entry? I feel like it's something that has come up periodically as a point of confusion.
non-login shell is going to be the default for the anniversary update :tada:
I've changed the .lnk as suggested, and happy with the change :smile:
@pplu I'm glad that works for you.
@aseering It's absolutely something we will consider changing in the future. A UsreVoice entry would not be a bad idea. I will also file a work item internally to revisit this.
Ok, I've created a UserVoice post here:
https://wpdev.uservoice.com/forums/266908-command-prompt-console-bash-on-ubuntu-on-windo/suggestions/14825565-open-bash-as-a-login-shell-by-default
The user voice entry is marked as "CLOSED - VS MERGE LEGACY (DO NOT USE)". Is this still an open item? .profile is the proper place to put PATH settings that you want to apply across multiple shells. Yes, I can use .bashrc but bash is not the only shell that I or others may want to use. That WSL never sources this when launching it in the default manner is a subtle yet serious problem. For example, the entry in the default .profile that adds ~/bin to your path does not take effect when launching bash.exe from the start menu entry (which is all I ever do: WINKEY-b-a-s-h-enter).
Even with the available workaround, this is confusing to any new users who are just getting started. In my case, I just wasted a couple hours trying to chase down why the PATH settings in .profile were not working. This is where the official installation instructions for golang tell you to place the command to add /usr/local/go/bin to your PATH. This type of native-Linux/WSL inconsistency is exactly the kind of problem I would think you wouldn't want developers dealing with.
IMHO this is a significant pain point that will keep cropping up until fixed.
the workaround doesnt work for me as the lnk file doesnt appear in my C:\Users<username>\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Bash on Ubuntu on Windows.lnk
Also, creating a new lnk file doesnt solve the issue for me :(
Please use wsl.exe or the distro-specific executables - here are the docs