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

If there is space in username, it doesn't work #544

Closed
Blank-c opened this issue May 27, 2022 · 3 comments · Fixed by #545
Closed

If there is space in username, it doesn't work #544

Blank-c opened this issue May 27, 2022 · 3 comments · Fixed by #545
Assignees
Labels
bug Something isn't working
Milestone

Comments

@Blank-c
Copy link

Blank-c commented May 27, 2022

What version of Garble and Go are you using?

$ garble version
v0.6.0

$ go version 
1.18.2

What environment are you running Garble on?

go env Output
$ go env
set GO111MODULE=on
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\Sauhard Gaming\AppData\Local\go-build
set GOENV=C:\Users\Sauhard Gaming\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\Users\Sauhard Gaming\go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\Sauhard Gaming\go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=C:\Program Files\Go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=C:\Program Files\Go\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.18.2
set GCCGO=gccgo
set GOAMD64=v1
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=NUL
set GOWORK=
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
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=C:\Users\SAUHAR~1\AppData\Local\Temp\go-build2327819100=/tmp/go-build -gno-record-gcc-switches

What did you do?

garble build hello.go

What did you expect to see?

An executable file

What did you see instead?

image

@mvdan
Copy link
Member

mvdan commented May 27, 2022

Hm, nicely spotted.

@mvdan mvdan self-assigned this May 27, 2022
@mvdan mvdan added the bug Something isn't working label May 27, 2022
@mvdan
Copy link
Member

mvdan commented May 27, 2022

The problem seems to be that -toolexec takes a space-separated list of arguments, so if the path to garble on disk contains a space, it splits that into two arguments. So in your case, -toolexec=/path/with spaces/to/garble tries to execute /path/with rather than /path/with spaces/to/garble.

The proper fix will need to be upstream, which is unfortunate as that could mean no backport to Go 1.18.x.

I'm trying to think if we could work around this. On Linux, we certainly could - if garble is running in /home/foo bar/go/bin/garble, we could have it copy the binary to /tmp/garble (via os.TempDir) and then use -toolexec=/tmp/garble to avoid the space. However, on Windows we can't do that - if garble is in C:\Users\foo bar\go\bin\garble, the only temporary directory will be something like C:\Users\foo bar\AppData\Local\Temp, which still contains a space. And I don't think there are any directories outside the user's home directory where we can reliably write executable files.

@mvdan
Copy link
Member

mvdan commented May 27, 2022

Scratch that - there is no upstream bug. Fix incoming.

@mvdan mvdan added this to the v0.7.0 milestone May 27, 2022
mvdan added a commit to mvdan/garble-fork that referenced this issue May 27, 2022
If we don't quote it, paths containing spaces or quote characters will
fail. For instance, the added test without the fix fails:

        > env NAME='with spaces'
        > mkdir $NAME
        > cp $EXEC_PATH $NAME/garble$exe
        > exec $NAME/garble$exe build main.go
        [stderr]
        go tool compile: fork/exec $WORK/with: no such file or directory
        exit status 1

Luckily, the fix is easy: we bundle Go's cmd/internal/quoted package,
which implements a QuotedJoin API for this very purpose.

Fixes burrowers#544.
mvdan added a commit to mvdan/garble-fork that referenced this issue May 27, 2022
If we don't quote it, paths containing spaces or quote characters will
fail. For instance, the added test without the fix fails:

        > env NAME='with spaces'
        > mkdir $NAME
        > cp $EXEC_PATH $NAME/garble$exe
        > exec $NAME/garble$exe build main.go
        [stderr]
        go tool compile: fork/exec $WORK/with: no such file or directory
        exit status 1

Luckily, the fix is easy: we bundle Go's cmd/internal/quoted package,
which implements a QuotedJoin API for this very purpose.

Fixes burrowers#544.
mvdan added a commit to mvdan/garble-fork that referenced this issue May 29, 2022
If we don't quote it, paths containing spaces or quote characters will
fail. For instance, the added test without the fix fails:

        > env NAME='with spaces'
        > mkdir $NAME
        > cp $EXEC_PATH $NAME/garble$exe
        > exec $NAME/garble$exe build main.go
        [stderr]
        go tool compile: fork/exec $WORK/with: no such file or directory
        exit status 1

Luckily, the fix is easy: we bundle Go's cmd/internal/quoted package,
which implements a QuotedJoin API for this very purpose.

Fixes burrowers#544.
@lu4p lu4p closed this as completed in #545 May 29, 2022
lu4p pushed a commit that referenced this issue May 29, 2022
If we don't quote it, paths containing spaces or quote characters will
fail. For instance, the added test without the fix fails:

        > env NAME='with spaces'
        > mkdir $NAME
        > cp $EXEC_PATH $NAME/garble$exe
        > exec $NAME/garble$exe build main.go
        [stderr]
        go tool compile: fork/exec $WORK/with: no such file or directory
        exit status 1

Luckily, the fix is easy: we bundle Go's cmd/internal/quoted package,
which implements a QuotedJoin API for this very purpose.

Fixes #544.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

Successfully merging a pull request may close this issue.

2 participants