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/gopls: update unstable version installation instruction #46880

Open
hyangah opened this issue Jun 22, 2021 · 6 comments
Open

x/tools/gopls: update unstable version installation instruction #46880

hyangah opened this issue Jun 22, 2021 · 6 comments
Labels
gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@hyangah
Copy link
Contributor

hyangah commented Jun 22, 2021

Neither works quietly. In favor of the experimental workspace module option, can we remove the use of replace?

~$ gotip get golang.org/x/tools/gopls@master golang.org/x/tools@master
go: downloading golang.org/x/tools/gopls v0.0.0-20210622191215-6d3e43932267
go: downloading golang.org/x/tools v0.1.4-0.20210622191215-6d3e43932267
go get: installing executables with 'go get' in module mode is deprecated.
	Use 'go install pkg@version' instead.
	For more information, see https://golang.org/doc/go-get-install-deprecation
	or run 'go help get' or 'go help install'.

~$ gotip install golang.org/x/tools/gopls@master golang.org/x/tools@master
go install: golang.org/x/tools/gopls@master (in golang.org/x/tools/gopls@v0.0.0-20210622191215-6d3e43932267):
	The go.mod file for the module providing named packages contains one or
	more replace directives. It must not contain directives that would cause
	it to be interpreted differently than if it were the main module.
@gopherbot gopherbot added Tools This label describes issues relating to any tools in the x/tools repository. gopls Issues related to the Go language server, gopls. labels Jun 22, 2021
@gopherbot gopherbot added this to the Unreleased milestone Jun 22, 2021
@ianthehat
Copy link

I vote we remove the replace and all attempt to use the new experimental go.work file instead to see if it solves the workflow well for us.

@stamblerre stamblerre added this to To Do in gopls on-deck Jul 15, 2021
@stamblerre stamblerre moved this from To Do to P3 in gopls on-deck Aug 12, 2021
@pwaller
Copy link
Contributor

pwaller commented Oct 1, 2021

Following the instructions on working with generic code, I hit this error message during install. Not clear what the right course of action is, would appreciate advice. (It also seems worthwhile to update that instruction!)

@hyangah
Copy link
Contributor Author

hyangah commented Oct 4, 2021

@pwaller please follow the instruction @jayconrod described in #43684 (comment)

# Create an empty go.mod file, only for tracking requirements.
cd $(mktemp -d)
go mod init empty-module-for-installing-a-tool

# Use 'go get' to add requirements and to ensure they work together.
go get golang.org/x/tools/gopls@master golang.org/x/tools@master

# Install using the selected versions in go.mod.
go install golang.org/x/tools/gopls

Actually, the above instruction should be the new instruction for unstable version installation until we migrate to a separate repository with one module. (cc @stamblerre @ianthehat @findleyr )

I considered removing replace directive, but even without replace, I doubt go install golang.org/x/tools@master golang.org/x/tools/gopls@master would behave as we hoped - go install doesn't support changing dependencies versions AFAIK. go install golang.org/x/tools/gopls@master may be building a version of gopls neither its developers nor the builders built/tested. go.work is designed for developers (who check out the source in the local directory), so I don't think that supports this use case.

Alternatives I considered were

  1. keep the current replace directive and ask users to git clone; cd tools/gopls; go install ., or
  2. check in go.work in x/tools and ask users to git clone; cd tools; go build -o gopls-unstable ./gopls. (note: go install won't work here).

But gopls built in these ways won't have complete version info (runtime/debug.BuildInfo) due to #29228 - which will be less ideal for gopls&vscode-go maintainers when triaging issues.

@gopherbot
Copy link

Change https://golang.org/cl/354169 mentions this issue: gopls/doc/advanced.md: update unstable version installation instruction

gopherbot pushed a commit to golang/tools that referenced this issue Oct 7, 2021
`go get` no longer builds/installs binaries in tip.

Updates golang/go#46880

Change-Id: I5673368a579d79f571adf5ca5c44c15b8101dbe9
Reviewed-on: https://go-review.googlesource.com/c/tools/+/354169
Trust: Hyang-Ah Hana Kim <hyangah@gmail.com>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
@hyangah
Copy link
Contributor Author

hyangah commented Oct 7, 2021

The new instruction based on #46880 (comment) is complicated and not user friendly. We plan to look into a way to simplify it. Current ideas:

  • Provide a script to do the work, or
  • Let gopls handle installation of it. e.g. gopls get unstable or gopls install unstable which runs the sequence of go commands and the dummy main module creation.

@hyangah hyangah self-assigned this Oct 8, 2021
@stamblerre stamblerre assigned stamblerre and unassigned hyangah and stamblerre Oct 15, 2021
@hyangah
Copy link
Contributor Author

hyangah commented Mar 17, 2022

If #50603 is implemented, we can just utilize
git clone go.googlesource.com/tools -> checkout to the wanted commit -> go install from the gopls directory.

That will achieve:

  • pick up the replace formula described as in the go.mod.
  • produce a binary with the version info other than (dev).
  • place the built binary to the default go install directory.
  • the new instruction is more user-friendly: users know git clone and go install.

@golang/tools-team

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
No open projects
Development

No branches or pull requests

6 participants