I just recently got a new 2023 Macbook pro and after installing and using the Exercism CLI, my zsh shell suddenly doesn’t know where to find the exercism commands.
Running which exercism returns exercism not found
Running exercism submit exercise-name.js returns Zsh: command not found: exercism
Could someone point me in the direction to fixing this?
I followed the cli-walkthrough to do the install using homebrew. I seem to be getting this issue with anything I install, it has happened with Visual Studio Code, tldr and Homebrew itself. They all worked fine after initial install then somewhile later (I expect after a reboot) they no longer work in the terminal. I even had to manually create the ~/.zshrc file and add the export path for Visual Studio code to get the code command to work.
This fixed the issue for Visual Studio code but it seems to be happening for every application I install. I expected this would be something that MacOS does automatically. I can’t even use the brew command now even though I used it to install both the exercism-cli and tldr.
mitch@colossus ~ % brew update zsh: command not found: brew
I’m also not sure on where the exercism executable is, there is the below directory on my computer but this just contains the few exercises that I was able to download while the CLI was working. I can’t see any executables or additional files there when running ls -la
I do not have that operating system available to look at, so I do not
know if updatedb and locate brew or locate exercism would work for
you.
The manual should tell you if they are available. man updatedb or man locate.
If you download the exercism executable from the releases page, and
place the extracted executable to ~/bin/ it should be in a location on
your path.
Another thought might be that your terminal is not using the login
environment. But like I said, I am not well versed on OSX and the way
it is configured.
It seems to me that either something about your shell environment has changed, or you are not actually in the shell you think you are.
Try using env to print out the actual environment variables that are present in the current shell. It’s possible that whatever terminal or shell you are using is not actually loading your ~/.zshrc file.
To fix brew in the short term, you could put the path into $PATH just like you did for VS Code: /opt/homebrew/bin/
I’m not really sure what I did to fix this but I reinstalled Homebrew and now everything seems to just be working… no more issues with the Exercism CLI as well as tldr and VS Code.
I’ll post another update in case the issues resurface.
echo 'export PATH=~/bin:$PATH' >> ~/.zshrc
source ~/.zshrc #load zshrc with bin path
Because .zshrc is file that contains all configurations for zsh terminal to start up like bashrc. You can replace with .zprofile if you want only to install for the user you use.
To verify the changes that you made, write this in terminal:
nano ~/.zshrc
In the last lines of file you need to see:
export PATH=~/bin:$PATH
And try to run in terminal, after changes of zshrc and closing terminal and reopen again:
export isn’t needed because the PATH doesn’t need to be exported. The shell uses the shell variable PATH (which does not need to be an exported/env var) to find executables. The PATH is being reset every time you start a new shell so there’s no need to export it to have it persist from shell to shell. You can create a new shell without PATH in the environment to test this out. (The env command helps you create a clean environment. export -n can un-export a variable.)