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
os/exec: exec.LookPath return errors when PATH starts with semicolon (parsed as contains empty string at first) and working directory is same as the target executable on windows
#69636
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.
set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\Administrator\AppData\Local\go-build
set GOENV=C:\Users\Administrator\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\Users\Administrator\go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\Administrator\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.20.14
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=-O2 -g
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-O2 -g
set CGO_FFLAGS=-O2 -g
set CGO_LDFLAGS=-O2 -g
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=C:\Users\Administrator\AppData\Local\Temp\go-build3123780178=/tmp/go-build -gno-record-gcc-switches
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)
ray1422
changed the title
os/exec: exec.LookPath return errors when PATH starts with semicolon (parsed as contains empty string at first) and working directory is same as the target executable
os/exec: exec.LookPath return errors when PATH starts with semicolon (parsed as contains empty string at first) and working directory is same as the target executable on windows
Sep 26, 2024
To avoid those security problems, as of Go 1.19, this package will not resolve a program using an implicit or explicit path entry relative to the current directory. That is, if you run LookPath("go"), it will not successfully return ./go on Unix nor .\go.exe on Windows, no matter how the path is configured. Instead, if the usual path algorithms would result in that answer, these functions return an error err satisfying errors.Is(err, ErrDot).
Go version
go version go1.20.14 windows/amd64
Output of
go env
in your module/workspace:What did you do?
I have a file
my.bat
inC:\
, and my programWhat did you see happen?
when this program executed with working dir
C:\
, it printsbut when I execute it with other working dir, it parsed normally and printed
I think it's caused by dotErr is returned too early, although the executable do exist in the PATH.
What did you expect to see?
C:\
is in the path, it should printno matter what working directory is it.
The text was updated successfully, but these errors were encountered: