"The selected directory is not a valid home for Go Sdk"
Asked Answered
H

10

25

I'm using IntelliJ Idea, and the google-go-lang-idea-plugin from:

https://github.com/mtoader/google-go-lang-idea-plugin/issues/173

When I try to add my APT provided Go installation to the Go SDK list, I get the following error

The selected directory is not a valid home for Go Sdk

I have tried adding the following directories as the Go SDK root

  • /usr/share/go/
  • /usr/share/src/
  • /usr/lib/go/
  • /usr/lib/go/src/
  • /usr/lib/go/pkg/
  • /usr/lib/go/pkg/linux_amd64

Does anyone know how to get this working? I've commented on the various issues in the bugtracker, however the maintainer claimed that this was fixed 10 months ago.

Failing that, does anyone know what this plugin is actually looking for that would make a directory look like the SDK directory?

Hendel answered 1/10, 2013 at 5:8 Comment(0)
D
44

I came this issue when config goroot path in goland idea.

enter image description here I solve it as follows,

Go the GO SDK path and find zversion.go, then append the file with

const TheVersion = `go1.17.2`

. You need to change the version according to you case.

In my case the sversion.go path is located at D:\Programs\Go\src\runtime\internal\sys\zversion.go.

Save the file, and restart the goland ide, then config the GOROOT (File -> setting -> Go -> GOROOT -> + -> local...), select you Go root path and save it.

enter image description here

Decrial answered 27/10, 2021 at 2:14 Comment(5)
hey dude,you saved my day! i just edit your answer to fix some markdown syntax and added a hyperlink i found in jetbrainsAlgerian
Works like charm!Kickstand
No clue why this would work, but it doesIlluminism
Seems it doesn't work on 2022.1.3 now. :-(Eurythmics
works for 1.19.3 tooDecrial
O
5

addon: got the same problem on go1.18.4, just need to add this line of code in ${GOROOT}/src/runtime/internal/sys/zversion.go

const TheVersion = `go1.18`
Optometrist answered 22/7, 2022 at 2:22 Comment(0)
H
3

It turns out that google-go-lang-idea-plugin requires a slightly different folder structure than the default apt install produces. To fix it:

# mkdir /usr/lib/go/bin
# ln -s /usr/bin/go    /usr/lib/go/bin/go
# ln -s /usr/bin/godoc /usr/lib/go/bin/godoc
# ln -s /usr/bin/gofmt /usr/lib/go/bin/gofmt
Hendel answered 12/12, 2013 at 1:5 Comment(3)
This is not required anymore since the v1.0.0 of the plugin, as such, please don't mess around with the system paths and report any issues to the bug tracker in order to improve it. Thank you.Absorber
The v1.0.0 is still in alpha and I can't install it with PhpStorm version 8, what do you suggest then? thanksKareenkarel
@Kareenkarel you can use either PHPStorm 9 EAP or IntelliJ IDEA Community 14.1+ (which is free).Absorber
S
3

Step 1: Open cmd

Step 2: Run below command => go env

Step 3: Find GOROOT and according this GOROOT path select directory for Go Sdk.

Schism answered 2/10, 2021 at 2:12 Comment(1)
This is very simple, and it works. I am on a Mac, installed Go through Homebrew, and was trying to get GoLand to recognize it. This was all it took.Brigham
D
1

So I just had this exact problem on IntelliJ 2016.1.3 with Go 1.5.

I had installed the IntelliJ Go Plugin a while ago and installed GO 1.5 a while back, and it all worked fine. Now i checked and suddenly, I'm sure I didn't remove it, GO 1.5 was gone from my system. But who knows, I haven't worked with go for a bit, so I might have removed it.

Anyway, after a bit of debugging, the following steps helped me:

  1. Install the most current Go version (currently for me 1.6.3). Follow the instructions on https://golang.org/doc/install
  2. Update the Plugin for Go in IntelliJ !!!
  3. Set the SDK in IntelliJ for the project:File -> Project Structure -> Project -> under Project SDK add a New SDK and navigate to your go installation.
  4. Click Apply and then Ok
Dustindustman answered 2/8, 2016 at 12:21 Comment(0)
C
1

I met the same problem when using go1.18 and add

const TheVersion = `go1.18`

in /src/runtime/internal/sys/zversion.go under GOROOT PATH

but it didn't work. Similar action for go1.17, it worked.

Carisa answered 13/8, 2022 at 10:15 Comment(1)
But it works for go1.18.3 so i used go1.18.3Carisa
C
0

goland 2022.3.2 golang 1.19.5

The IDE will check the following items when adding goSDK 1、dir/bin/go.exe exists? 2、dir/bin/go.exe can execute? 3、dir/VERSION

dir/src/runtime/internal/sys/zversion.go don't change

Carmencarmena answered 24/5, 2023 at 8:43 Comment(1)
As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.Increase
I
0

As the answer above said, goland checks three items when adding go sdk. I got the similar situation because i renamed the 'go' command to 'go20' in bin directory, for keeping multi versions of go environments. The problem was solved by adding version val into the file and saving two executable commands 'go' and 'go20' and just add go20 into the system path, made goland could find the initial go command. If your problem still exists after adding the var, check the bin directory.

Intracutaneous answered 12/7, 2023 at 8:49 Comment(0)
C
0
  1. Open your comand-line and type:

    go env
    
  2. Then find the set GOROOT= section and go to the directory which specified after "=" sign.

  3. Navigate to the directory src\runtime\internal\sys then find the zversoin.go file and open it by a text editor opened by run as administrator mode.

  4. Append the blow code by end of the file and save:

    const TheVesion = `go{version of go e.g. 1.20}`
    

Note: Use a backtilde, not a single quote for go{version of Go, e.g., 1.20}.

  1. Close and reopen you IDE and the try again(i.e. go to GOROOT folder retrived by go env command).

  2. For further information refer to, GOROOT and GOPATH configuration.

Coonskin answered 21/12, 2023 at 9:54 Comment(0)
L
0

Make sure you have installed the latest version of Goland. Also, if you encountered this issue on mac, make sure you have the correct go installation for your CPU.

Louettalough answered 11/7 at 10:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.