-
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
bash not picking up /etc/environment #1405
Comments
Thanks @stringhaml for posting! I believe this is conceptually the same issue as #816 ; it probably shares the same workaround. WSL team, any further thoughts on that issue? I feel like I recall a bunch of discussion about it somewhere on one of these tickets prior to the Anniversary release, but I haven't heard much since. |
@stringhaml Upgrading to a newer release of Windows via the insider program and using the workaround from #816 should fix this issue. Let us know if that works for you. |
How can you upgrade to a newer release? |
@johnnyodonnell - supposedly you can download Creator's Update today via the media creation tool, but it "officially" releases on 4/11. |
This is still a problem with 1703 unfortunately. Running Right now there seems to be no way to set an environment variable that is used in all contexts? I tested this with WSL and Ubuntu Server 16.04. I was expecting WSL to behave just like Ubuntu in this case. I added
WSL 16170 (1703/Creators Update):
Ubuntu 16.04:
Using I also use HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Lxss AppendNtPath 0, since I was hoping that would help. I could see this happening to not have Somewhat related: #816 |
It's been over a year and there still isn't a way to properly load the environment in Ubuntu? This is basic stuff. Are there any updates on how to source /etc/environment as it would in any standard Ubuntu install? |
Still not working on 1709 (16299.248). |
This got marked as a dupe of #816 a long time ago, but that issue was hence marked fixinsiderbuilds. I think it was marked as such because quoth:
|
Is there any progress on getting WSL to pick up /etc/environment under Ubuntu? If not what is the best work around? |
Still present in 1809. One workaround right now is to use |
I just tried it on build 18975 and WSL 2 (Ubuntu 18.04 LTS image) - |
After |
Tested in build 19041.21, not working. Tried to run |
Perfect work around for me: using WSLENV |
WSL 10.0, Ubuntu 16.04 - |
Try to rewrite |
Windows 10 Linux Subsystem /etc/environment still not picked up by fresh run in Win10 2004 by wsl2 + Ubuntu. |
Confirm this is an issue in Win10 2004 + Ubuntu 18.04. It's quite problematic for environment setup for non-interactive shells - for example PyCharm's WSL integration users the launcher exe which won't pick-up /etc/profile.d scripts - and /etc/bash.bashrc (above the interactive check) doesn't work. It seems there is no way of having an env var set without interactively logging in. |
Confirmed also on Win10 2004 + Ubuntu 20.04, WSL2 Is there a way to pass the --login option to a WSL instance started from Windows Terminal? edit: nevermind, |
PIPENV_VENV_IN_PROJECT の設定は性質的には /etc/environment に 記述したほうが良さそうだけど、WSLには /etc/environment が読み込めない バグがあるっぽい。 microsoft/WSL#1405 しかたないので /etc/profile.d に設定することにした。
Confirmed on Win10 20H2, Ubuntu 20.04, WSL2. Still not working. |
Still an issue using Windows 11 Home 21H2 build 22000.132 and Ubuntu 20.04 running on WSL |
I am not sure. I think this issue related to the systemd. If I boot the WSL via genie, the pam_env can be loaded. (PS: because the genie create a login shell so the issue may not related to the systemd. A login shell is the important point) |
@jackchammons @therealkenc It's been 6 years since this was opened, 4+ years since de-duped from #816 . 3 years since linked to #4232, and since then no maintainers from MS have commented or provided update on these two critical bugs. Are these things on any internal roadmap or associated with any project plan to be done in the next year? Or better yet, could you comment as to whether or not anyone is actively working on them? |
Let's hope Poettering cleans up this mess now that he's with Microsoft 😜 @8ar10der, I don't think it has anything to do with login shells. |
Related: linux-pam/linux-pam#481 Interesting finding: Does anybody know what tool WSL uses to perform the login? Maybe what is missing is a dedicated config in I found a way to get into the WSL distribution from PowerShell that uses
Found this by googling here: https://uzxmx.github.io/wsl-tricks.html |
Any update on this? I still have this problem using Windows 11 build 22621.1702.
This works for me, but then every time I open VS Code within WSL, it opens from Windows' file system instead of WSL's I ended up using WSLENV to set my environment variables. I added something like this to my Powershell $env:MYENV = "some-value"
$env:WSLENV = "${env:WSLENV}::MYENV" And then setting my windows terminal profile: {
"name": "Ubuntu",
- "source": "CanonicalGroupLimited.Ubuntu_79rhkp1fndgsc",
+ "commandline": "pwsh.exe --command \"wsl --cd ~\"",
}, Or executing directly from powershell: ubuntu This works, but I don't feel like this should be the way to do it. |
any update? |
7 years now... |
I have just found my way here after spending an incredible amount of time trying to do what seems to be the most simple thing: set an env var globally inside of a distro or across all distros. ChatGPT thought it was possible to assign them in an Although this present issue is about bash specifically, for many use cases it would be helpful to have this not be shell-dependent. In my own case as a PowerShell-first user, the bash profile workarounds are not that helpful, and what should we do, define these things differently for every different shell type? In a corporate environment like mine we want to have a pre-configured distro with things like SSL config vars set up correctly, so that things work right out of the box without every dev having to configure their profiles. The WSLENV workaround is about the only one that makes sense in that context, but is ugly as it means pushing profile changes to Windows desktops rather than just tailoring our WSL distro. The config sections suggested by ChatGPT would be dead simple to implement surely, and gets around any messing about with PAM etc. Can we have something like that, please please please??? |
To celebrate 🎂 the 7 years anniversary of this issue in 10 days, I present you my workaround, based on @smaktacular 's one, that combines At the end of your
Done - It took me a bit more than 7 minutes, it will take you a bit more than 7 seconds. Happy 7 years anniversary! 🥳 🎆 🎈 PS:> Make sure you have a newline at the end of |
7.5 years and ticking This bug breaks
A simple fix is to add |
Workaround
|
@dzciemix it worked! |
Happy 8 years anniversary 🎂! Still breaks installations and scripts that assume /etc/environment is working, creating support overhead. |
When setting up http_proxy="http://my.proxyserver.example.com" and other such environment variables in /etc/environment they are not exported when opening a new bash session.
for example:
user@mycomputer:~$ cat /etc/environment
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"
ftp_proxy="http://my.proxyserver.example.com:1234"
http_proxy="http://my.proxyserver.example.com:1234"
https_proxy="http://my.proxyserver.example.com:1234"
no_proxy=example.com,*.example.com,10.0.0.0/8,192.168.0.0/16,127.0.0.0/8,localhost"
socks_proxy="http://my.proxyserver.example.com:1235"
exit bash, re-open, and do a printenv they are not listed.
The text was updated successfully, but these errors were encountered: