WSL icon indicating copy to clipboard operation
WSL copied to clipboard

Starting bash from start menu doesn't process .profile

Open pplu opened this issue 10 years ago • 11 comments

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)

pplu avatar Jun 14 '16 12:06 pplu

To start bash as a login shell use "bash.exe -l". You can also start in your home directory by using "bash.exe ~ -l"

benhillis avatar Jun 14 '16 14:06 benhillis

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.

aseering avatar Jun 14 '16 14:06 aseering

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.

benhillis avatar Jun 14 '16 14:06 benhillis

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

benhillis avatar Jun 14 '16 15:06 benhillis

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.

aseering avatar Jun 15 '16 00:06 aseering

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 avatar Jun 15 '16 07:06 pplu

@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.

benhillis avatar Jun 15 '16 15:06 benhillis

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

aseering avatar Jun 15 '16 23:06 aseering

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.

evancox10 avatar Apr 30 '17 22:04 evancox10

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 :(

joadr avatar Sep 21 '17 03:09 joadr

Please use wsl.exe or the distro-specific executables - here are the docs

tara-raj avatar May 22 '18 21:05 tara-raj