-
Notifications
You must be signed in to change notification settings - Fork 826
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add "Run as login shell" option for Bash. #816
Comments
Closing this out because there is a way to run as a login shell (via passing -l or --login to bash.exe) |
@benhillis -- The issue as I see it here is that the shortcut to open a shell on Windows does not provide a shell whose environment is comparable to the shortcut to open a shell on Ubuntu. That appears to meet your own criteria for a bug -- it's a point of incompatibility that has resulted in a number of tickets filed by users who don't understand their shell's behavior. It's true that there's a workaround, but the workaround isn't a fix... I'd really like to see this ticket either re-opened, or closed as a dupe with a reference to some other ticket that's tracking the work. |
@aseering - agreed, reopening. |
ping -- any updates on this? |
@aseering I'll check with the team on their thoughts about adding --login to the default shortcut. |
Thanks @benhillis ! For what it's worth, I understand the argument that this is kind of a hack as compared to re-thinking |
ping -- someone else hit this :-) |
Unfortunately I couldn't get quorum to add this for Creators Update. User's that want a login shell will have to manually modify their shortcut or use bash.exe -l |
Thanks @benhillis for the update. This underlying issue has been around since before freeze for the Anniversary Update (though this particular ticket was filed right after it shipped). Given that this is the sort of change that only becomes harder to make over time, and given that it has missed two releases already, can we take this to mean that you don't plan to implement this change? |
I would say that since there is such a simple workaround the team feels this is a documentation issue rather than a code defect. I've reached out to @jackchammons to make sure we have a blurb about running bash as a login shell. |
Ok -- I mean, there are lots of things with simple workarounds that y'all have chosen to fix. You appear to be confirming that:
Please let me know if that's inaccurate. |
We have not yet made that determination. I think the greater problem is that to truly match Ubuntu's behavior we should switch over to using /bin/login. That would solve this as well as a number of other issues but it does come with some interesting baggage which is why we have not yet done it. |
Your point about
Anyway -- thanks for bringing this up with the WSL team, and for the feedback about y'all's thought process. I appreciate knowing what's going on. Also, thanks for all the fixes that you have gotten in :-) |
I don't think it is sufficient to add -l to the default shortcut, because I think most users still expect their .profile to be applied even if they run 'bash' from the command line rather than clicking on the shortcut. There is also the issue of 'bash -c xyz' not applying the .profile (see #1404), which is the correct behaviour on Linux, but this makes sense on Linux because the .profile would have already been applied before the user ever has a chance to run 'bash -c'. The /bin/login solution fixes both these issues. Maybe an alternative solution would be to allow the passing of specific environment variables from Windows into WSL (see #219), thus eliminating the need for .profile? If this were possible, commands which we would normally put in .profile could be run at Windows logon instead. However, this would require additional configuration to fix issues such as the OP's, and it would not be ideal for people who use the same dotfiles on all machines. |
--login is the fist step for sure but making it with /bin/login would definitely be nice. I wouldn't like to see WSL not conforming to .profile. But it would be neat to see the windows environment variables injected in as a completely separate [optional-but-defaults-to-enabled] feature. (Probably with Win>Linux path fixup i.e. C:\ -> /mnt/c/). Just like the Path is. Hell then I could even make my own path with PATH="$PATH:$Path" if I wanted. Maybe they could be injected with a prefix like $WIN_Path? |
As of build 16188 when running bash.exe without arguments (or with the ~ argument) bash will be launched as a login shell. The same is true for the new wsl.exe binary (with the exception that wsl launches your user's default shell as a login shell). |
Awesome! Thanks @benhillis. Looking forward to trying it out! |
Thank you so much for this change @benhillis! It really helps. That said, the approach of only launching bash as a login shell if there are no parameters given causes several scenarios to remain unfixed (particularly #1404 which is concerningly now marked "bydesign"). Why not just always run bash as a login shell if it's launched from bash.exe? Are there still future changes planned with regard to this behaviour? |
Seems to me that this is fixed in Fall Creator's Update as expected |
On a new install of Windows w/ all updates applied, opening Ubuntu still does not source
It appears that creating an executable bash script in |
@thesmart, I think this is due to |
I've installed and managed to make rvm, ruby and rails work. But after close Bash and open another instance, I can't get ruby or rails worked. I get this error when try to call ruby:
Workaround here is to add
bash --login
every time open a new Bash, while Ubuntu's terminal has an toggle "run as login shell" in its option.The text was updated successfully, but these errors were encountered: