Error "unknown command: go"

When trying to build a hugo site with modules, hugo fails to get modules, because it can’t run go tool.
go and hugo was installed using asdf (https://asdf-vm.com/). go is working fine from any terminal configuration I tried.
Has anyone experienced using hugo with asdf?

❯ hugo mod get -u
unknown command: go. Perhaps you have to reshim?
WARN 2022/10/01 10:42:04 failed to download modules: failed to execute 'go [mod download]': failed to execute binary "go" with args [mod download]: unknown command: go. Perhaps you have to reshim?
 *errors.errorString
unknown command: go. Perhaps you have to reshim?
Error: failed to get ["-d" "-u" "github.com/some/module"]: failed to execute 'go [get -d -u github.com/some/module]': failed to execute binary "go" with args [get -d -u github.com/some/module]: unknown command: go. Perhaps you have to reshim?
 *errors.errorString

I suspect this is caused by Hugo’s security policy, specifically security.exec.osEnv.

The default value is:

[security.exec]
osEnv = ['(?i)^((HTTPS?|NO)_PROXY|PATH(EXT)?|APPDATA|TE?MP|TERM)$']

In your site configuration, change this to:

[security.exec]
osEnv = ['(?i)^((HTTPS?|NO)_PROXY|PATH(EXT)?|APPDATA|TE?MP|TERM|HOME|ASDF_DIR)$']

If that doesn’t work, change it to:

[security.exec]
osEnv = ['.*']

See https://github.com/gohugoio/hugo/issues/9811

Adding the asdf path worked. Thank you!

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