{"action":"created","issue":{"url":"https://api.github.com/repos/golang/go/issues/27558","repository_url":"https://api.github.com/repos/golang/go","labels_url":"https://api.github.com/repos/golang/go/issues/27558/labels{/name}","comments_url":"https://api.github.com/repos/golang/go/issues/27558/comments","events_url":"https://api.github.com/repos/golang/go/issues/27558/events","html_url":"https://github.com/golang/go/issues/27558","id":358166107,"node_id":"MDU6SXNzdWUzNTgxNjYxMDc=","number":27558,"title":"cmd/go: hangs with 100% CPU on import of absolute path in the presence of go.mod","user":{"login":"bmeh","id":35892409,"node_id":"MDQ6VXNlcjM1ODkyNDA5","avatar_url":"https://avatars2.githubusercontent.com/u/35892409?v=4","gravatar_id":"","url":"https://api.github.com/users/bmeh","html_url":"https://github.com/bmeh","followers_url":"https://api.github.com/users/bmeh/followers","following_url":"https://api.github.com/users/bmeh/following{/other_user}","gists_url":"https://api.github.com/users/bmeh/gists{/gist_id}","starred_url":"https://api.github.com/users/bmeh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bmeh/subscriptions","organizations_url":"https://api.github.com/users/bmeh/orgs","repos_url":"https://api.github.com/users/bmeh/repos","events_url":"https://api.github.com/users/bmeh/events{/privacy}","received_events_url":"https://api.github.com/users/bmeh/received_events","type":"User","site_admin":false},"labels":[{"id":992189327,"node_id":"MDU6TGFiZWw5OTIxODkzMjc=","url":"https://api.github.com/repos/golang/go/labels/modules","name":"modules","color":"bac2ff","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2018-09-07T18:23:53Z","updated_at":"2018-09-10T16:34:20Z","closed_at":null,"author_association":"NONE","body":"### What version of Go are you using (`go version`)?\r\ngo version go1.11 linux/amd64\r\n\r\n### Does this issue reproduce with the latest release?\r\nYes.\r\n\r\n### What operating system and processor architecture are you using (`go env`)?\r\n```\r\nGOARCH=\"amd64\"\r\nGOBIN=\"\"\r\nGOCACHE=\"/home/bmeh/.cache/go-build\"\r\nGOEXE=\"\"\r\nGOFLAGS=\"\"\r\nGOHOSTARCH=\"amd64\"\r\nGOHOSTOS=\"linux\"\r\nGOOS=\"linux\"\r\nGOPATH=\"/home/bmeh/go\"\r\nGOPROXY=\"\"\r\nGORACE=\"\"\r\nGOROOT=\"/home/bmeh/.local/pkg/go-1.11\"\r\nGOTMPDIR=\"\"\r\nGOTOOLDIR=\"/home/bmeh/.local/pkg/go-1.11/pkg/tool/linux_amd64\"\r\nGCCGO=\"gccgo\"\r\nCC=\"gcc\"\r\nCXX=\"g++\"\r\nCGO_ENABLED=\"1\"\r\nGOMOD=\"\"\r\nCGO_CFLAGS=\"-g -O2\"\r\nCGO_CPPFLAGS=\"\"\r\nCGO_CXXFLAGS=\"-g -O2\"\r\nCGO_FFLAGS=\"-g -O2\"\r\nCGO_LDFLAGS=\"-g -O2\"\r\nPKG_CONFIG=\"pkg-config\"\r\nGOGCCFLAGS=\"-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build720301179=/tmp/go-build -gno-record-gcc-switches\"\r\n```\r\n\r\n### What did you do?\r\nI tried to execute `go build main.go`, where `main.go` imports an absolute path (`\"/home/bmeh/foo/logger\"`).\r\n\r\nIf file `go.mod` does not exist, it prints:\r\n`main.go:4:8: import \"/home/bmeh/foo/logger\": cannot import absolute path`\r\nWhereas if I create `go.mod` via `go mod init main` (which doesn't make `logger` a dependency, should it? In my opinion, it should, or perhaps in the future versions.), it hangs indefinitely, consuming 100% CPU. If I use `./logger` as the import path, it doesn't hang, it prints `build main: cannot find module for path _/home/bmeh/foo/logger` instead, even though `go.mod` exists in `logger/` and is properly vendored[1] via `go mod vendor`, but I guess that's not how you handle internal libraries anyway, just merely pointing out the inconsistency.\r\n\r\nIt is worth mentioning that `go build main.go` succeeds in case there is no `go.mod` and the import path is `./logger`, all while being *outside of `$GOPATH`*, but of course it checks for the dependencies in `$GOPATH`. I am not even sure how to make a vendored version of `main.go` that makes `logger/*` (which is an internal library) a dependency, along with its own vendored dependencies.[2]\r\n\r\nAdditionally, in case the import path in `main.go` is an absolute path (`\"/home/bmeh/foo/logger\"`), `go mod vendor` hangs indefinitely as well, but if it's a relative path (`\"./logger\"`), it says: `go: no dependencies to vendor`\r\n\r\nTo sum up: both `go build`, and `go mod vendor` hangs in case an absolute path is imported AND `go.mod` is present, if `go.mod` doesn't exist, it prints an error and exits. It works when `go.mod` doesn't exist, and the import path is a relative path.\r\n\r\n[1] Further explanation needed as to why that's the case, or if there are any plans to change this behavior in future releases. Additionally, in my opinion, the error message is cryptic, and why does it append `_` in front of it when I am clearly importing `/home/bmeh/foo/logger`?\r\n\r\n[2] Perhaps anyone could help me out with that?\r\n\r\nDirectory tree:\r\n\r\n```\r\n/home/bmeh/foo\r\n.\r\n├── logger\r\n│   ├── go.mod\r\n│   ├── go.sum\r\n│   ├── logger.go\r\n│   └── vendor\r\n│       ├── github.com\r\n│       │   ├── mattn\r\n│       │   │   ├── go-colorable\r\n│       │   │   │   ├── colorable_appengine.go\r\n│       │   │   │   ├── colorable_others.go\r\n│       │   │   │   ├── colorable_windows.go\r\n│       │   │   │   ├── LICENSE\r\n│       │   │   │   ├── noncolorable.go\r\n│       │   │   │   └── README.md\r\n│       │   │   └── go-isatty\r\n│       │   │       ├── doc.go\r\n│       │   │       ├── isatty_appengine.go\r\n│       │   │       ├── isatty_bsd.go\r\n│       │   │       ├── isatty_linux.go\r\n│       │   │       ├── isatty_linux_ppc64x.go\r\n│       │   │       ├── isatty_others.go\r\n│       │   │       ├── isatty_solaris.go\r\n│       │   │       ├── isatty_windows.go\r\n│       │   │       ├── LICENSE\r\n│       │   │       └── README.md\r\n│       │   └── mgutz\r\n│       │       └── ansi\r\n│       │           ├── ansi.go\r\n│       │           ├── doc.go\r\n│       │           ├── LICENSE\r\n│       │           ├── print.go\r\n│       │           └── README.md\r\n│       ├── golang.org\r\n│       │   └── x\r\n│       │       └── sys\r\n│       │           ├── AUTHORS\r\n│       │           ├── CONTRIBUTORS\r\n│       │           ├── LICENSE\r\n│       │           ├── PATENTS\r\n│       │           └── unix\r\n│       │               ├── affinity_linux.go\r\n│       │               ├── aliases.go\r\n│       │               ├── asm_darwin_386.s\r\n│       │               ├── asm_darwin_amd64.s\r\n│       │               ├── asm_darwin_arm64.s\r\n│       │               ├── asm_darwin_arm.s\r\n│       │               ├── asm_dragonfly_amd64.s\r\n│       │               ├── asm_freebsd_386.s\r\n│       │               ├── asm_freebsd_amd64.s\r\n│       │               ├── asm_freebsd_arm.s\r\n│       │               ├── asm_linux_386.s\r\n│       │               ├── asm_linux_amd64.s\r\n│       │               ├── asm_linux_arm64.s\r\n│       │               ├── asm_linux_arm.s\r\n│       │               ├── asm_linux_mips64x.s\r\n│       │               ├── asm_linux_mipsx.s\r\n│       │               ├── asm_linux_ppc64x.s\r\n│       │               ├── asm_linux_s390x.s\r\n│       │               ├── asm_netbsd_386.s\r\n│       │               ├── asm_netbsd_amd64.s\r\n│       │               ├── asm_netbsd_arm.s\r\n│       │               ├── asm_openbsd_386.s\r\n│       │               ├── asm_openbsd_amd64.s\r\n│       │               ├── asm_openbsd_arm.s\r\n│       │               ├── asm_solaris_amd64.s\r\n│       │               ├── bluetooth_linux.go\r\n│       │               ├── cap_freebsd.go\r\n│       │               ├── constants.go\r\n│       │               ├── dev_aix_ppc64.go\r\n│       │               ├── dev_aix_ppc.go\r\n│       │               ├── dev_darwin.go\r\n│       │               ├── dev_dragonfly.go\r\n│       │               ├── dev_freebsd.go\r\n│       │               ├── dev_linux.go\r\n│       │               ├── dev_netbsd.go\r\n│       │               ├── dev_openbsd.go\r\n│       │               ├── dirent.go\r\n│       │               ├── endian_big.go\r\n│       │               ├── endian_little.go\r\n│       │               ├── env_unix.go\r\n│       │               ├── errors_freebsd_386.go\r\n│       │               ├── errors_freebsd_amd64.go\r\n│       │               ├── errors_freebsd_arm.go\r\n│       │               ├── fcntl.go\r\n│       │               ├── fcntl_linux_32bit.go\r\n│       │               ├── gccgo_c.c\r\n│       │               ├── gccgo.go\r\n│       │               ├── gccgo_linux_amd64.go\r\n│       │               ├── ioctl.go\r\n│       │               ├── mkall.sh\r\n│       │               ├── mkerrors.sh\r\n│       │               ├── mkpost.go\r\n│       │               ├── mksyscall_aix.pl\r\n│       │               ├── mksyscall.pl\r\n│       │               ├── mksyscall_solaris.pl\r\n│       │               ├── mksysctl_openbsd.pl\r\n│       │               ├── mksysnum_darwin.pl\r\n│       │               ├── mksysnum_dragonfly.pl\r\n│       │               ├── mksysnum_freebsd.pl\r\n│       │               ├── mksysnum_netbsd.pl\r\n│       │               ├── mksysnum_openbsd.pl\r\n│       │               ├── openbsd_pledge.go\r\n│       │               ├── pagesize_unix.go\r\n│       │               ├── race0.go\r\n│       │               ├── race.go\r\n│       │               ├── README.md\r\n│       │               ├── sockcmsg_linux.go\r\n│       │               ├── sockcmsg_unix.go\r\n│       │               ├── str.go\r\n│       │               ├── syscall_aix.go\r\n│       │               ├── syscall_aix_ppc64.go\r\n│       │               ├── syscall_aix_ppc.go\r\n│       │               ├── syscall_bsd.go\r\n│       │               ├── syscall_darwin_386.go\r\n│       │               ├── syscall_darwin_amd64.go\r\n│       │               ├── syscall_darwin_arm64.go\r\n│       │               ├── syscall_darwin_arm.go\r\n│       │               ├── syscall_darwin.go\r\n│       │               ├── syscall_dragonfly_amd64.go\r\n│       │               ├── syscall_dragonfly.go\r\n│       │               ├── syscall_freebsd_386.go\r\n│       │               ├── syscall_freebsd_amd64.go\r\n│       │               ├── syscall_freebsd_arm.go\r\n│       │               ├── syscall_freebsd.go\r\n│       │               ├── syscall.go\r\n│       │               ├── syscall_linux_386.go\r\n│       │               ├── syscall_linux_amd64_gc.go\r\n│       │               ├── syscall_linux_amd64.go\r\n│       │               ├── syscall_linux_arm64.go\r\n│       │               ├── syscall_linux_arm.go\r\n│       │               ├── syscall_linux_gc_386.go\r\n│       │               ├── syscall_linux_gccgo_386.go\r\n│       │               ├── syscall_linux_gccgo_arm.go\r\n│       │               ├── syscall_linux_gc.go\r\n│       │               ├── syscall_linux.go\r\n│       │               ├── syscall_linux_mips64x.go\r\n│       │               ├── syscall_linux_mipsx.go\r\n│       │               ├── syscall_linux_ppc64x.go\r\n│       │               ├── syscall_linux_s390x.go\r\n│       │               ├── syscall_linux_sparc64.go\r\n│       │               ├── syscall_netbsd_386.go\r\n│       │               ├── syscall_netbsd_amd64.go\r\n│       │               ├── syscall_netbsd_arm.go\r\n│       │               ├── syscall_netbsd.go\r\n│       │               ├── syscall_openbsd_386.go\r\n│       │               ├── syscall_openbsd_amd64.go\r\n│       │               ├── syscall_openbsd_arm.go\r\n│       │               ├── syscall_openbsd.go\r\n│       │               ├── syscall_solaris_amd64.go\r\n│       │               ├── syscall_solaris.go\r\n│       │               ├── syscall_unix_gc.go\r\n│       │               ├── syscall_unix.go\r\n│       │               ├── timestruct.go\r\n│       │               ├── types_aix.go\r\n│       │               ├── types_darwin.go\r\n│       │               ├── types_dragonfly.go\r\n│       │               ├── types_freebsd.go\r\n│       │               ├── types_netbsd.go\r\n│       │               ├── types_openbsd.go\r\n│       │               ├── types_solaris.go\r\n│       │               ├── xattr_bsd.go\r\n│       │               ├── zerrors_aix_ppc64.go\r\n│       │               ├── zerrors_aix_ppc.go\r\n│       │               ├── zerrors_darwin_386.go\r\n│       │               ├── zerrors_darwin_amd64.go\r\n│       │               ├── zerrors_darwin_arm64.go\r\n│       │               ├── zerrors_darwin_arm.go\r\n│       │               ├── zerrors_dragonfly_amd64.go\r\n│       │               ├── zerrors_freebsd_386.go\r\n│       │               ├── zerrors_freebsd_amd64.go\r\n│       │               ├── zerrors_freebsd_arm.go\r\n│       │               ├── zerrors_linux_386.go\r\n│       │               ├── zerrors_linux_amd64.go\r\n│       │               ├── zerrors_linux_arm64.go\r\n│       │               ├── zerrors_linux_arm.go\r\n│       │               ├── zerrors_linux_mips64.go\r\n│       │               ├── zerrors_linux_mips64le.go\r\n│       │               ├── zerrors_linux_mips.go\r\n│       │               ├── zerrors_linux_mipsle.go\r\n│       │               ├── zerrors_linux_ppc64.go\r\n│       │               ├── zerrors_linux_ppc64le.go\r\n│       │               ├── zerrors_linux_s390x.go\r\n│       │               ├── zerrors_linux_sparc64.go\r\n│       │               ├── zerrors_netbsd_386.go\r\n│       │               ├── zerrors_netbsd_amd64.go\r\n│       │               ├── zerrors_netbsd_arm.go\r\n│       │               ├── zerrors_openbsd_386.go\r\n│       │               ├── zerrors_openbsd_amd64.go\r\n│       │               ├── zerrors_openbsd_arm.go\r\n│       │               ├── zerrors_solaris_amd64.go\r\n│       │               ├── zptrace386_linux.go\r\n│       │               ├── zptracearm_linux.go\r\n│       │               ├── zptracemipsle_linux.go\r\n│       │               ├── zptracemips_linux.go\r\n│       │               ├── zsyscall_aix_ppc64.go\r\n│       │               ├── zsyscall_aix_ppc.go\r\n│       │               ├── zsyscall_darwin_386.go\r\n│       │               ├── zsyscall_darwin_amd64.go\r\n│       │               ├── zsyscall_darwin_arm64.go\r\n│       │               ├── zsyscall_darwin_arm.go\r\n│       │               ├── zsyscall_dragonfly_amd64.go\r\n│       │               ├── zsyscall_freebsd_386.go\r\n│       │               ├── zsyscall_freebsd_amd64.go\r\n│       │               ├── zsyscall_freebsd_arm.go\r\n│       │               ├── zsyscall_linux_386.go\r\n│       │               ├── zsyscall_linux_amd64.go\r\n│       │               ├── zsyscall_linux_arm64.go\r\n│       │               ├── zsyscall_linux_arm.go\r\n│       │               ├── zsyscall_linux_mips64.go\r\n│       │               ├── zsyscall_linux_mips64le.go\r\n│       │               ├── zsyscall_linux_mips.go\r\n│       │               ├── zsyscall_linux_mipsle.go\r\n│       │               ├── zsyscall_linux_ppc64.go\r\n│       │               ├── zsyscall_linux_ppc64le.go\r\n│       │               ├── zsyscall_linux_s390x.go\r\n│       │               ├── zsyscall_linux_sparc64.go\r\n│       │               ├── zsyscall_netbsd_386.go\r\n│       │               ├── zsyscall_netbsd_amd64.go\r\n│       │               ├── zsyscall_netbsd_arm.go\r\n│       │               ├── zsyscall_openbsd_386.go\r\n│       │               ├── zsyscall_openbsd_amd64.go\r\n│       │               ├── zsyscall_openbsd_arm.go\r\n│       │               ├── zsyscall_solaris_amd64.go\r\n│       │               ├── zsysctl_openbsd_386.go\r\n│       │               ├── zsysctl_openbsd_amd64.go\r\n│       │               ├── zsysctl_openbsd_arm.go\r\n│       │               ├── zsysnum_darwin_386.go\r\n│       │               ├── zsysnum_darwin_amd64.go\r\n│       │               ├── zsysnum_darwin_arm64.go\r\n│       │               ├── zsysnum_darwin_arm.go\r\n│       │               ├── zsysnum_dragonfly_amd64.go\r\n│       │               ├── zsysnum_freebsd_386.go\r\n│       │               ├── zsysnum_freebsd_amd64.go\r\n│       │               ├── zsysnum_freebsd_arm.go\r\n│       │               ├── zsysnum_linux_386.go\r\n│       │               ├── zsysnum_linux_amd64.go\r\n│       │               ├── zsysnum_linux_arm64.go\r\n│       │               ├── zsysnum_linux_arm.go\r\n│       │               ├── zsysnum_linux_mips64.go\r\n│       │               ├── zsysnum_linux_mips64le.go\r\n│       │               ├── zsysnum_linux_mips.go\r\n│       │               ├── zsysnum_linux_mipsle.go\r\n│       │               ├── zsysnum_linux_ppc64.go\r\n│       │               ├── zsysnum_linux_ppc64le.go\r\n│       │               ├── zsysnum_linux_s390x.go\r\n│       │               ├── zsysnum_linux_sparc64.go\r\n│       │               ├── zsysnum_netbsd_386.go\r\n│       │               ├── zsysnum_netbsd_amd64.go\r\n│       │               ├── zsysnum_netbsd_arm.go\r\n│       │               ├── zsysnum_openbsd_386.go\r\n│       │               ├── zsysnum_openbsd_amd64.go\r\n│       │               ├── zsysnum_openbsd_arm.go\r\n│       │               ├── ztypes_aix_ppc64.go\r\n│       │               ├── ztypes_aix_ppc.go\r\n│       │               ├── ztypes_darwin_386.go\r\n│       │               ├── ztypes_darwin_amd64.go\r\n│       │               ├── ztypes_darwin_arm64.go\r\n│       │               ├── ztypes_darwin_arm.go\r\n│       │               ├── ztypes_dragonfly_amd64.go\r\n│       │               ├── ztypes_freebsd_386.go\r\n│       │               ├── ztypes_freebsd_amd64.go\r\n│       │               ├── ztypes_freebsd_arm.go\r\n│       │               ├── ztypes_linux_386.go\r\n│       │               ├── ztypes_linux_amd64.go\r\n│       │               ├── ztypes_linux_arm64.go\r\n│       │               ├── ztypes_linux_arm.go\r\n│       │               ├── ztypes_linux_mips64.go\r\n│       │               ├── ztypes_linux_mips64le.go\r\n│       │               ├── ztypes_linux_mips.go\r\n│       │               ├── ztypes_linux_mipsle.go\r\n│       │               ├── ztypes_linux_ppc64.go\r\n│       │               ├── ztypes_linux_ppc64le.go\r\n│       │               ├── ztypes_linux_s390x.go\r\n│       │               ├── ztypes_linux_sparc64.go\r\n│       │               ├── ztypes_netbsd_386.go\r\n│       │               ├── ztypes_netbsd_amd64.go\r\n│       │               ├── ztypes_netbsd_arm.go\r\n│       │               ├── ztypes_openbsd_386.go\r\n│       │               ├── ztypes_openbsd_amd64.go\r\n│       │               ├── ztypes_openbsd_arm.go\r\n│       │               └── ztypes_solaris_amd64.go\r\n│       └── modules.txt\r\n└── main.go\r\n\r\n12 directories, 271 files\r\n```\r\n\r\n### What did you expect to see?\r\nGracefully exit with a descriptive error message.\r\n\r\n### What did you see instead?\r\nIt hung indefinitely with 100% CPU usage.\r\n\r\n---\r\n\r\n@myitcv "},"comment":{"url":"https://api.github.com/repos/golang/go/issues/comments/419977352","html_url":"https://github.com/golang/go/issues/27558#issuecomment-419977352","issue_url":"https://api.github.com/repos/golang/go/issues/27558","id":419977352,"node_id":"MDEyOklzc3VlQ29tbWVudDQxOTk3NzM1Mg==","user":{"login":"myitcv","id":3374574,"node_id":"MDQ6VXNlcjMzNzQ1NzQ=","avatar_url":"https://avatars1.githubusercontent.com/u/3374574?v=4","gravatar_id":"","url":"https://api.github.com/users/myitcv","html_url":"https://github.com/myitcv","followers_url":"https://api.github.com/users/myitcv/followers","following_url":"https://api.github.com/users/myitcv/following{/other_user}","gists_url":"https://api.github.com/users/myitcv/gists{/gist_id}","starred_url":"https://api.github.com/users/myitcv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/myitcv/subscriptions","organizations_url":"https://api.github.com/users/myitcv/orgs","repos_url":"https://api.github.com/users/myitcv/repos","events_url":"https://api.github.com/users/myitcv/events{/privacy}","received_events_url":"https://api.github.com/users/myitcv/received_events","type":"User","site_admin":false},"created_at":"2018-09-10T16:34:20Z","updated_at":"2018-09-10T16:34:20Z","author_association":"MEMBER","body":"As I mentioned over in https://github.com/golang/go/issues/27474#issuecomment-419330707:\r\n\r\n> Relative import paths will not work. They might work with go run <files> but with GOPATH/modules mode they will not work at all.\r\n\r\n> Using an absolute path for an import path is also undefined (although I agree it should fail more gracefully than simply hanging). I will retitle the issue for this bug.\r\n\r\nHence this issue only exists to tidy up a very uncommon edge case where someone has, by accident, used an absolute import path and the experience should be better than simply hanging."}}
{"actor":{"display_login":"myitcv"}}