Added new check on create. Addresses issue #3.
diff --git a/cmd/in_gopath.go b/cmd/in_gopath.go new file mode 100644 index 0000000..f06e118 --- /dev/null +++ b/cmd/in_gopath.go
@@ -0,0 +1,33 @@ +package cmd + +import ( + "github.com/Masterminds/cookoo" + + "path/filepath" + "fmt" + "os" +) + +func InGopath(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt) { + // Get current dir + cwd, err := os.Getwd() + if err != nil { + return false, err + } + // Get GOPATH + gopath, err := filepath.Abs(os.Getenv("GOPATH")) + if err != nil { + return false, err + } + + // Check that they are equal. + if cwd != gopath { + Error("For Glide to create a managed _vendor directory, you must set your GOPATH to %s.\n", cwd) + Info("You can use `glide in` to set GOPATH for you.\n") + Info("If you are using an external GOPATH, skip to `glide update`.\n") + return false, fmt.Errorf("GOPATH is %s, but current directory is %s", gopath, cwd) + } + + + return true, nil +}
diff --git a/glide.go b/glide.go index 322c619..a53a71e 100644 --- a/glide.go +++ b/glide.go
@@ -172,6 +172,7 @@ Does(cmd.Out, "gopath") reg.Route("install", "Install dependencies."). + Does(cmd.InGopath, "pathIsRight"). Includes("@ready"). Does(cmd.Mkdir, "dir").Using("dir").WithDefault("_vendor"). Does(cmd.LinkPackage, "alias").