Hello everyone. My problem is when I close the terminal and re-open it then type the ‘exercism’ command it won’t work but it will work after I source the bash_profile.
So what I want to fix is when I open the terminal, I can type the ‘exercism’ command without typing the “source ~/.bash_profile”. Can someone help me with this?
Are you using bash as your shell? Does echo $SHELL show /bin/bash (or similar)?
The man bash page says,
When bash is invoked as an interactive login shell, or as a non-interactive shell with the --login option, it first reads and executes commands from the file /etc/profile, if that file exists. After reading that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first one that exists and is readable. The --noprofile option may be used when the shell is started to inhibit this behavior.
What does echo $- show? Is there an i (interactive) in there?
That’s pretty … odd. You may want to try logging out and logging back on and seeing that fixes the issue. If not, you may want to check your local man bash and see if it invokes different rc files.
The fact that you have to source your bash_profile means your terminal is not starting a login shell. You could check your terminal’s settings to launch a login shell, or you could move the exercism-specific stuff from ~/.bash_profile to ~/.bashrc
I did what @glennj suggested, I moved the the $PATH to ~/.bashrc since the terminal is starting as a non-login shell, it first reads and execute commands from the ~/.bashrc instead of ~/.bash_profile. Thank you @glennj