Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

Completions fail when gopkgs is not an executable #2220

Closed
thekvs opened this issue Dec 29, 2018 · 11 comments
Closed

Completions fail when gopkgs is not an executable #2220

thekvs opened this issue Dec 29, 2018 · 11 comments

Comments

@thekvs
Copy link

thekvs commented Dec 29, 2018

I am using Ubuntu and manually compile all necessary third-party go tools (gocode, gocode-gomod etc) and install them in /usr/local/bin folder via self-made .deb package. And though /usr/local/bin is in $PATH it seems that vscode unable to use some of that tools like gocode and is able to use others like gometalinter. Everything works when vscode compiles all tools itself and places them into $GOPATH/bin but for some reason I'd like to maintain aforementioned go tools in separate manner because I also want to use them from the another editor that I occasionally use.

@ramya-rao-a
Copy link
Contributor

If you are using modules, then you need to get gocode from https://github.com/stamblerre/gocode and rename the resulting binary to gocode-gomod. Follow this up with also installing gocode from https://github.com/mdempsky/gocode.

Let me know if that helps.

@thekvs
Copy link
Author

thekvs commented Dec 30, 2018

No, all gocodes' versions were correct. But it seems that I've found what was causing problems with vscode-go plugin -- I've used a wrong path for gopkgs tool in my build script so it wasn't built as an executable. Maybe you should somehow address this situation in the extension but that's another issue so I am closing this one.

@thekvs thekvs closed this as completed Dec 30, 2018
@ramya-rao-a
Copy link
Contributor

I've used a wrong path for gopkgs tool in my build script so it wasn't built as an executable. Maybe you should somehow address this situation in the extension but that's another issue so I am closing this one.

Can you elaborate on this?

@thekvs
Copy link
Author

thekvs commented Dec 31, 2018

kvs@lair ~:> go get -u -d github.com/uudashr/gopkgs
kvs@lair ~:> go build -i -o /tmp/gopkgs -ldflags="-s -w" github.com/uudashr/gopkgs    <--- I was using this wrong path in my build script
kvs@lair ~:> ls -l /tmp/gopkgs
-rw-rw-r-- 1 kvs kvs 66666 дек 31 09:12 /tmp/gopkgs
kvs@lair ~:> file /tmp/gopkgs 
/tmp/gopkgs: current ar archive   <--- Not an executable!
kvs@lair ~:> rm /tmp/gopkgs
kvs@lair ~:> go build -i -o /tmp/gopkgs -ldflags="-s -w" github.com/uudashr/gopkgs/cmd/gopkgs  <--- This is the correct one
kvs@lair ~:> ls -l /tmp/gopkgs
-rwxrwxr-x 1 kvs kvs 3838272 дек 31 09:12 /tmp/gopkgs
kvs@lair ~:> file /tmp/gopkgs 
/tmp/gopkgs: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, stripped

@ramya-rao-a
Copy link
Contributor

Maybe you should somehow address this situation in the extension

By this you mean that if the extension does find say a gopkgs file as in your case, it should check if it is an executable or not?

@thekvs
Copy link
Author

thekvs commented Jan 1, 2019

Yes.

And the other thing that I'd propose is not to break the whole code completion things (but warn user) if there are execution problems with some auxiliary tools involved in code completion. What I mean is that when I did chmod a+x on the wrongly compiled gopkgs file (it didn't make it a correct executable!) code completion magically started to work, probably with some reduced functionality.

@ramya-rao-a ramya-rao-a changed the title vscode doesn't use gocode installed in the /usr/local/bin folder Completions fail when gopkgs is not an executable Jan 2, 2019
@ramya-rao-a
Copy link
Contributor

We already check whether the file corresponding to the Go tools exist or not. It is a simple step from there to add another check on whether it is an executable as well.

PRs are most welcome to fix this.

Code Pointers:

  • Build and Debug extension
  • Update the fileExists function check to do the additional check if the file is an executable. We already have access to the fs.stats object at this point, so checking the mode should do the trick.

@keremgocen
Copy link
Contributor

I'd like to jump on this if no one else have yet

@ramya-rao-a
Copy link
Contributor

Go ahead @keremgocen :)

@oneslash
Copy link
Contributor

oneslash commented Jan 8, 2019

@ramya-rao-a, shall we close this issue since the PR has been already merged?

@ramya-rao-a
Copy link
Contributor

Yes, otherwise it misleads other contributors who want to work on issues with the help-wanted label :)

I will update this issue once we release the update with the fix

@vscodebot vscodebot bot locked and limited conversation to collaborators Feb 23, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants