You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Got [go build -o=/abs/path/to/output/HelloWorld -a /abs/path/to/code/HelloWorld/] to run
Actual result --
Got [go build -o=/abs/path/to/output/HelloWorld -a /abs/path/to/code/HelloWorld/] to run
go: directory ../HelloWorld/ outside available modules
Somehow, exec.Command transforms an absolute build path to relative (specifically, relative to current software working dir), making me think that when the program runs, additional go execs have the same execution environment.
Appending cmd.Dir = "/abs/path/to/code/HelloWorld/" fixes the issue, but I would like to get around this.
P.S. Since build path is absolute, obviously, I'm using go mod.
The text was updated successfully, but these errors were encountered:
ianlancetaylor
changed the title
os/exec.Cmd changes absolute path to relative when using go
os/exec: Cmd changes absolute path to relative when using go
Oct 24, 2018
The go tool prints a path as relative if that is shorter. See https://golang.org/src/cmd/go/internal/base/path.go#L23 . This isn't a bug in os/exec. I don't think it's a bug at all. Closing. Please comment if you disagree. If you do disagree, please provide a complete program that shows the problem, not a fragment; thanks.
Using go version go1.11.1 linux/amd64 with default env I run the following code (simplified for the ticket, added extra fmt.Print*)
Expected result --
Actual result --
Somehow, exec.Command transforms an absolute build path to relative (specifically, relative to current software working dir), making me think that when the program runs, additional go execs have the same execution environment.
Appending
cmd.Dir = "/abs/path/to/code/HelloWorld/"
fixes the issue, but I would like to get around this.P.S. Since build path is absolute, obviously, I'm using
go mod
.The text was updated successfully, but these errors were encountered: