Hugo server error related to hugo modules and local cache

Thanks in advance for the help.

I have been using Hugo Modules instead of Git submodules on two new local repositories and everything has been great the last few days. No problem. But today …

When I run Hugo Server on my local repositories that used Hugo Modules, I get the following error:

go: reading at revision v2.6.1: git ls-remote -q origin in /var/folders/v9/1d78tzlj70jgt2vnxfb4xl8m0000gp/T/hugo_cache_hsheridanstandard/modules/filecache/modules/pkg/mod/cache/vcs/066af87f3ece5bb7d6b6b53ce98f8b34566e9be8285986a3e33bbfe82661fac4: exit status 128:
	fatal: 'origin' does not appear to be a git repository
	fatal: Could not read from remote repository.
	Please make sure you have the correct access rights
	and the repository exists.

When I run Hugo mod init I get the same error message.

When I run hugo mod clean --all same error message.

When I run hugo config | grep cachedir same error message.

hugo env command shows:

hugo v0.114.0+extended darwin/amd64 BuildDate=unknown

It looks like a permissions issue and I have half a mind to try the hugo commands after switching over to sudo for my admin account on the machine. But, what is confusing about that is that I did not need admin rights the first time around to run mod init.

More likely, I suspect that Mac OS has cleaned the cache where the module was … and I thought that re-running hugo mod init would restore the cache but apparently I am incorrect :slight_smile:

I have a private Github repository, but if it helps, I can invite anyone as a collaborator.

Obviously, the above issue is local on my machine.

hugo server fails for the two repositories where I used Hugo Modules.

for the local repositories where I used git submodules, hugo server works just fine.

I appear to be having the same issue as this post below but I am not using micromodal and removing Congo from the repository would not be a good idea:

Thanks in advance for the help.

So, if this suddenly stopped working, I am suspicious of the volatile cache location.

Set the HUGO_CACHEDIR to something outside of /tmp and try again.

hello and thank you so much for the help.

I think you are exactly correct and I am trying to sort out the HUGO_CACHEDIR command

I was reading the below article but I don’t understand it. Can you point me in the direction of a resource with more info on this command, it’s flags, and where I should place the cache location on a mac? If not, no problem, I will see if I can start to understand the below post.

placing the cache in the usr/local/share directory makes sense to me. But, when I run HUGO_CACHEDIR at the command line i get an error saying command not found. thanks

HUGO_CACHEDIR is an environment variable, not a command.

Bingo. About that the time you made that post it dawned on me it was an environment variable and not a command. My apologies for the imposition and temp brain freeze :-).

Now i understand that article also :-).


Thank you @jmooring for your help. Greatly appreciated.

For future readers, here is what resolved the issue. I am running 11.7.8 macOS Big Sur. All of the below from the terminal command line.

  1. nano ~/.zshenv
    opens or creates the above file in a command line editor
  2. export HUGO_CACHEDIR=$HOME/.local/share/hugo
    add this line to the file
  3. ctrl o and enter
    save the file
  4. ctrl x
    exit the file and nano editor
  5. logout of terminal and log back in
  6. echo $HUGO_CACHEDIR
    confirm the env variable has been properly set
  7. cd to your Hugo repository
  8. hugo server
    it downloaded the modules and I wept :grinning:

FWIW, i tried in the beginning to change the HUGO_CACHEDIR env variable from the command line on a temp basis (have to edit the file for a permanent change), but no joy as I kept hitting “not found” issues when setting the above path, and switching to su admin user brought no joy. So I was pleasantly surprised when making the permanent change in the zshenv file worked.

Peace and good luck

1 Like

Nicely done, and thanks for details.

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