-
Notifications
You must be signed in to change notification settings - Fork 801
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
.bashrc file didn't load when start bash in windows #2067
Comments
@yhvicey -
Option |
@sunjoong After installation there is no short cut in start menu so I created one manually: After adding "-l" to target I tried again but still doesn't work. I guess it has nothing to do with shortcut because there's same issue if I start %WINDIR%\System32\Bash.exe directly. And this problem seems to appear in recent insider builds. Or, I have changed the color of the bash console. Does it matters? |
@yhvicey - Something's wrong!!
I meant |
|
@yhvicey - This is not a solution becasue that not reading ~/.bashrc file issue might not removed, but... you said runnig /bin/bash manually worked, so... it might be an emegency trick, I think. Try
|
@sunjoong It works, thanks for your workaround. |
Before than 16184, bash's argv[0] is '/bin/bash'. This is non-login shell. Bash will only loads .bashrc. |
@0xbadfca11 - Thanks for notice; that's very important news.
You might find simular thing in ~/.profile but you have ~/.bash_profile, so check that file. |
@0xbadfca11 Thank you very much. I have created a .bash_profile file to disable bell before. |
@sunjoong , I was having the same problem. Your code solved mine. |
@sunjoong Your answer is perfect! It fixed it for me. |
@sunjoong It works for me. Thanks! |
@sunjoong Thank you for your answer! |
Posting it because it may help someone. For me, all the solutions above didn't work. After starting WSL, when ssh-agent was asking for a password, I always pressed Ctrl+C to skip it. When I entered (remembered) it, the ./bashrc was loaded correctly. It seems like I was breaking the loading process of ./bashrc |
This worked for me:
|
This problem is more difficult to solve for WSL installations installed from the Microsoft Store (Windows App Store). Finding the directory for the shortcut that launches the To work around this: run the Linux command line you installed,
Right click on the And as you can see, the "link" is unfortunately not a link, but a |
Man This works perfectly. //i just added this in both of them (Thinking whichever works and it did. #admit not the best pro work but it works.) |
I've found that in my system only if [[ -f ~/.profile ]] ; then
. ~/.profile
fi Now it works |
I confirm that this works. |
This comment is 3 years old but solved an issue I had today. I recently setup a new system with Windows 10, WSL 2, Ubuntu, Windows Terminal, Node, Python, Visual Studio Code, all the latest greatest. Things worked fine until this morning after an automated restart by Windows update. The terminal lost its color and none of the packages I installed (e.g. |
Thank you so much, I spent hours on finding a solution and this finally worked. |
I had this same issue. It turns out that the problem is a faulty /etc/bash.bashrc. It doesn't call ~/.bashrc. I added the following to my /etc/bash.bashrc and all is well. if [ -f "$HOME/.bashrc" ] |
@stevenrbrandt : Yes, it solves the issue when running with Windows Terminal + WSL Ubuntu. |
Thanks for @sunjoong 's answer. It works very well. But I think it still doesn't solve the problem directly. Here is the output of Probably, because I'm an obsessive person it still bothers me 😅. I hope to find or see some answer to fix this. |
@baranaldemir yes, I tried all those things before I came up with my fix. I've since switched to MobaXterm. Everything seems to just work better there, though I didn't check specifically for this issue. |
Had the same issue, but only when using a instance I manually created the user for. I found the ...
exec bash
# if running bash
if [ -n "$BASH_VERSION" ]; then
# include .bashrc if it exists
if [ -f "$HOME/.bashrc" ]; then
. "$HOME/.bashrc"
fi
fi
... EDIT: it also starts with the following command: wsl -e bash |
First, I entered WSL but it looks abnormally - no color and alias:
And if I enter bash again everything goes to work normally:
So what's wrong with my WSL? How to recover it? Thanks.
The text was updated successfully, but these errors were encountered: