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

Editor not looking at vendor folder it is ln -s from other path #1327

Closed
kkpoon opened this issue Nov 10, 2017 · 19 comments
Closed

Editor not looking at vendor folder it is ln -s from other path #1327

kkpoon opened this issue Nov 10, 2017 · 19 comments
Labels
needs-investigation symlink Issues that occur when symlinks are used upstream

Comments

@kkpoon
Copy link

kkpoon commented Nov 10, 2017

VSCODE=Version 1.18.0 (1.18.0)
GOPATH=/Users/admin/Development/go
GO Extension = 0.6.67
go version go1.9.2 darwin/amd64

Project path at $GOPATH/src/github.com/kkpoon/myproject

in the editor, the import statement is red underlined

mouseover one of it, for example "github.com/rs/cors", shows

cannot find package "github.com/rs/cors" in any of:
    /usr/local/Cellar/go/1.9.2/libexec/src/github.com/rs/cors (from $GOROOT)
    /Users/admin/Development/go/src/github.com/rs/cors (from $GOPATH)

in terminal, vscode integrated or outside vscode, go build success

"github.com/rs/cors" exists in vendor folder

cd $GOPATH/src/github.com/kkpoon/myproject
ls vendor/github.com/rs/cors
LICENSE   README.md cors.go   utils.go

after investigation, found

if project path is locate at /some/path/outside/go/path/myproject
and ln -s /some/path/outside/go/path/myproject to $GOPATH/src/github.com/kkpoon/myproject
then go import statement is red underlined

if project code is really stored in $GOPATH/src/github.com/kkpoon/myproject
vscode works as expected.

@ramya-rao-a
Copy link
Contributor

What is the folder that you have opened in VS Code?

Can you try to open the folder to which you have symlinked?

@kkpoon
Copy link
Author

kkpoon commented Nov 10, 2017

I start vscode by

cd $GOPATH/src/github.com/kkpoon/myproject
code .

@ramya-rao-a
Copy link
Contributor

And is $GOPATH/src/github.com/kkpoon/myproject symlinked to the actual place where the other code lives or is the symlink created higher up in the path?

For example, I symlinked $GOPATH/src/folder to another location where the code actually lives.
If I open $GOPATH/src/folder, then everything is fine
If I open $GOPATH/src/folder/some/other/folder/under/this, then I get the same errors like you with vendor folders not being identified

@kkpoon
Copy link
Author

kkpoon commented Nov 10, 2017

for example:

# actual code location
/Users/admin/Development/github.com/project1

# GOPATH location by ln -s
GOPATH=/Users/admin/Development/go
$GOPATH/src/github.com/kkpoon/project1

ls /Users/admin/Development/github.com/project1
# and 
ls $GOPATH/src/github.com/kkpoon/project1
# show the same result

@ramya-rao-a
Copy link
Contributor

That still doesn't tell me if you symlinked the folders at the github.com level or kkpoon level or project1 level

@kkpoon
Copy link
Author

kkpoon commented Nov 10, 2017

project1 level

I did mkdir -p src/github.com/kkpoon
cd into that level and symlink project1 to its actual location.

This worked well when vscode icon was orange. But not after I update vscode to blue icon version.

Real path created by mkdir

GOPATH=/Users/admin/Development/go
$GOPATH/src
$GOPATH/src/github.com
$GOPATH/src/github.com/kkpoon

Symlink

$GOPATH/src/github.com/kkpoon/project1 ->  /Users/admin/Development/github.com/project1
ls -l $GOPATH/src/github.com/kkpoon
total 0
lrwxr-xr-x  1 kkpoon  staff  52 Nov 11 00:04 project1 -> /Users/admin/Development/github.com/project1

@ramya-rao-a
Copy link
Contributor

When you hover over the tab after opening a file, you will get see the path of the file. Does this path correspond to the actual place where the code is or the location under GOPATH?

@kkpoon
Copy link
Author

kkpoon commented Nov 13, 2017

It shows the actual path, which is not under GOPATH

@ramya-rao-a
Copy link
Contributor

that's the issue..

The Go extension depends on the file path (the one you see on the file tab) to determine the import path of the current package to use in the go build command.
Since the value is the actual path, the import path cannot be determined and the extension falls back to using go build . which in turn is obviously not able to find the vendor folders.

Can you try opening VS Code at $GOPATH/src/github.com/kkpoon level, and see if the file path in the tab now shows the actual path or the GOPATH?

@kkpoon
Copy link
Author

kkpoon commented Nov 14, 2017

I open vscode at $GOPATH/src/github.com/kkpoon. it shows the path under GOPATH and it works fine.

Yet, it worked fine even I start vscode in symlink folder.

Now, I have no idea whether this issue belongs to OS level (macos) or vscode or go extension.
:(

@ramya-rao-a
Copy link
Contributor

ramya-rao-a commented Nov 14, 2017

Ok, so to summarize

  • opening vscode at $GOPATH/src/github.com/kkpoon works
  • opening vscode at /Users/admin/Development/github.com/project1 works
  • opening vscode at $GOPATH/src/github.com/kkpoon/project1 doesn't work

Is that right?

@kkpoon
Copy link
Author

kkpoon commented Nov 15, 2017

opening vscode at $GOPATH/src/github.com/kkpoon works
opening vscode at /Users/admin/Development/github.com/project1 doesn't works (it is not under GOPATH)
opening vscode at $GOPATH/src/github.com/kkpoon/project1 doesn't work

@shuntksh
Copy link

shuntksh commented Nov 22, 2017

I am having the exact same issue as @kkpoon that I have to open vs-code from one level up ($GOPATH/src/github.com/kkpoon in this case to work on project1) in order for go-plugin to read vendor directory.

Note that I also created a symlink from my local workspace to GOPATH. And opening vs-code from the path under GOPATH. (using MacOS X Sierra with VSC 1.18.1)

@quicksnap
Copy link

Also seem to be affected. When I open it one level above the symlink, the red underline changes to a green underline with the same error message.

@quicksnap
Copy link

Looks like the green underline is coming from "go.vetOnSave": "package" setting

@ewoutp
Copy link

ewoutp commented Apr 13, 2018

Same problem here.

@ramya-rao-a
Copy link
Contributor

I've logged an upstream issue in vscode for this. microsoft/vscode#49315

@stlaz
Copy link

stlaz commented Nov 7, 2018

It seems that microsoft/vscode#34627 is the current upstream issue that needs to be resolved in order for the debugging in symlinked directory to work. I suspect the Go community will be bumping into this the most.

@ramya-rao-a ramya-rao-a added the symlink Issues that occur when symlinks are used label Oct 20, 2019
@stamblerre
Copy link
Contributor

I've filed a general tracking issue for VS Code feature requests, so I'm going to close this in favor of that issue: golang/vscode-go#48.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
needs-investigation symlink Issues that occur when symlinks are used upstream
Projects
None yet
Development

No branches or pull requests

7 participants