I’ve had a hugo site “working” (build|deploys) for several months using Hugo Modules.
After a short (!?) period of non-deployment, trying to deploy today throws errors and it’s unclear to me what I’m doing wrong:
hugo version
hugo v0.115.4-dc9524521270f81d1c038ebbb200f0cfa3427cc5+extended linux/amd64 BuildDate=2023-07-20T06:49:57Z VendorInfo=snap:0.115.4
hugo
go: github.com/theNewDynamic/gohugo-theme-ananke@v0.0.0-20230203204610-a1a99cf12681: invalid version: git ls-remote -q origin in /tmp/hugo_cache_dazwilkin/modules/filecache/modules/pkg/mod/cache/vcs/a4e919119dce46d6dd112b7fa8c056d8f2572e79879084b0f4d2b04c9cc1339b: exit status 128:
ssh -o ControlMaster=no -o BatchMode=yes: 1: ssh: Permission denied
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
hugo: collected modules in 779 ms
Total in 780 ms
Error: failed to load modules: failed to download modules: failed to execute 'go [mod download]': failed to execute binary "go" with args [mod download]: go: github.com/theNewDynamic/gohugo-theme-ananke@v0.0.0-20230203204610-a1a99cf12681: invalid version: git ls-remote -q origin in /tmp/hugo_cache_dazwilkin/modules/filecache/modules/pkg/mod/cache/vcs/a4e919119dce46d6dd112b7fa8c056d8f2572e79879084b0f4d2b04c9cc1339b: exit status 128:
ssh -o ControlMaster=no -o BatchMode=yes: 1: ssh: Permission denied
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
*errors.errorString
If I delete go.*
and hugo mod init ...
, I get a similar error:
go: no module dependencies to download
go: github.com/theNewDynamic/gohugo-theme-ananke@upgrade: module github.com/theNewDynamic/gohugo-theme-ananke: git ls-remote -q origin in /tmp/hugo_cache_dazwilkin/modules/filecache/modules/pkg/mod/cache/vcs/a4e919119dce46d6dd112b7fa8c056d8f2572e79879084b0f4d2b04c9cc1339b: exit status 128:
ssh -o ControlMaster=no -o BatchMode=yes: 1: ssh: Permission denied
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
hugo: collected modules in 540 ms
Total in 541 ms
Error: failed to load modules: failed to get ["-d" "github.com/theNewDynamic/gohugo-theme-ananke@upgrade"]: failed to execute 'go [get -d github.com/theNewDynamic/gohugo-theme-ananke@upgrade]': failed to execute binary "go" with args [get -d github.com/theNewDynamic/gohugo-theme-ananke@upgrade]: go: github.com/theNewDynamic/gohugo-theme-ananke@upgrade: module github.com/theNewDynamic/gohugo-theme-ananke: git ls-remote -q origin in /tmp/hugo_cache_dazwilkin/modules/filecache/modules/pkg/mod/cache/vcs/a4e919119dce46d6dd112b7fa8c056d8f2572e79879084b0f4d2b04c9cc1339b: exit status 128:
ssh -o ControlMaster=no -o BatchMode=yes: 1: ssh: Permission denied
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
*errors.errorString
And:
module github.com/DazWilkin/pretired
go 1.19
require (
github.com/theNewDynamic/gohugo-theme-ananke v0.0.0-20230203204610-a1a99cf12681 // indirect
)
And:
title = ...
baseURL = ...
languageCode = "en-us"
enableRobotsTXT = true
[module]
[[module.imports]]
path = "github.com/theNewDynamic/gohugo-theme-ananke"
[sitemap]
changefreq = "monthly"
filename = "sitemap.xml"
[params]
...
What have I done wrong?
I have not looked into the details of the problem, but wanted to note that this is not related to recent changes we made to the Snap package (just tested with empty module cache using the v0.115.4 Snap package).
I’ll try to come back to this later today.
1 Like
I don’t like guessing, but…
Have you reconfigured Git since the last time this worked?
What happens if you run this?
hugo mod clean --all
hugo
What happens if you put this in your site configuration?
[security.exec]
osEnv = ['.*']
I’ve not explicitly changed Git; it may have been updated by auto-update.
hugo mod clean --all
and then hugo
both generate the same errors.
Adding [security.exec]
makes no difference
I should have added to my question that I’m able to git pull
, git push
etc. this repo.
I’m also able to run the git ls-remote
command (which I don’t understand) that’s shown without error:
git ls-remote -q origin in /tmp/hugo_cache_dazwilkin/modules/filecache/modules/pkg/mod/cache/vcs/a4e919119dce46d6dd112b7fa8c056d8f2572e79879084b0f4d2b04c9cc1339b
Curiously there is no /tmp/hugo_cache_dazwilkin
folder!?
The test I performed (before and after) was in my environment, not yours.
Let’s take the Snap package out of play. Please run from a prebuilt binary and see if you get the same results.
https://github.com/gohugoio/hugo/releases/download/v0.115.4/hugo_extended_0.115.4_linux-amd64.tar.gz
You can just extract to your project directory, make sure you’ve got exec perms, then run ./hugo
.
Hmmm…
So hypothesis is that something’s changed between snap
versions and …
… previous (working) permissions have been revoked or are no longer appropriate.
Unfortunately, that doesn’t tell us what the Snap limitation is. This is where we’re allowed to look at Git configs:
- /etc/gitconfig
- $HOME/.gitconfig
- $HOME/.config/git
- $HOME/.gitconfig.local
And the Snap runs Go 1.19/stable internally.
Anything look different to you?
No.
more ${HOME}/.gitconfig
[gitubuntu]
lpuser = [REDACTED]
[user]
name = [REDACTED]
email = [REDACTED]
[url "git@github.com:"]
insteadOf = https://github.com/
[credential "https://source.developers.google.com"]
helper = gcloud.sh
[credential]
helper = gcloud
[pull]
rebase = false
[core]
editor = nano
snap version
snap 2.59.5
snapd 2.59.5
series 16
ubuntu 22.04
kernel 5.15.0-1041-realtime
One more. Please run:
git config --list --show-origin
I don’t need to know the settings; just the file locations.
I just saw this:
[url "git@github.com:"]
insteadOf = https://github.com/
[credential "https://source.developers.google.com"]
helper = gcloud.sh
[credential]
helper = gcloud
Are any of those settings recent?
git config --list --show-origin
file:[HOME]/.gitconfig gitubuntu.lpuser=[REDACTED]
file:[HOME]/.gitconfig user.name=[REDACTED]
file:[HOME]/.gitconfig user.email=[REDACTED]
file:[HOME]/.gitconfig url.git@github.com:.insteadof=https://github.com/
file:[HOME]/.gitconfig credential.https://source.developers.google.com.helper=gcloud.sh
file:[HOME]/.gitconfig credential.helper=gcloud
file:[HOME]/.gitconfig pull.rebase=false
file:[HOME]/.gitconfig core.editor=nano
file:[HOME]/[FOLDER]/.git/modules/public/config core.repositoryformatversion=0
file:[HOME]/[FOLDER]/.git/modules/public/config core.filemode=true
file:[HOME]/[FOLDER]/.git/modules/public/config core.bare=false
file:[HOME]/[FOLDER]/.git/modules/public/config core.logallrefupdates=true
file:[HOME]/[FOLDER]/.git/modules/public/config core.worktree=../../../public
file:[HOME]/[FOLDER]/.git/modules/public/config remote.origin.url=git@github.com:[REDACTED]/[REDACTED].github.io.git
file:[HOME]/[FOLDER]/.git/modules/public/config remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
file:[HOME]/[FOLDER]/.git/modules/public/config branch.master.remote=origin
file:[HOME]/[FOLDER]/.git/modules/public/config branch.master.merge=refs/heads/master
No.
The [credential]
sections could be deleted as they’re unused.
I can temporarily remove insteadOf
although would this setting not apply to both the non-working snap
and the working binary?
Yes, it would apply to both. But a good test.
Indeed a good test.
I commented out the insteadOf
section and the snap
now works.
I’d added that section some time ago (~years) to overcome an issue with Visual Studio Code.
I’ll revisit why I added it (I recorded the change but not the explanation :-()
Thank you! That gives us something to explore. Ultimately we will probably have to switch to Snap’s “classic confinement” which is, essentially, unconfined. I’ve been resisting, but it’s on the radar:
https://github.com/gohugoio/hugo/issues/11126
You’re incredibly helpful, thank you!
1 Like
One last thing, your SSH keys are in $HOME/.ssh, correct?