Description
What version of Go are you using (go version
)?
$ go version
go version go1.11 darwin/amd64
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (go env
)?
OS X 10.13.6
$ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/kjk/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/kjk/src/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/Cellar/go/1.11/libexec"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.11/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/2k/p2_4052s70vd5_cfdm0k0l740000gn/T/go-build479826685=/tmp/go-build -gno-record-gcc-switches -fno-common"
What did you do?
- make sure you're OUTSIDE OF GOPATH
git clone https://github.com/kjk/modtest.git
cd modtest
go mod init github.com/kjk/modtest
go build
What did you expect to see?
This should build.
What did you see instead?
$ go build
go: finding github.com/gomarkdown/markdown/ast latest
go: finding github.com/gomarkdown/markdown/html latest
go: finding github.com/gomarkdown/markdown latest
main.go:8:2: unknown import path "github.com/gomarkdown/markdown/html": cannot find module providing package github.com/gomarkdown/markdown/html
For some reason go mod
has issue with github.com/gomarkdown/markdown/html
even though it works for github.com/gomarkdown/markdown
and github.com/gomarkdown/markdown/ast
.
The source of the problem seems to be:
$ go get -v github.com/gomarkdown/markdown/html
go: finding github.com/gomarkdown/markdown/html latest
go: finding github.com/gomarkdown/markdown latest
Fetching https://github.com?go-get=1
Parsing meta tags from https://github.com?go-get=1 (status code 200)
go get github.com/gomarkdown/markdown/html: no matching versions for query "latest"
There is no problem when running same go get
when in GOPATH
.
Activity
josephlr commentedon Sep 8, 2018
@kjk I just looked into this, I was able to get your example working. I had to make a tiny modification as
htmlHighlight
is not defined, but after commenting out that line, I was able to run:josephlr commentedon Sep 8, 2018
Full output:
kjk commentedon Sep 8, 2018
@josephlr I fixed the compilation error in the code.
However, I believe you did this inside GOPATH (as indicated by
(from $GOROOT)
messages).As I've indicated, you have to checkout the code outside of GOPATH.
Try repro steps after e.g.
cd $HOME
.josephlr commentedon Sep 8, 2018
@kjk Nope this was done outside of my
GOPATH
. Thego build
errors were just what happens if no go.mod file is present.josephlr commentedon Sep 8, 2018
Just tried this on
darwin/amd64
, got the same result.go mod init && go build && ./modtest
produced no errors for me (building outside ofGOPATH
).kjk commentedon Sep 8, 2018
@josephlr Are you using go 1.11 or master? Did you set
GO11MODULE
env variable to something? (I didn't so it'sauto
).I just double-checked and am still getting an error:
kjk commentedon Sep 8, 2018
Also, what does
go get -v github.com/gomarkdown/markdown/html
do?https://github.com?go-get=1
is suspicious and only happens forhtml
sub-package, not forast
sub-package.kjk commentedon Sep 8, 2018
And just to be sure, do
GO111MODULE=on go get -u -v github.com/gomarkdown/markdown/html
.It works with
GO111MODULE=off
and fails withon
orauto
if not in GOPATH.josephlr commentedon Sep 8, 2018
@kjk Still no luck reproducing your bug on
darwin/amd64
I'm outside of GOPATH, no Go environment variables set (except GOPATH), using go 1.11 installed from Homebrew latest. I even went an manually deleted the entire package cache. Here's my full output:
Other versions of software that could help:
kjk commentedon Sep 8, 2018
@josephlr Interesting. I tried to reproduce on another mac machine and couldn't.
So it's something specific to a setup on one machine but I have no ideas on how to investigate this further.
They both have similar setup, all programs from homebrew, kept up-to-date.
agnivade commentedon Sep 9, 2018
@bcmills
myitcv commentedon Sep 9, 2018
@kjk please can you try the following:
kjk commentedon Sep 10, 2018
That works, but I already said it works inside GOPATH.
myitcv commentedon Sep 10, 2018
@kjk
But this test was outside of
GOPATH
; noticeGOPATH
and your working directory are two different temporary directories, so by definition you are outside ofGOPATH
.This therefore sounds like an issue with your build/module cache (most likely the latter).
Perhaps take a backup of
$GOPATH/pkg/mod
(in case we want to investigate further) and then rungo clean -modcache
and see whether your original problem persists.bcmills commentedon Sep 10, 2018
I'm not able to reproduce the failure either.
I'm curious what happens if you run:
kjk commentedon Sep 11, 2018
go clean -modcache
fixed this.So the cache was busted to the point of messing things up. Knowing what I know now, most likely
/Users/kjk/go/pkg/mod/github.com/gomarkdown/markdown\@v0.0.0-20180907191918-6fda95a9e93f
and/or corresponding/Users/kjk/go/pkg/mod/cache/vcs/${sha1}
and/or/Users/kjk/Library/Caches/go-build
was corrupted.Unfortunately by removing the cache I also lost all the info needed to investigate it.
A hint from earlier debug tries:
no Go files in
indicates that the git repository was corrupted because there are .go files in https://github.com/gomarkdown/markdown/tree/master/htmlAlso the error message is truncated or just badly phrased.
Some other thoughts.
-n
flag for-modcache
seems brokenI'm pretty sure
go clean -modcache
deletes more than that.debugging tools for this area are not adequate
-v
doesn't provide enough information.GODEBUG
allows printing a bit more information but not enough and it's not documented anywhere in full (as in: relevant to go toolchain as a whole; it's scattered in runtime docs etc.)In retrospect it looks like local copy of
github.com/gomarkdown/markdown
in/Users/kjk/go/pkg/mod/cache/vcs/
was busted but I only figured it out after runningstrace
(well,dtruss
) ongo get
step (after I fixed it by cleaning the cache).To properly debug this there should be a switch that makes go tool print all the files it's inspecting, all
git
commands its executing etc.Realistically this bug can be closed because I don't see a way of making progress on debugging this further.
As a data point:
bcmills commentedon Sep 11, 2018
Yeah,
go clean
needs quite a bit of work for 1.12. (See also #27469, #27458, #27310, and #26991.)That could certainly do it.
go1.11beta2
was a pretty rough build for modules (sorry about that!).