Different "go install" behavior on Win10 compared to Linux and OSX

Hello All,

On Linux and OSX “go install” works fine from the src directory. On Windows 10 I need to supply the library path to the tool to get it to build. imports work fine on all 3 platforms. Details from Windows:

John@RATBONE C:\Users\John
> go env GOPATH
C:\Users\john\Projects\golang

John@RATBONE C:\Users\John
> cd %GOPATH%

John@RATBONE C:\Users\John\Projects\golang
> ll
total 0
drwxrwxrwx   1 user     group           0 Oct 28 14:24 bin
drwxrwxrwx   1 user     group           0 Jul 30 14:09 pkg
drwxrwxrwx   1 user     group           0 Oct 28 13:51 src

Everything builds and runs fine, but I need to supply the pkg/lib path to go install:

John@RATBONE C:\Users\John\Projects\golang
> ls -l pkg\windows_amd64\bitbucket.org\user\wsbc-server
total 63
-rw-rw-rw-   1 user     group       45576 Nov 11 14:51 taplist.a
-rw-rw-rw-   1 user     group       17832 Nov 11 14:51 wsbcdb.a

John@RATBONE C:\Users\John\Projects\golang                                              
> cd src\bitbucket.org\user\wsbc-server\taplist                                      
                                                                                        
John@RATBONE [...]\src\bitbucket.org\user\wsbc-server\taplist
> go install
go install: no install location for directory C:\Users\John\Projects\golang\src\bitbucket.org\user\wsbc-server\taplist outside GOPATH
        For more details see: 'go help gopath'
> go install bitbucket.org\user\wsbc-server\taplist

> ls -l %GOPATH%\pkg\windows_amd64\bitbucket.org\user\wsbc-server
total 63
-rw-rw-rw-   1 user     group       45154 Nov 12 12:20 taplist.a
-rw-rw-rw-   1 user     group       17832 Nov 12 12:20 wsbcdb.a

The imports in main() work just fine on Windows, though:

import (
        [...]
        "bitbucket.org/user/wsbc-server/taplist"
)

Am I missing something on Windows?

Thanks,

JB

PS:

> go env
set GOARCH=amd64
set GOBIN=C:\Users\john\Projects\golang\bin
set GOEXE=.exe
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=C:\Users\john\Projects\golang
set GORACE=
set GOROOT=C:\Go
set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64
set GCCGO=gccgo
set CC=gcc
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0
set CXX=g++
set CGO_ENABLED=1
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
(c) 2017 Microsoft Corporation. All rights reserved.

C:\Users\Meliphas>go env
set GOARCH=amd64
set GOBIN=
set GOEXE=.exe
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=C:\Users\Meliphas\go
set GORACE=
set GOROOT=C:\Go
set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64
set GCCGO=gccgo
set CC=gcc
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0
set CXX=g++
set CGO_ENABLED=1
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config

I’m on Windows 10 as well, my install tool works just fine and the only difference between our environment variables is that I do no have a GOBIN set. I hope this helps.

@CurtGreen I unset GOBIN but the behavior is still the same. Thanks, though!

Hrrmmm have you tried uninstalling and reinstalling the go tools?

1 Like

I bet it sees C:\Users\john as distinct from C:\Users\John. Try using a consistent case for the path.

1 Like

@CurtGreen no I had not tried that. I uninstalled the go msi, cleaned out all the relevant env vars in Win10, re-downloaded and re-installed the go 1.9.2 msi and now everything seems fine, after I reset GOPATH.

Thanks for the suggestion, dunno why it didn’t occur to me. Also I do remember the 1.9.2 installer getting “hung up” for a bit the first time through, not sure what happened…

Thanks again!

JB

@calmh wow I had not noticed that - not sure how that happened, I must have mis-typed it in the system env var editing tool (though I usually copy/paste to avoid that). Thanks! That was almost certainly the issue. Though it is strange - that lower case ‘j’ kept “go install” from working, but the build of main() did not seem to be effected?

I marked your post as the answer, but I wonder why/how main() built.

Thanks!

JB

I think the check only gets triggered when it looks for the bin directory to put the resulting binary in.

1 Like

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