Hugo not found

I’m having issues running Hugo after updating it to hugo_extended_0.74.3_macOS-64bit. I followed the installation via tarball instructions, but when I run which hugo via the command line it returns ‘hugo not found’. It was running normally before the update. I’ve tried to roll back to the prior version, but get the same error when attempting to run hugo or check the version.

Any clue what might be happening?

Where did you install it? To which location? Please provide all the steps you took in detail if possible.

  1. Which location did you put the hugo binary in?
  2. If it’s anywhere outside standard system binary directories, it will not be in the $PATH
  3. You can always add it to a folder in your home directory, and add that folder/directory to your $PATH variable, so hugo is found.

I usually recommend ~/.bin or ~/bin in your home directory.

If you unpack the tarball to ~/.bin/ or ~/bin, so it looks like ~/.bin/hugo or ~/bin/hugo and then add the PATH=$PATH:~/.bin/ hugo will always be found.

Make sure you put it in the correct directory. By correct I mean, the same one tht’s in your path variable (could even be the system PATH, hence /usr/bin or /usr/local/bin/)

I downloaded the appropriate latest release here, confirmed the download, extracted it and moved it to ~/bin. I then verified it runs via ./hugo version, and added export PATH=$PATH:$HOME/bin to my PATH variable. I noticed the permissions on the extracted Hugo executable wasn’t 777 (like in the instructions example), so I changed it just to be sure.

Open a new shell and type echo "$PATH" to verify.

That’s returning: /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

Exactly. It doesn’t contain $HOME/bin.

If you typed export PATH=$PATH:$HOME/bin, the change was temporary, for the current shell.

You need to change your PATH permanently.

See https://stackoverflow.com/questions/7703041/editing-path-variable-on-mac.

I think I understand but a little more clarity would help me. I edited my base_profile via $ nano ~/.bash_profile, then entered export PATH=$PATH:$HOME/bin and saved the file (as the hugo documentation instructs). You are saying that a successful permanent updated you mean I see $HOME/bin when echoing $PATH, correct?

No. You should see something like this:

/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/home/your_user_name/bin

Since you’re having trouble with this, and /usr/local/bin is already in your path, why not install it /usr/local/bin?

I do not know when .bash_profile is sourced on a Mac. I do not know if it is sourced every time you open a new shell, or only upon login. Have you tried logging out/in?

If that doesn’t work, can you post the contents of .bash_profile?

I get the following attempting to extract to /usr/local/bin: tar: Error exit delayed from previous errors.

I’ve noticed that if I simple enter export PATH=$PATH:$HOME/bin then type which hugo, it echos the correct path to the hugo executable (in same shell). I’ve tried restarting my machine but to no avail – same error: hugo not found.

Exactly. You have not permanently updated your PATH. Type cat ~/.bash_profile and post the results.

export PATH=$PATH:$HOME/bin

That’s it? Nothing else?

Please type cat ~/.profile and post the results.

Yes that was all of it. cat ~/.profile gives me: cat: /Users/nz0brp/.profile: No such file or directory

At this point we’ve established that this is not a Hugo problem, but a “your mac” problem. I suspect your ~/.bash_profile is not being sourced.

  1. Perhaps something here will help: https://stackoverflow.com/questions/18773051/how-to-make-os-x-to-read-bash-profile-not-profile-file
  2. You should post your problem on a mac-related forum.
1 Like

Agreed. Thanks for the help Joe!

Not a Hugo issue but for those that might have encountered this as well:

The issue stems from zsh (Z shell) being the new default shell starting with macOS Catalina. To resolve, I first verified shell was zsh with echo $SHELL, then went home with cd ~/ created a profile via $ touch .zprofile and opened it with open .zprofile. The final step is to add export PATH=$PATH:$HOME/bin to the profile file and close it. You can verify it worked by opening a new shell window and running which hugo to see the updated path. :sweat_smile:

3 Likes

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.