Building on Windows - cannot find package xxx in any of

I tried building Hugo on Windows from last version with “go install hugo” and I get several errors such as:
C:\go_code\src\hugo>go install hugo
main.go:19:2: cannot find package “github.com/spf13/hugo/commands” in any of:
C:\go_code\src\hugo\vendor\github.com\spf13\hugo\commands (vendor tree)
C:\Go\src\github.com\spf13\hugo\commands (from $GOROOT)
C:\go_code\src\github.com\spf13\hugo\commands (from $GOPATH)

I can correct these errors manually by editing lines calling packages in .go files such as:
github.com/spf13/hugo/helpers

To:
“hugo/helpers”

My exact commands were:

  1. cd go_code/src/hugo
  2. govendor sync
  3. go install hugo

I notice that these changes are done in vendor.json after “govendor sync”:

  1. Some “checksumSHA1” are changed
  2. “rootPath”: “github.com/spf13/hugo"
    becomes
    "rootPath”: “hugo”

I also notice that hugo doesn’t get synced by govendor under:
C:\go_code\src\hugo\vendor\github.com\spf13/hugo

If I do copy the master version of hugo to this path manually it does work.

This machine is really limited on security and I don’t know if that may be the issue. Maybe I missed an installation step?

If you forked it, it may have ended up in the “wrong” directory under GOPATH. The trick is to make sure it lives in $GOPATH\src\hugo\vendor\github.com\spf13\hugo.

Set GOPATH=C:\go_code in your environment.

Move C:\go_code\src\hugo to C:\go_code\src\github.com\spf13\hugo.

See https://github.com/golang/go/wiki/GOPATH

Thanks a lot bep and moorereason. It was indeed my issue.

I moved my files from “C:\go_code\src\hugo” to “C:\go_code\src\github.com\spf13\hugo” and it worked.

I did a manual .zip install which should have been:

  1. Unzip to “C:\go_code\src\github.com\spf13\hugo”
  2. Open a cmd at “C:\go_code\src\github.com\spf13\hugo”
  3. input in the cmd: govendor sync
  4. input in the cmd: go install github.com\spf13\hugo

That alternative install with govendor seems cleaner as it doesn’t pollute the GOPATH folder with all of hugo’s dependencies (they are installed under “hugo/vendor” instead).

I believe this install method hasn’t been supported in all versions (as govendor support seems to have been added a few months ago), but is it a supported install method?

If that’s the case, I suggest adding it as maybe “Option 2” under “Build and Install the Binaries from Source (Advanced Install)” at:


(*) A note should probably be added with a mention that it’s supported as of version xyz.