You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
Reacted by Carl Patenaude-Poulin, Ashley Tolen, Lucas Theisen and Caleb Collins-Parks
Another option is to add --login to the shotcut used to launch bash.
Reacted by Carl Patenaude-Poulin, Ben Hillis, Julio César Rocha, Nicholas La Roux, Cody Swartz, Manuel Torre, Samuel, Ruben Solorio, Ashley Tolen, M J Khan and 1 more
Ben Hillis (@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.
Reacted by Evan Cox, Ron Pinz, Cody Briscoe Horton, sorincezar and Cristiano Gavião
Thanks Ben Hillis (@benhillis) ! For what it's worth, I understand the argument that this is kind of a hack as compared to re-thinking init, or even /bin/login. My question is, as WSL picks up users, will it be easier to transition people from a default minimal shell to a default proper login shell, or from a default --login shell to a proper login shell?
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 Ben Hillis (@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 Jack Hammons (@jackchammons) to make sure we have a blurb about running bash as a login shell.
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 /bin/login is a good one. However, what WSL should really do if the objective is to maximize compatibility is to have Ubuntu's /bin/init (or an appropriate one of its many children) fork a login shell. That would solve a whole lot of problems, including this one and including many that /bin/login would not solve. It would also drag quite a large pile of baggage along with it :-)
/bin/login is not a complete solution, but it would be a substantial improvement. /bin/bash --login is also not a complete solution; it would also be an improvement, and a step towards /bin/login. Either way, I hope y'all choose to do something incremental -- it would be wonderful to have all the various system-environment-related details working properly, but I for one will get grumpy if I have to wait until then just to have stock WSL run my dotfiles :-)
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).
Reacted by Doodad/Doodead, Riley Labrecque, Shawn Zivontsis, Nguyen Thanh Dat B, Mike Branski, Martin Hochel and Samuel
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?
John Smart (@thesmart), I think this is due to /bin/login not being used by WSL for logging in. /etc/environment is parsed by Linux-PAM and the default config depends on /bin/login.
Activity
xob commentedon Aug 8, 2016
Another option is to add

--loginto the shotcut used to launch bash.benhillis commentedon Dec 1, 2016
Closing this out because there is a way to run as a login shell (via passing -l or --login to bash.exe)
aseering commentedon Dec 1, 2016
Ben Hillis (@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.
benhillis commentedon Dec 1, 2016
Adam Seering (@aseering) - agreed, reopening.
aseering commentedon Jan 31, 2017
ping -- any updates on this?
benhillis commentedon Jan 31, 2017
Adam Seering (@aseering) I'll check with the team on their thoughts about adding --login to the default shortcut.
aseering commentedon Feb 1, 2017
Thanks Ben Hillis (@benhillis) ! For what it's worth, I understand the argument that this is kind of a hack as compared to re-thinking
init, or even/bin/login. My question is, as WSL picks up users, will it be easier to transition people from a default minimal shell to a default proper login shell, or from a default--loginshell to a proper login shell?aseering commentedon Feb 9, 2017
ping -- someone else hit this :-)
benhillis commentedon Feb 9, 2017
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
aseering commentedon Feb 9, 2017
Thanks Ben Hillis (@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?
benhillis commentedon Feb 9, 2017
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 Jack Hammons (@jackchammons) to make sure we have a blurb about running bash as a login shell.
aseering commentedon Feb 9, 2017
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.
benhillis commentedon Feb 9, 2017
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.
aseering commentedon Feb 9, 2017
Your point about
/bin/loginis a good one. However, what WSL should really do if the objective is to maximize compatibility is to have Ubuntu's/bin/init(or an appropriate one of its many children) fork a login shell. That would solve a whole lot of problems, including this one and including many that/bin/loginwould not solve. It would also drag quite a large pile of baggage along with it :-)/bin/loginis not a complete solution, but it would be a substantial improvement./bin/bash --loginis also not a complete solution; it would also be an improvement, and a step towards/bin/login. Either way, I hope y'all choose to do something incremental -- it would be wonderful to have all the various system-environment-related details working properly, but I for one will get grumpy if I have to wait until then just to have stock WSL run my dotfiles :-)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 :-)
shawnz commentedon Feb 14, 2017
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.
rlabrecque commentedon Apr 18, 2017
--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?
benhillis commentedon May 13, 2017
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).
rlabrecque commentedon May 13, 2017
Awesome! Thanks Ben Hillis (@benhillis). Looking forward to trying it out!
shawnz commentedon May 13, 2017
Thank you so much for this change Ben Hillis (@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?
mungojam commentedon Oct 15, 2017
Seems to me that this is fixed in Fall Creator's Update as expected
thesmart commentedon Dec 7, 2017
On a new install of Windows w/ all updates applied, opening Ubuntu still does not source
/etc/environment:It appears that creating an executable bash script in
/etc/profile.d/*will get loaded upon process restart. This doesn't seem to work withsudo.therealkenc commentedon Mar 1, 2018
This was marked fixedinsiderbuilds as of 16188 (message) implying 16299 FCU. New landing zone for
/etc/environmentbehaviour is #1405.trallnag commentedon Jul 31, 2022
John Smart (@thesmart), I think this is due to
/bin/loginnot being used by WSL for logging in./etc/environmentis parsed by Linux-PAM and the default config depends on/bin/login.