Zsh: command not found: exercism

Hi Guys,

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?

Thank you

This usually indicates that the executable is not in the $PATH, in that if it were in the path, the command could be found.

What instructions did you follow to install?

Since you know where the executable is, as you have installed it and have used it, I would probably put it in the path.

Otherwise, the cli-walkthrough suggests that we can install this using Homebrew.

Hi kotp,

Thanks for coming back to me on this one.

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 is the current contents of the file:

mitch@colossus ~ % cat ~/.zshrc
export PATH=$HOME/bin:/usr/local/bin:$PATH
export PATH="$PATH:/Applications/Visual Studio Code.app/Contents/Resources/app/bin"%

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

mitch@colossus Exercism % pwd
/Users/mitch/Exercism

mitch@colossus Exercism % ls -a
. .. javascript

What am I doing wrong? Really appreciate your help on this.

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.

What version of osx are you running?

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/

Thank you for everyone’s suggestions and help.

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.

Cheers,

Alex.

Ventura 13.2 (22D49)

I have the same problem as you. To solve the problem using zsh terminal instead of following this step in adding exercism to $PATH in documentation:

echo 'export PATH=~/bin:$PATH' >> ~/.bash_profile
source ~/.bash_profile

I used:

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:

exercism

References to learn more about zsh:

If it helps, another user (IsaacG) also helped me to solve this issue:

Kind Regards,

Rod.

Just to clarify, the export isn’t needed because PATH is already exported.

1 Like

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.)

1 Like

Respectfully disagree: programs you spawn from the shell may need to look up executables in the PATH.

/etc/profile exports the PATH on Linux (Ubuntu anyway).

On my Mac, I see the PATH initialized and exported in /etc/pam.d/rc.common:

wow! it works! thank you my friend.