TL;DR:
Following Exercism’s CLI installation instructions created ~/.bash_profile that overrode my ~/.profile, changing the behavior of subsequent bash sessions.
Hello!
I’m on Windows 11 using Windows Subsystem for Linux to run (a fresh install of) Ubuntu-24.04. The only other thing I’d installed before Exorcism’s CLI was Ruby (…and Mise, à la the rubyonrails.org installation guide).
I followed the Linux path at the cli walkthrough so I could start working on exercises locally. As I did so,
[[ ":$PATH:" == *":$HOME/bin:"* || ":$PATH:" == *":~/bin:"* ]] && echo "~/bin is in PATH" || echo "~/bin is not in PATH"
produced “~/bin is not in the PATH”. After investigation, I think this ended up causing issues, as I then ran the next commands according to the guide, which:
–>created a ~/.bash_profile that did not exist before…
–>which made it so my ~/.profile was no longer looked at…
–>which made it so my ~/.bashrc was no longer looked at…
–>and ~/.bashrc is where my mise and ruby bash commands are initialized.
So basically, following the walkthrough seemed to break* my Ruby install by way of creating ~/.bash_profile when I shouldn’t have. (*yes, it really just broke the process that added the commands to my $PATH).
Explanation (I think):
I am not anywhere close to a Linux or Bash expert, but I have a suspicion of what’s going on here.
I did not initially have a ~/bin directory, so my running mkdir -p ~/bin according to the guide did indeed make it for me.
I see that my ~/.profile script includes
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
PATH="$HOME/bin:$PATH"
fi
So that is what normally adds ~/bin to my PATH (…if it exists)! So why’d the check tell me it wasn’t there? According to the man pages, bash only auto-runs ~/.profile upon invocation of the shell.
Therefore, creating ~/bin and then immediately checking to see if it’s included in $PATH was the error of my ways (and, as it relates to my particular default setup, the error of the walkthrough’s ways). While it was not in my $PATH at that moment, a mechanism existed to where it would be added for all subsequent bash sessions. Therefore I did not need to run, and indeed should not have run:
echo 'export PATH=~/bin:$PATH' >> ~/.bash_profile
source ~/.bash_profile
That significantly* altered my bash setup–causing anything that I’d previously installed that used ~/.profile (and, subsequently, anything that used ~/.bashrc because there is code in ~/.profile to run ~/.bashrc) to no longer work as expected. (*not actually that significant… After figuring all this out, the simple, single-action fix was to just rm the ~/.bash_profile that I’d created.)
In hindsight, what I should’ve done:
After creating ~/bin, I needed to run source ~/.profile, or restart my bash session, before checking my $PATH.
Does this suggest an update to the CLI Walkthrough?
I don’t know, but I thought I’d raise the question.
I don’t know enough about Linux and bash to know why one’s system would be using ~/.bash_profile vs. ~/.profile. Or if my system’s way of adding ~/bin to the $PATH is uncommon. Or if WSL’s Ubuntu 24.04 is somehow different than non-WSL. Or really anything else (I don’t know what I don’t know). And I suspect that my exact solution would not work universally.
What I do know is that this was my experience:
- I installed Ruby on Rails, following the rubyonrails.org guide exactly, including a fresh/default install of Ubuntu.
- This seemed to be a success, and using
rubyon the command line was working. - I installed Exercism’s CLI, following the installation walkthrough exactly.
- This seemed to be a success and using
excersimon the command line was working. (and see additional thought below!) - I soon found that using
rubyandmiseon the command line were no longer working (and I actually initially second-guessed myself as to whether or not I’d installed Ruby at all! Thought maybe I’d dreamt it
)
And it seems plausible to me that others will have a similar experience. But I acknowledge that the “takeaway” to my whole episode here could just be something like, “lolz welcome to Linux–you must be new here!” I admit that I learned a decent bit that I’d guess are basics for “Linux people”.
Another thought after writing all ^that^
Thinking more about it, I probably didn’t run into ruby and mise commands not working until I was using a different bash session than the one I used to install Exercism CLI. When I started that session, ~/.profile ran and so ruby and mise were added to $PATH. Then I created ~/.bash_profile containing the command to add ~/bin to $PATH and sourced it-- so ~/bin was now also in $PATH.
Therefore, I suspect that immediately after installing Exercism CLI, everything would’ve been working as expected! But all subsequent bash sessions would be as I described above. Such latency could make this relatively minor issue maddening since it potentially leaves a user thinking “This was all working perfectly yesterday! I’ve done nothing since then! WHAT’S HAPPENING?!” (…but what they’ve “done” is closed their terminal and opened a new one)