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

GOPATH not set error #16

Open
karl-gustav opened this issue Jan 21, 2020 · 5 comments
Open

GOPATH not set error #16

karl-gustav opened this issue Jan 21, 2020 · 5 comments

Comments

@karl-gustav
Copy link

Got this error after installing this plugin with package control:

  File "/Users/some_user/Library/Application Support/Sublime Text 3/Installed Packages/Gofmt.sublime-package/gofmt.py", line 257, in run_formatter
    formatter = Formatter(view)
  File "/Users/some_user/Library/Application Support/Sublime Text 3/Installed Packages/Gofmt.sublime-package/gofmt.py", line 166, in __init__
    self.cmds = [Command(cmd, self.view, self.window) for cmd in cmds]
  File "/Users/some_user/Library/Application Support/Sublime Text 3/Installed Packages/Gofmt.sublime-package/gofmt.py", line 166, in <listcomp>
    self.cmds = [Command(cmd, self.view, self.window) for cmd in cmds]
  File "/Users/some_user/Library/Application Support/Sublime Text 3/Installed Packages/Gofmt.sublime-package/gofmt.py", line 77, in __init__
    self.window)
  File "/Users/some_user/Library/Application Support/Sublime Text 3/Packages/golangconfig/all/golangconfig.py", line 227, in subprocess_info
    raise exception
golangconfig.EnvVarError: The following environment variable is currently unset: GOPATH

The ENV variable is set if I open up a terminal, but I'm guessing this is looking some where else for that variable...

@mm-git01
Copy link

mm-git01 commented May 11, 2020

did anyone find a solution for this,even though everything is set properly this error continues to pop up its is quite annoying.

@ghost
Copy link

ghost commented Aug 2, 2020

Has anyone found the solution? I have them properly set under go env and also tried making a json user setting but nothing

{
	"env":
	{
		"GOPATH": "/home/user/go",
	}
}

@JohnDDuncanIII
Copy link

I could only get this to work by going to the Golang Config package settings and manually setting my PATH and GOPATH there.

golang.sublime-settings

{
    "PATH": "/Users/username/go/bin",
    "GOPATH": "/Users/username/go"
}

https://github.com/golang/sublime-config/blob/master/docs/user.md#global-sublime-text-settings

Screen Shot 2020-08-24 at 12 23 24 AM

What's weird is that I did not need to manually set the PATH, GOPATH, nor GOROOT to get SublimeLinter-golint working. Not exactly sure why that is the case.


from the author:

I use golangconfig to run the go binaries. It supports overriding the PATH it uses, and has examples in the user documentation. As its intent is to normalize configuration across Golang packages for Sublime, I’d rather not deviate from its established way of doing things. Could you take a look at the docs and see if that gets things working?

#5 (comment)

@DCTmaybe1201
Copy link

I got the same problem when use sublime text 4 and install package https://packagecontrol.io/packages/Gofmt on MacOS

Use command which go in your terminal to get the GOPATH.
Set them in golang.sublime-settings

{
    "PATH": "/usr/local/bin/go/bin",
    "GOPATH": "/usr/local/bin/go"
}

It's done.

@salekh
Copy link

salekh commented Jul 31, 2022

I can confirm that the same issue exists on Ubuntu 22.04 as well, and the fix works there too. By default, the golang.sublime-settings file will be located under ~/.config/sublime-text/Packages/User

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants