Skip to content

add ability to read symlink basedirs - #438

Merged
mattfarina merged 1 commit into
Masterminds:masterfrom
klnusbaum:check_basedir_symlink
Jun 2, 2016
Merged

add ability to read symlink basedirs#438
mattfarina merged 1 commit into
Masterminds:masterfrom
klnusbaum:check_basedir_symlink

Conversation

@klnusbaum

@klnusbaum klnusbaum commented May 22, 2016

Copy link
Copy Markdown
Contributor

Imagine the following scenario: A user has a Go project. This directory is sitting in an arbitrary location in their file system and the user would like to keep it there. However, they need it to work with Go tooling, so they symlink it into an appropriate location in their GOPATH, e.g. $GOPATH/src/github.com/user1/myproject. The user then decides they's like to start using glide, so they cd to $GOPATH/src/github.com/user1/myproject and run glide create to generate their initial glide.yaml file. The result is the creation of empty glide.yaml file. Sad times.

What's happening is that the basedir given to NewResolver is actually a symlink. This in turn causes an issue in the ResolveLocal function. The if !fi.IsDir() check fails since the basedir isn't actually a directory, it's a symlink.

Let's add a check to the NewResolver function. After getting the absolute path of the provided basedir, let's check to see if it's a symlink. If it is, read the symlink and use that as the basedir instead. If not, proceed as normal.

@mattfarina

mattfarina commented May 23, 2016

Copy link
Copy Markdown
Member

I really like this change.

Unfortunately, I case where project can be added to itself. For example,

package: github.com/foo/bar
import:
- package: github.com/foo/bar
  subpackages:
  - baz
  - qux

I discovered this on a private project so I can't share.

Once we get this fixed I'll be happy to merge this. I'll try to dig into it more later this week. If you find the solution before then that would be great, too.

Note, updated to fix formatting.

@mattfarina mattfarina added this to the 0.11 milestone May 23, 2016
@klnusbaum

Copy link
Copy Markdown
Contributor Author

Hey @mattfarina, any updates on this?

@mattfarina

Copy link
Copy Markdown
Member

@klnusbaum I've been traveling and then had a holiday weekend so I got a little behind. Need to figure out that bug so we can merge this.

@mattfarina
mattfarina merged commit 52f7192 into Masterminds:master Jun 2, 2016
@mattfarina

Copy link
Copy Markdown
Member

@klnusbaum I found the problem, fixed it, and merged into master. Thanks for the contribution.

@klnusbaum

Copy link
Copy Markdown
Contributor Author

awsome! Thanks @mattfarina !

@klnusbaum
klnusbaum deleted the check_basedir_symlink branch June 6, 2016 22:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants