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

Error in lint.py #36

Open
ConnerEnders opened this issue May 18, 2020 · 3 comments
Open

Error in lint.py #36

ConnerEnders opened this issue May 18, 2020 · 3 comments

Comments

@ConnerEnders
Copy link

ConnerEnders commented May 18, 2020

For some reason just the file name is being passed into the parse function in lint.py, where it is expecting the file path. So it's trying to split string and fails. Not sure what the fix is for this.

Traceback (most recent call last):
.../go/decorators.py", line 51, in <lambda>
.../go/decorators.py", line 57, in call
.../go/decorators.py", line 12, in tracer
.../go/lint.py", line 27, in run
.../go/lint.py", line 42, in parse
.../go/lint.py", line 106, in parse
ValueError: too many values to unpack (expected 3)
@yields
Copy link
Owner

yields commented May 19, 2020

Can you provide some debug info?

  • sublime text version (in the console: sublime.version())
  • go version (run go env)

Also, what the directory structure looks like? is it a single window, single file or just a regular project with go.mod?

@rsms
Copy link

rsms commented Nov 22, 2020

I have this issue as well and I think the problem is with finding the golint program which is likely installed in our GOPATH and not system-wide e.g. in /bin.

This is what I see in sublime console whenever I save a go file: (with sublime-go just freshly installed; no changes to configuration)

Traceback (most recent call last):
  File "/Users/rsms/Library/Application Support/Sublime Text 3/Installed Packages/Golang.sublime-package/go/decorators.py", line 51, in <lambda>
  File "/Users/rsms/Library/Application Support/Sublime Text 3/Installed Packages/Golang.sublime-package/go/decorators.py", line 57, in call
  File "/Users/rsms/Library/Application Support/Sublime Text 3/Installed Packages/Golang.sublime-package/go/decorators.py", line 12, in tracer
  File "/Users/rsms/Library/Application Support/Sublime Text 3/Installed Packages/Golang.sublime-package/go/lint.py", line 27, in run
  File "/Users/rsms/Library/Application Support/Sublime Text 3/Installed Packages/Golang.sublime-package/go/lint.py", line 42, in parse
  File "/Users/rsms/Library/Application Support/Sublime Text 3/Installed Packages/Golang.sublime-package/go/lint.py", line 106, in parse
ValueError: too many values to unpack (expected 3)

sublime.version() 3211

$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/rsms/Library/Caches/go-build"
GOENV="/Users/rsms/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/rsms/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/rsms/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/Cellar/go/1.15.3/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.15.3/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/rsms/src/ljus/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/lj/xnhllk113_7f71yqt5n7jmth0000gn/T/go-build309220068=/tmp/go-build -gno-record-gcc-switches -fno-common"

golint

$ which golint
/Users/rsms/go/bin/golint

PATH visible to sublime: import os; os.environ['PATH'] in sublime console yields /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin — note that dirname $(which golint) is NOT in this path. Also import os; os.environ['GOPATH'] yields KeyError: 'GOPATH'. AFAIK there is no way to alter the environment in Sublime Text (I do have "shell_environment": true in my ST settings.)

@rsms
Copy link

rsms commented Nov 22, 2020

Offending line causing the error:

sublime-go/go/lint.py

Lines 99 to 106 in 5c72dad

@staticmethod
def parse(line, filepath, tool):
"""
Parse the given line and return an error.
If an invalid line is given, None is returned.
"""
(root, cwd, filename) = filepath

The last line here with parameter filepath is a list. It comes from here:

sublime-go/go/buffer.py

Lines 77 to 81 in 5c72dad

def filename(view):
"""
Filename returns a relative filename from view.
"""
return view.file_name()[len(root(view))+1:]

You're trying to destruct a string (the filename) as a 3-element tuple/list.

Calls goes like this:

  1. def run(self, edit):
  2. file = buffer.filename(view)
  3. return view.file_name()[len(root(view))+1:]
  4. errs = parse(res.stdout, file, "lint")
  5. (root, cwd, filename) = filepath
    ← BOOM!

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

3 participants