Skip to content
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.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/tools/cmd/present: doesn't work with go in git master (1.16) #43459

Open
ayang64 opened this issue Jan 1, 2021 · 10 comments
Open

x/tools/cmd/present: doesn't work with go in git master (1.16) #43459

ayang64 opened this issue Jan 1, 2021 · 10 comments
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@ayang64
Copy link
Member

ayang64 commented Jan 1, 2021

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

go 1.16

$ go version
go version devel +95ce805d14 Thu Dec 31 02:24:55 2020 +0000 linux/amd64

Does this issue reproduce with the latest release?

Yes

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

go env Output
$ go env
go version devel +95ce805d14 Thu Dec 31 02:24:55 2020 +0000 linux/amd64
ayan@alia:/tmp/y$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/ayan/.cache/go-build"
GOENV="/home/ayan/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/ayan/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/ayan"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/home/ayan/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/ayan/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="devel +95ce805d14 Thu Dec 31 02:24:55 2020 +0000"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/tmp/y/go.mod"
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 -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build2261444876=/tmp/go-build -gno-record-gcc-switches"

What did you do?

I installed the present tool using go get:

$ go get golang.org/x/tools/cmd/present
go: downloading golang.org/x/tools v0.0.0-20201230224404-63754364767c
go: downloading golang.org/x/net v0.0.0-20201021035429-f5854403a974
go: downloading github.com/yuin/goldmark v1.2.1

That error occurs because go didn't place the source for the present tool in my $GOPATH.

What did you expect to see?

$ present
2021/01/01 14:19:58 Open your web browser and visit http://127.0.0.1:3999

What did you see instead?

$  present
Couldn't find gopresent files: no required module provides package golang.org/x/tools/cmd/present: working directory is not part of a module

By default, gopresent locates the slide template files and associated
static content by looking for a "golang.org/x/tools/cmd/present" package
in your Go workspaces (GOPATH).

You may use the -base flag to specify an alternate location.

I believe the right thing to do is to embed the static assets and templates in the present tool. I submitted a PR that appears to work at:

golang/tools#264

@gopherbot gopherbot added the Tools This label describes issues relating to any tools in the x/tools repository. label Jan 1, 2021
@gopherbot gopherbot added this to the Unreleased milestone Jan 1, 2021
@toothrot toothrot added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jan 5, 2021
@toothrot
Copy link
Contributor

toothrot commented Jan 5, 2021

/cc @rsc

@mikijov
Copy link

mikijov commented Jan 16, 2021

Workaround is to invoke it with -base, but that is obviously far from ideal.
present -base ~/go/src/golang.org/x/tools/cmd/present

@ayang64
Copy link
Member Author

ayang64 commented Jan 16, 2021

@mikijov -- thank you for that work-around! i think part of my issue is that go 1.16 doesn't place the source for package in an easy to find location. for example, when i use go get, the static files land in ${GOPATH}/pkg/mod/golang.org/x/tools@v0.0.0-20210115202250-e0d201561e39/cmd/present.

so this patch is meant to simplify things by embedding all of the static files.

@zikaeroh
Copy link
Contributor

zikaeroh commented Jan 16, 2021

x/tools (and any other module wanting to support Go versions before 1.16) cannot make use of the embed package due to #40067; if you want to embed the assets, you'd need to do it by other means.

EDIT: The restriction is any package in x/tools (my mistake); if you don't import it you don't see the error, but it would make present not possible to use even with build tags.

@ayang64
Copy link
Member Author

ayang64 commented Jan 16, 2021

x/tools (and any other module wanting to support Go versions before 1.16) cannot make use of the embed package due to #40067; if you want to embed the assets, you'd need to do it by other means.

I understand. So should I simply close this PR and the related issues?

@zikaeroh
Copy link
Contributor

The PR/CL maybe, but I wouldn't personally be closing the issues as you're still getting them. This is certainly still an issue; it's just that the fix can't be the embed package unless #40067 is fixed and backported to old versions of Go (or, we wait a couple of years).

@zikaeroh
Copy link
Contributor

FWIW, my original reasoning here was wrong (sorry 😦); embed could be used in a package like this as it's not importable (so the go tooling was happy before); just note that this would still have to wait for x/tools/cmd/present to no longer need to be supported for anything below 1.16.

@Koshmaar
Copy link

I updated from golang v1.14 to 1.16 and thought things will work the same (or better), but this is sad exception. Before it was working perfectly, now by default it fails miserably and one need to search internet and only on internal bugtracker it's possible to find explanation what's happening. How can this change/workaround not be explained in the present docs? Sorry for my tone, but such user unfriendliness is incredible.

What worked for me was present -base ~/go/pkg/mod/golang.org/x/tools@v0.1.0/cmd/present - maybe at least add this as a suggestion in cmdline output.

packrat386 added a commit to packrat386/tools that referenced this issue Jun 11, 2021
Provide a better suggestion for how to fix the error when static files
cannot be loaded due to installing and running in module aware mode.

See: golang/go#43459
packrat386 added a commit to packrat386/tools that referenced this issue Jun 11, 2021
Provide a better suggestion for how to fix the error when static files
cannot be loaded due to installing and running in module aware mode.

See: golang/go#43459
@nerg4l
Copy link

nerg4l commented Aug 1, 2021

Instead of using -base flag you could turn off modules temporarily with GO111MODULE=off present. Starting this way it will run as espected as of now.

@seankhliao seankhliao changed the title x/tools/cmd/present doesn't work with go in git master (1.16) x/tools/cmd/present: doesn't work with go in git master (1.16) Oct 16, 2021
@gopherbot
Copy link

Change https://golang.org/cl/356290 mentions this issue: cmd/present: embed contents when available

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants