Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build error on recent go versions (go: cannot find main module, but found .git/config), with workaround #7

Open
juozaspo opened this issue Oct 23, 2022 · 0 comments

Comments

@juozaspo
Copy link
Contributor

juozaspo commented Oct 23, 2022

Trying to build on Ubuntu 22.04 LTS I get an error when building using go 1.18.1.
Build log using custom build script:

go clean
go build -ldflags "-X main.Version=4 -X main.Build=`git describe --tags --always`" -o mtmapprune
go: cannot find main module, but found .git/config in /home/juozas/mtmapprune
	to create a module there, run:
	go mod init
make: *** [Makefile:11: mtmapprune] Error 1

Script contents:

#!/bin/bash
# custom build script made by juozaspo, workaround for minetest-tools/mtmapprune#1
make clean
GOPATH=/usr/share/gocode make

Running go mod init github.com/minetest-tools/mtmapprune succeeds but then build fails with error go: could not create module cache: mkdir /usr/share/gocode/pkg: permission denied unless I change the go path. Also the global path in /usr/share/gocode cannot be used as build process tries to write there, and the building takes more time than expected, sqlite library must be installed using command go get github.com/mattn/go-sqlite3.

golang-go package is installed, golang-github-mattn-go-sqlite3-dev appears to be no longer needed, also the readme does not describe what other dependencies are needed, also there are a few new files created by commands above (go mod init, go get), for now I've added them to .gitignore on my fork.

$ cat go.mod 
module github.com/minetest-tools/mtmapprune

go 1.18

require github.com/mattn/go-sqlite3 v1.14.15 // indirect
$ cat go.sum 
github.com/mattn/go-sqlite3 v1.14.15 h1:vfoHhTN1af61xCRSWzFIWzx2YskyMTwHLrExkBOjvxI=
github.com/mattn/go-sqlite3 v1.14.15/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg=

My updated fork: https://github.com/juozaspo/mtmapprune, with default branch set to testing, with go path removed from build script

@juozaspo juozaspo changed the title Build error (go: cannot find main module, but found .git/config) Build error (go: cannot find main module, but found .git/config), with workaround Oct 23, 2022
@juozaspo juozaspo changed the title Build error (go: cannot find main module, but found .git/config), with workaround Build error on recent go versions (go: cannot find main module, but found .git/config), with workaround Oct 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant