I was editing the bashrc script in my Windows 10 Ubuntu Bash and I made a mistake while editing the script. Now bash exits immediately upon opening it. Is there a way for me to open Bash without running bashrc, or will I have to reinstall it?
2 Answers
You should be able to skip loading the default .bashrc
file in WSL in essentially the same way as in "regular" bash:
--norc Do not read and execute the system wide initialization file
/etc/bash.bashrc and the personal initialization file ~/.bashrc
if the shell is interactive. This option is on by default if
the shell is invoked as sh.
So, open the Windows CMD.exe
and type
wsl.exe -e bash --norc
Once you are in the interactive shell you can revert the changes yo made to the ~/.bashrc
file.
-
-
5@jpmc26 - Because in this situation, it doesn't matter, both work and the result is the exact same, but cmd is faster to load and easier to open with purely keyboard commands– TaegostJul 8, 2019 at 15:46
-
1There's no need to open a prompt first at all, you can simply hit the windows key and type "wsl -e bash --norc" followed by enter. Jul 8, 2019 at 19:55
I have more than one distro on my wsl. The faulty one was not the first I installed, so not the default. In order to apply the above solution, we have first to set the faulty distro to be the default, so the invoked bash will be then used.
wsl --set-default --set-default Ubuntu-20.04
So then, the command
wsl.exe -e bash --norc
will invoke the right bash.
.bashrc
from any Windows App such as Notepad++ ?.bashrc
to.bashrc.hold
. Or is that dangerous too?