1.13.4: go mod: weird permissions in pkg/mod after go get

4,647 views
Skip to first unread message

clement auger

unread,
Nov 22, 2019, 2:40:56 PM11/22/19
to golang-nuts
hi,

I have some weird permissions set on my module files after i run go get on my project.

please check my session

[clementauger@Host-001 jenjen-stream] $ go version
go version go1
.13.4 linux/amd64
[clementauger@Host-001 jenjen-stream] $ go env
GO111MODULE
=""
GOARCH
="amd64"
GOBIN
=""
GOCACHE
="/home/clementauger/.cache/go-build"
GOENV
="/home/clementauger/.config/go/env"
GOEXE
=""
GOFLAGS
=""
GOHOSTARCH
="amd64"
GOHOSTOS
="linux"
GONOPROXY
=""
GONOSUMDB
=""
GOOS
="linux"
GOPATH
="/home/clementauger/gow"
GOPRIVATE
=""
GOPROXY
="https://proxy.golang.org,direct"
GOROOT
="/home/clementauger/.gvm/gos/go1.13.4"
GOSUMDB
="sum.golang.org"
GOTMPDIR
=""
GOTOOLDIR
="/home/clementauger/.gvm/gos/go1.13.4/pkg/tool/linux_amd64"
GCCGO
="gccgo"
AR
="ar"
CC
="gcc"
CXX
="g++"
CGO_ENABLED
="1"
GOMOD
="/home/clementauger/gow/src/github.com/clementauger/jenjen-stream/go.mod"
CGO_CFLAGS
="-g -O2"
CGO_CPPFLAGS
=""
CGO_CXXFLAGS
="-g -O2"
CGO_FFLAGS
="-g -O2"
CGO_LDFLAGS
="-g -O2"
PKG_CONFIG
="pkg-config"
GOGCCFLAGS
="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build597193614=/tmp/go-build -gno-record-gcc-switches"
[clementauger@Host-001 jenjen-stream] $ sudo rm -fr /home/clementauger/gow/pkg/mod/github.com/hashicorp/go-multierror@v1.0.0/
[clementauger@Host-001 jenjen-stream] $ sudo rm -fr /home/clementauger/gow/pkg/mod/github.com/hashicorp/errwrap@v1.0.0/
[clementauger@Host-001 jenjen-stream] $ sudo rm -fr /home/clementauger/gow/pkg/mod/github.com/hashicorp/
[clementauger@Host-001 jenjen-stream] $ cat go.mod
module github.com/clementauger/jenjen-stream

go
1.13

require github.com/hashicorp/go-multierror v1.0.0
[clementauger@Host-001 jenjen-stream] $ go get ./...
go
: extracting github.com/hashicorp/go-multierror v1.0.0
go
: extracting github.com/hashicorp/errwrap v1.0.0
[clementauger@Host-001 jenjen-stream] $ ll /home/clementauger/gow/pkg/mod/github.com/hashicorp/
total
8
dr
-x------ 2 clementauger clementauger 4096 22 nov.  20:35 errwrap@v1.0.0
dr
-x------ 2 clementauger clementauger 4096 22 nov.  20:35 go-multierror@v1.0.0

It also triggers a bug when i try to load that package using x/go/loader

$ jenjen -template=github.com/clementauger/jenjen-stream -   "T => string, StreamT => StreamString, stream => streamString"
/home/clementauger/gow/pkg/mod/github.com/hashicorp/go-multierror@v1.0.0/prefix.go:6:2: could not import github.com/hashicorp/errwrap (go/build: importGo github.com/hashicorp/errwrap: exit status 1
error writing go
.mod: open /home/clementauger/gow/pkg/mod/github.com/hashicorp/go-multierror@v1.0.0/go.mod298498081.tmp: permission denied

)
2019/11/22 20:37:34 couldn't load packages due to errors: github.com/hashicorp/go-multierror
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0x647257]

goroutine 1 [running]:
golang.org/x/tools/go/loader.(*Program).InitialPackages(0x0, 0x1, 0x1, 0xc00244fdf0)
    /home/clementauger/gow/pkg/mod/golang.org/x/to...@v0.0.0-20191121172411-96ad48e4b060/go/loader/loader.go:372 +0x37
main.main()
    /home/clementauger/gow/src/github.com/clementauger/jenjen/cmd/jenjen/main.go:132 +0x946

the conf is standard, where dst="."

        var conf loader.Config
        conf
.FromArgs([]string{dst}, false)
        prog
, err := conf.Load()
       
if err != nil {
            log
.Println(err)
       
}
        i
:= prog.InitialPackages()
       
if len(i) > 0 && len(i[0].Files) > 0 {
            dstPkgName
= i[0].Files[0].Name.Name
            dstFp
= prog.Fset.File(i[0].Files[0].Pos()).Name()
       
}

go.mod used to work well, what's wrong ?

Sean Liao

unread,
Nov 23, 2019, 2:44:29 AM11/23/19
to golang-nuts
The module cache GOPATH/pkg/mod has no write permissions to prevent accident modifications to the files (they are versioned and checksummed, modifying them would fail the checksum).

clement auger

unread,
Nov 23, 2019, 4:40:20 AM11/23/19
to golang-nuts
in regard of Sean comment and FTR,

Now using version go1.13.4
[clementauger@Host-001 ~] $ ll gow/
bin
/ pkg/ src/
[clementauger@Host-001 ~] $ ll gow/
bin
/ pkg/ src/
[clementauger@Host-001 ~] $ ll gow/pkg/mod/
cache
/      github.com/ golang.org/ gopkg.in/  
[clementauger@Host-001 ~] $ ll gow/pkg/mod/github.com/apex/
total
4
dr
-xr-xr-x 5 clementauger clementauger 4096 15 oct.  21:00 log@v1.1.1
[clementauger@Host-001 ~] $ ll gow/pkg/mod/github.com/apex/*/*
-r--r--r--  1 clementauger clementauger  794 15 oct.  21:00 gow/pkg/mod/github.com/apex/l...@v1.1.1/default.go
-r--r--r--  1 clementauger clementauger  430 15 oct.  21:00 gow/pkg/mod/github.com/apex/l...@v1.1.1/doc.go

$ ll gow/pkg/mod/github.com/hashicorp/
total 8
dr-x------ 2 clementauger clementauger 4096 22 nov.  20:35 err...@v1.0.0
dr-x------ 2 clementauger clementauger 4096 22 nov.  20:35 go-mul...@v1.0.0

$ ll gow/pkg/mod/github.com/hashicorp/*/
*
-r--r--r-- 1 clementauger clementauger  4377 22 nov.  20:35 gow/pkg/mod/github.com/hashicorp/errwrap@v1.0.0/errwrap.go
-r--r--r-- 1 clementauger clementauger  1292 22 nov.  20:35 gow/pkg/mod/github.com/hashicorp/errwrap@v1.0.0/errwrap_test.go
-r--r--r-- 1 clementauger clementauger    36 22 nov.  20:35 gow/pkg/mod/github.com/hashicorp/errwrap@v1.0.0/go.mod
-r--r--r-- 1 clementauger clementauger 15977 22 nov.  20:35 gow/pkg/mod/github.com/hashicorp/errwrap@v1.0.0/LICENSE

Bryan Mills

unread,
Nov 25, 2019, 1:52:31 PM11/25/19
to golang-nuts
The go/loader issue looks like https://golang.org/issue/34860 combined with some other bug in one of the go/loader error-handling paths.
(Note that in general we recommend golang.org/x/tools/go/packages for Go tools that support module mode.)

What is the underlying problem you were trying to solve when you ran into trouble with permissions?
Reply all
Reply to author
Forward
0 new messages