Can't update Packages (go: error loading module requirements) - go

I want to update my package but when i run -v command to get latest updates the command line hit an err
go get -v ./...
what happens?
> go: finding github.com/aws/aws-sdk-go v1.17.11 go: finding
> github.com/aws/aws-sdk-go v1.17.7 go: finding
> github.com/aws/aws-sdk-go v1.16.32 go:
> github.com/aws/aws-sdk-go#v1.17.7: git -c protocol.version=0 fetch
> --unshallow -f https://github.com/aws/aws-sdk-go refs/heads/*:refs/heads/* refs/tags/*:refs/tags/* in
> /Users/fly/go/pkg/mod/cache/vcs/cb1953cbdfd14fc2ffce4dfd06487e8d5a0c96da00d00bdef65874ff644eaa26:
> exit status 128: warning: redirecting to
> https://github.com/aws/aws-sdk-go/ fatal: Unable to create
> '/Users/fly/go/pkg/mod/cache/vcs/cb1953cbdfd14fc2ffce4dfd06487e8d5a0c96da00d00bdef65874ff644eaa26/shallow.lock':
> File exists.
>
> Another git process seems to be running in this repository, e.g. an
> editor opened by 'git commit'. Please make sure all processes are
> terminated then try again. If it still fails, a git process may have
> crashed in this repository earlier: remove the file manually to
> continue. go: github.com/aws/aws-sdk-go#v1.16.32: unknown revision
> v1.16.32 go: github.com/aws/aws-sdk-go#v1.17.11: unknown revision
> v1.17.11 go: error loading module requirements

The error message is pretty clear here:
Another git process seems to be running in this repository, e.g. an
editor opened by 'git commit'. Please make sure all processes are
terminated then try again.
When you run go get the git command is used to load everything. So there is another process using git.
Just end the other git command and it will work.

Related

Go install command show 404 error when trying to install module from github

I developed a go module and pushed it to github, when I am trying to install it with the go install command its showing
go: downloading github.com/hvuhsg/lokidbServer v0.0.0-20220825205442-250079f3d6e9
go: github.com/hvuhsg/lokidbServer/cmd/lokidb.go#latest: github.com/hvuhsg/lokidbServer#v0.0.0-20220825205442-250079f3d6e9: verifying module: github.com/hvuhsg/lokidbServer#v0.0.0-20220825205442-250079f3d6e9: reading https://sum.golang.org/lookup/github.com/hvuhsg/lokidb!server#v0.0.0-20220825205442-250079f3d6e9: 404 Not Found
server response:
not found: github.com/hvuhsg/lokidbServer#v0.0.0-20220825205442-250079f3d6e9: invalid version: git ls-remote -q origin in /tmp/gopath/pkg/mod/cache/vcs/023bef7fbf7701c1dd80019746ac35a6d71aa94fa9b3961e0dadef371238a56e: exit status 128:
fatal: could not read Username for 'https://github.com': terminal prompts disabled
Confirm the import path was entered correctly.
If this is a private repository, see https://golang.org/doc/faq#git_https for additional information.
P.S: the repo is public
The full command is
go install github.com/hvuhsg/lokidbServer/cmd/lokidb.go#latest
You can install it like this:
go install github.com/hvuhsg/lokidbServer/cmd#latest
If the repo is yours, I would recommend adding a folder lokidb to the cmd folder, and put the main package inside of it.
Check this repo as an example:
go install github.com/fraugster/parquet-go/cmd/csv2parquet#latest
Another option is to add a file to the root of the directory, like its done here (in this case, the package inside go.mod is defined as github.com/vektra/mockery/v2):
go install github.com/vektra/mockery/v2#latest

Golang linter issues 'context loading failed: no go files to analyze'

We are using
golangci-lint version 1.40.1 together with
golang version 1.16.4
in our project for linting our Golang code.
Until now, what we did is running this bash script (from the root
directory of our repository):
if ! [ -x "$(command -v golangci-lint)" ]; then
echo "Fetching linter..."
go install github.com/golangci/golangci-lint/cmd/golangci-lint
go mod tidy
fi
golangci-lint run --build-tags="unit contract container"
With some recent updates of Golang and golangci-lint, we suddenly face this error message:
ERRO Running error: context loading failed: no go files to analyze
There is a lengthy post on GitHub regarding this issue but the only useful suggestion there is to turn off the GO111MODULE env variable. When I run the linter with GO111MODULE turned off like
GO111MODULE=off golangci-lint run --build-tags="unit contract container"
the upper error message disappears but instead I am getting lots of false linting errors like:
api/router.go:152:5: undeclared name: `PermissionUpdatePackage` (typecheck)
PermissionUpdatePackage,
^
My go environment looks like this:
GO111MODULE=on
GOPATH=/Users/USER/workspace/go
GOROOT=/usr/local/opt/go/libexec
GOPRIVATE=*.CUSTOMER.com
GOSS_PATH=/usr/local/bin/goss
I tried to install the linter via go get... as well as go install ... and finally brew install golangci-lint which seems to be the recommended way following this documentation.
Running a go get ./... in the root of the project eventually solved the issues. In between we ran the following commands that probably cleared some (module?) caches that might have caused trouble as well:
golangci-lint cache clean && go clean -modcache -cache -i
golangci-lint run -v --timeout=5s
The error message
ERRO Running error: context loading failed: failed to load packages: timed out to load packages: context deadline exceeded
in the latter command pointed us to this GitHub post that made me try out go get ./...
For installing the linter (with a specified version), we ended up with this script:
linter_version='1.40.1'
if ! [ -x "$(command -v golangci-lint)" ]; then
echo "Fetching linter..."
# we cannot install linter in the project directory, otherwise we get dependency errors
# hence, temporarily jump into the /tmp directory
pushd /tmp > /dev/null
GO111MODULE=on go get github.com/golangci/golangci-lint/cmd/golangci-lint#v"${linter_version}" 2>&1
popd >/dev/null
fi

Jenkins GO run fails with git 128

Folks, am trying to run some go tests. Seems to be a failure with git configuration on the box?
Am running git version 1.8.3.1 before someone asks... go version 1.13.1
Builds pass for me locally on my mac and linux... but seem to fail in Jenkins
go test -v ./... -tags=unit
go: bitbucket.org/xxxxxxx/yyyyyyy#v1.0.82 requires
cloud.google.com/go/storage#v1.6.0 requires
cloud.google.com/go#v0.53.0 requires
cloud.google.com/go/bigquery#v1.3.0 requires
golang.org/x/exp#v0.0.0-20191030013958-a1ab85dbe136: invalid version: git fetch --unshallow -f https://go.googlesource.com/exp in /var/lib/jenkins/go/pkg/mod/cache/vcs/879ce674f4d9f0a3a3f207a6503e782bb2113f1a3d0c1f8049cc523b96d9aa9e: exit status 128:
fatal: git fetch-pack: expected shallow list
make[1]: *** [unit-test] Error 1
make[1]: Leaving directory `/var/lib/jenkins/workspace/xxxxxx/yyyyy'
make: *** [test] Error 2
Build step 'Execute shell' marked build as failure
[Slack Notifications] found #1 as previous completed, non-aborted build
[Slack Notifications] will send OnEveryFailureNotification because build matches and user preferences allow it
Finished: FAILURE
Solution was simple, bump up the version of git in GCP

when executing the go get command to install fabric-ca, I'm getting an error

when executing
go get -u github.com/hyperledger/fabric-ca/cmd/
from the fabric-ca guide, I get the following error:
# cd /home/pi/go/src/github.com/hyperledger/fabric-ca; git pull --ff-only
error: cannot open .git/FETCH_HEAD: Permission denied
package github.com/hyperledger/fabric-ca/cmd: exit status 1`
I tried git cloning and it downloaded everything from the fabric-ca repository, then I tried installing fabric-server and client by myself like this:
sudo make fabric-ca-server
this also produced the following error:
Building fabric-ca-server in bin directory ...
/bin/sh: 1: go: not found
Makefile:91: recipe for target 'bin/fabric-ca-server' failed
make: *** [bin/fabric-ca-server] Error 127
Looks like your GOPATH is set to /home/pi/go and appears that you do not have access to somewhere along the path to /home/pi/go/src/github.com/hyperledger/fabric-ca.
I'd check make sure that the user you are running go get with has R/W access to /home/pi/go/src

'Executable named git not found on path:' when running stack

After a recent change in the repository that I am working, I can no longer build. When trying to run any stack command, such as stack build, I get the following error:
$ stack build
Executable named git not found on path: ["/home/matthew/.stack/snapshots/x86_64-linux-nix/lts-8.23/8.0.2/bin","/nix/store/kikxl1m9gg1rh9yfi9ly9bkl39zdb6z7-postgresql-9.5.6/bin","/nix/store/xczvw3rlvr1ind8s88i7yx0vasl4gzxm-ghc-8.0.2/bin","/nix/store/sxngsdy5y53j8fkb912hbpgamb2bpv5q-patchelf-0.9/bin","/nix/store/9ngvanddznmrbf74cvy0pmrqimk3i56x-paxctl-0.9/bin","/nix/store/c07gdr6cm43j1cphadzafq185k711vx4-coreutils-8.26/bin","/nix/store/7pyzxi7k5l6nym972gi2nq8s9f9b2q0j-findutils-4.6.0/bin","/nix/store/gjwa02cchnj2r69dlqjixjmdn0ws7f1v-diffutils-3.5/bin","/nix/store/xk38vw7z7bfr8173vdwfrfamxqcaj7hi-gnused-4.4/bin","/nix/store/r6s8rcd28wsk4gwviyc93343bq5zwlqq-gnugrep-3.0/bin","/nix/store/bvs3nyfflhsb75cfn4ff2a6xnksdzx9f-gawk-4.1.3/bin","/nix/store/g3skr3kss1fqqzl5viyg178qbcp4cdky-gnutar-1.29/bin","/nix/store/kdx0bwfy20q6blpgpdb7psbn1y435r56-gzip-1.8/bin","/nix/store/f2fg211g8zy5k624dwx0g7z32cm148mr-bzip2-1.0.6.0.1-bin/bin","/nix/store/adjkz7lhgvl3y3hpkzfsmpk15f0jrnmr-gnumake-4.2.1/bin","/nix/store/lpk84rsbha199vm3k54498lqv2jswqj8-bash-4.4-p5/bin","/nix/store/1hdv6h68f7xy9k0lhxqf26saz0w0r39i-patch-2.7.5/bin","/nix/store/vkbh4xbgxvx3v9813d4kdwv8ggwrp038-xz-5.2.2-bin/bin"]
It seems that my stack program does not know the correct path to my git program.
How can I specify my git path to stack?
I have verified that I do have git installed at the following path.
$ which git
/nix/var/nix/profiles/default/bin/git
I am on nixos 17.03.
Edit.
I am sure that the stack build and which git commands were run in the same environment as they were run back to back in the same shell.
My path is
$ echo $PATH
/home/matthew/bin:/run/wrappers/bin:/run/wrappers/bin:/home/matthew/.nix-profile/bin:/home/matthew/.nix-profile/sbin:/home/matthew/.nix-profile/lib/kde4/libexec:/nix/var/nix/profiles/default/bin:/nix/var/nix/profiles/default/sbin:/nix/var/nix/profiles/default/lib/kde4/libexec:/run/current-system/sw/bin:/run/current-system/sw/sbin:/run/current-system/sw/lib/kde4/libexec
This shows the /nix/var/nix/profiles/default/bin is in the path, which contains git.
Also, in my stack.yaml file when I set system-ghc: true I get an 'access rights' error instead of the 'Executable named git not found' error.
$ stack build
Warning: /home/matthew/backup/azara_work/platform/api/stack.yaml: Unrecognized field in NixOptsMonoid: system-ghc
Cloning into '/home/matthew/backup/azara_work/platform/api/.stack-work/downloaded/4FnxEtHDACVR'...
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Process exited with ExitFailure 128: /nix/var/nix/profiles/default/bin/git clone --recursive git#github.com:seanhess/rollbar-haskell.git /home/matthew/backup/azara_work/platform/api/.stack-work/downloaded/4FnxEtHDACVR
Add this to either ~/.stack/config.yaml
or local stack.yaml (if it already has a nix: block)
nix:
enable: true
packages: [git]

Resources