Skip to content

cmd/go: 'go build' fails when current directory and output directory are symlinks on Windows #27515

Closed
@ankeesler

Description

@ankeesler

What version of Go are you using (go version)?

go version go1.11 windows/amd64

Does this issue reproduce with the latest release?

Yes. This is a regression from go1.10.3.

What operating system and processor architecture are you using (go env)?

Windows Server 1709 (OS Version 10.0.16299) and Windows Server 1803 (OS Version 10.0.17134).

set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\Administrator\AppData\Local\go-build
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=C:\Users\Administrator\go
set GOPROXY=
set GORACE=
set GOROOT=C:\Go
set GOTMPDIR=
set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64
set GCCGO=gccgo
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g`<no output>` -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\Administrator\AppData\Local\Temp\go-build075376310=/tmp/go-build -gno-record-gcc-switches

What did you do?

On Windows, create this directory structure.

C:\some-directory\
  hello\
  src\
  src2 [-> symlinked to C:\some-directory\src]
    hello [-> symlinked to C:\some-directory\hello]
    hello.go

From the directory C:\some-directory\src2\, run go build -o c:\some-directory\src2\hello\hello.exe .\hello.go.

What did you expect to see?

The command succeeds and builds hello.exe in the directory C:\some-directory\hello\.

What did you see instead?

go build command-line-arguments: mkdir C:\some-directory\src2\hello\: Cannot create a file when that file already exists.

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.OS-Windows

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions