filecoin-project / specs

The Filecoin protocol specification

Home Page:https://spec.filecoin.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

hugo module cache error preventing site from building locally

olizilla opened this issue · comments

About every other week, I am hitting an issue where the sites fails to build locally, failing with an error about missing modules.

⨎ npm run serve

> specs-new@1.0.0 serve /Users/oli/Code/filecoin-project/specs
> hugo server --bind=0.0.0.0

go: github.com/filecoin-project/specs-actors@v0.8.6: reading github.com/filecoin-project/specs-actors/go.mod at revision v0.8.6: unknown revision v0.8.6
hugo: collected modules in 768 ms
Error: failed to download modules: go command failed: go: github.com/filecoin-project/specs-actors@v0.8.6: reading github.com/filecoin-project/specs-actors/go.mod at revision v0.8.6: unknown revision v0.8.6

The fix

hugo & macos can't play nice with their tmp dir. you have to delete it all and start again.

npx hugo mod clean --all

This will wipe the hugo module cache, so it can be downloaded fresh next time you run a hugo command (or npm run serve)... you need the --all flag in there or else it seems that the clean command (as with all the others) fails when it encounters the broken module.


The hugo author notes that this should be more promenant in the docs... no kidding.

A related hint from me (which should get a more prominent place in the docs):

  • Hugo uses a /tmp dir for the cache if cace dir is not set (in config.toml or environment)
  • Go downloads the modules and write protects all directories
  • On MacOS I have experienced some occasional issues which I guess relates to MacOS trying to clean out these directories, but only partly succeeds.
  • Setting HUGO_CACHEDIR os env variable to something outside /tmp is the solution to the above. It’s also in general a good thing.

see: https://discourse.gohugo.io/t/hugo-modules-for-dummies/20758/8

I dont see how manually managing your cache dir is a good thing, but i've wasted enough time on this now, and passing the --all flag seems to fix it without having to pick a custom tmp dir that works on all OSs /rant

@olizilla that's very useful! I think it should be in the main README, as people will likely not search through issues to troubleshoot their local build.