Relative paths passed to localInstall work unexpectedly
matthijskooijman opened this issue · comments
I'm a bit stubborn when it comes to go and directory organisation, so I tried to use vg
to create a git clone of my project in whatever directory I wanted (without having to have it in src/github.com/foo/bar
). I was hoping that that would take care of creating a virtual GOPATH somewhere, and automatically link my project directory into there in an appropriate place. Unfortunately that did not happen, so I needed a manual vg localInstall
to get my project directory linked (which makes sense, since vg
does not know the full package name of my project).
So, I tried:
/path/to/bar$ vg localInstall github.com/foo/bar .
/path/to/bar$ mount|grep bar
/path/to/bar on /home/matthijs/.virtualgo/bar/src/github.com/foo/bar type fuse (rw,nosuid,nodev,relatime,user_id=1000,group_id=1000,default_permissions)
Which indeed correctly puts /path/to/bar
in the virtual $GOPATH/src/github.com/foo/bar
. However, in virtualgo.toml
it stores the original relative path .
, and it seems this path is interpreted relative to the current directory, not the project root. E.g. if I deactivate the workspace and then jump into a subdirectory of my project, things get broken:
/$ cd /path/to/bar/sub/
Activating bar
Uninstalling "github.com/foo/bar" from workspace
Unmounting bindfs mount at "/home/matthijs/.virtualgo/bar/src/github.com/foo/bar"
Removing sources at "/home/matthijs/.virtualgo/bar/src/github.com/foo/bar"
Removing "github.com/foo/bar" from locally installed packages
Installing local sources at "." in workspace as "github.com/foo/bar" using bindfs
(bar) matthijs@grubby:/path/to/bar/sub$ mount|grep bar
/path/to/bar/sub on /home/matthijs/.virtualgo/bar/src/github.com/foo/bar type fuse (rw,nosuid,nodev,relatime,user_id=1000,group_id=1000,default_permissions)
Should the path passed to localInstall
be made absolute before storing it?
I think it indeed makes sense to make the path absolute before storing. If you want to take a stab at it let me know, otherwise I think I'll fix it in a couple of days.
Thanks! No spare time, so I'll leave this one for you :-)