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

settings: support predefined variables in go.toolsEnvVars #413

Closed
edp1096 opened this issue Jul 26, 2020 · 5 comments
Closed

settings: support predefined variables in go.toolsEnvVars #413

edp1096 opened this issue Jul 26, 2020 · 5 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@edp1096
Copy link

edp1096 commented Jul 26, 2020

Please direct general questions to:

Please review the documentation before filing an issue.
Helpful pages include:

Please answer these questions before submitting your issue. Thanks!

What version of Go, VS Code & VS Code Go extension are you using?

  • Run go version to get version of Go
    • go version go1.14.4 windows/amd64
  • Run code -v or code-insiders -v to get version of VS Code or VS Code Insiders
    • 버전: 1.47.2
      커밋: 17299e413d5590b14ab0340ea477cdd86ff13daf
      날짜: 2020-07-15T18:22:06.216Z
      Electron: 7.3.2
      Chrome: 78.0.3904.130
      Node.js: 12.8.1
      V8: 7.8.279.23-electron.0
      OS: Windows_NT x64 10.0.18363
  • Check your installed extensions to get the version of the VS Code Go extension
  • Run go env to get the go development environment details
	- ws$ go env
set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=D:\devs\pcbangstudio\user\gocache
set GOENV=D:\devs\pcbangstudio\user\userprofile\AppData\Roaming\go\env
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=D:\devs\pcbangstudio\user\gopath
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=D:\devs\pcbangstudio\tools\langs\go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=D:\devs\pcbangstudio\tools\langs\go\pkg\tool\windows_amd64
set GCCGO=gccgo
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=D:\devs\pcbangstudio\workspace\chsn-inventory\ws\go.mod
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -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=D:\devs\pcbangstudio\user\tmp\go-build876394286=/tmp/go-build -gno-record-gcc-switches
ws$

Share the Go related settings you have added/edited

Run Preferences: Open Settings (JSON) command to open your settings.json file.
Share all the settings with the go. or ["go"] or gopls prefixes.

    "go.toolsEnvVars": {
        "GOARCH": "amd64",
        "GOOS": "windows",
        "GOBIN": "${workspaceFolder}/bin"
    },
    "go.useLanguageServer": true,
    "[go]": {
        "editor.snippetSuggestions": "none",
        "editor.formatOnSave": true,
        "editor.codeActionsOnSave": {
            "source.organizeImports": true,
            "source.fixAll": true,
        },
        "editor.defaultFormatter": "golang.go"
    },
    "files.eol": "\n",
    "gopls": {
        "usePlaceholders": true // add parameter placeholders when completing a function
    },
    "go.languageServerExperimentalFeatures": {
        "format": true,
        "autoComplete": true,
        "rename": true,
        "goToDefinition": true,
        "hover": true,
        "signatureHelp": true,
        "goToTypeDefinition": true,
        "goToImplementation": true,
        "documentSymbols": true, // =outline
        "workspaceSymbols": true,
        "findReferences": true
    },
    "go.languageServerFlags": [],
    "go.docsTool": "gogetdoc",
    "go.formatTool": "goimports",
    "go.gocodeAutoBuild": true,

Describe the bug

A clear and concise description of what the bug.
A clear and concise description of what you expected to happen.

When use install features with Predefined variable of vscode, vscode-go cannot recognize the path value.

  • Go: Install Current Package - Output message when try to install my source to GOBIN where I specified.
Installing current package
Installation failed: cannot install, GOBIN must be an absolute path
  • Go: Install/Update Tools - Output message when try to install go tools by vscode-go.
Tools environment: GOPATH=D:\devs\pcbangstudio\user\gopath, GOBIN=${workspaceFolder}/bin
Installing 1 tool at the configured GOBIN: ${workspaceFolder}/bin in module mode.
  gopls

Installing golang.org/x/tools/gopls FAILED

1 tools failed to install.

gopls: failed to install [object Object]: Error: Command failed: D:\devs\pcbangstudio\tools\langs\go\bin\go.exe get -v golang.org/x/tools/gopls
go: golang.org/x/tools/gopls upgrade => v0.4.3
cannot install, GOBIN must be an absolute path
 undefined  
@stamblerre
Copy link
Contributor

I'm not sure if specifying ${workspaceFolder} in your settings will work the same way as in a launch.json. Can you remove that setting or use the go.toolsGopath setting to specify a location in which to install tools?

@stamblerre stamblerre added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Jul 26, 2020
@edp1096 edp1096 closed this as completed Jul 26, 2020
@edp1096
Copy link
Author

edp1096 commented Jul 26, 2020

Hello Rebecca,
Solved tools installation by adding "go.toolsGopath": "${env:GOPATH}", thank you but, Go: Install Current Package feature is still showing same message failed.
Is there not possible using go.toolsEnvVars with Predefined variables at settings.json anymore?

@edp1096 edp1096 reopened this Jul 26, 2020
@stamblerre
Copy link
Contributor

It's possible that we accidentally made a change that broke this. You're right - this does seem like it should work, and I am able to reproduce the error. Thanks for the report - we'll look into it.

@stamblerre stamblerre added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. and removed WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. labels Jul 26, 2020
@stamblerre stamblerre changed the title Installation failed: cannot install, GOBIN must be an absolute path settings: support predefined variables in go.toolsEnvVars Jul 26, 2020
@hyangah hyangah modified the milestones: v0.17.0, v0.16.0 Jul 30, 2020
@gopherbot
Copy link
Collaborator

Change https://golang.org/cl/246519 mentions this issue: src/goEnv.ts: readd go.toolsEnvVars variable substitution

@hyangah hyangah modified the milestones: v0.17.0, v0.16.1 Aug 5, 2020
gopherbot pushed a commit that referenced this issue Aug 5, 2020
The extension resolved ${workspaceFolder}, ${workspaceRoot},
${env:} variables included in go.toolsEnvVars, since 0.6.66,
but that feature was lost in the 0.15 dev cycle.

Readd the code from
https://github.com/microsoft/vscode-go/blob/2dbccbe5d2fb70feab3f87ac6f6187f6b896e795/src/util.ts#L438

Similar logic for testEnvVars still exists in getTestEnvVars
(testutils.ts).

Fixes #413

Change-Id: I1cc8ff41ce8445c573e554f947da8cd610c3671b
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/246519
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
(cherry picked from commit 6a84918)
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/246958
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
@gopherbot
Copy link
Collaborator

Change https://golang.org/cl/246958 mentions this issue: [release] src/goEnv.ts: readd go.toolsEnvVars variable substitution

@golang golang locked and limited conversation to collaborators Aug 5, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

4 participants