I keep getting this error within Sublime Text, after installing the gofmt
package:
Traceback (most recent call last):
File "/Users/abrahma/Library/Application Support/Sublime Text 3/Installed Packages/Gofmt.sublime-package/gofmt.py", line 257, in run_formatter
formatter = Formatter(view)
File "/Users/abrahma/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/abrahma/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/abrahma/Library/Application Support/Sublime Text 3/Installed Packages/Gofmt.sublime-package/gofmt.py", line 77, in __init__
self.window)
File "/Users/abrahma/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
My `` file has the following:
"env" : {
"GOPATH" : "/Users/abrahma/git/go",
"GOROOT" : "/usr/local/Cellar/go/1.12.7/libexec",
}
(which matches the output of go env
on my terminal)
I also have a golang.sublime-settings
file with the following:
{
"env" : {
"GOPATH" : "/Users/abrahma/git/go",
"GOROOT" : "/usr/local/Cellar/go/1.12.7/libexec",
}
}
So, for some reason, the GOPATH
above clearly isn't getting picked up, any ideas why?
Instructions for setting the variables on different OS are mentioned in this doc https://github.com/golang/sublime-config/blob/master/docs/user.md
I use Sublime3 with GolangConfig in macOs and ran into the same error.
Setting the below in golang.sublime-settings
helped me fix the issue.
{
"PATH": "/Users/suryapandian/go/bin",
"GOPATH": "/Users/suryapandian/go"
}
Note: Attaching pic below to locate golang.sublime-settings
Thanks to the suggestion by @lbu, I realized that I needed this to exist in my login shell (~/.zprofile
in my case), and it works fine now.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With