Skip to content

Instantly share code, notes, and snippets.

@adnissen
Created January 14, 2014 20:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adnissen/8424683 to your computer and use it in GitHub Desktop.
Save adnissen/8424683 to your computer and use it in GitHub Desktop.
# this code doesn't work:
def install
# override any environmental vars, set our gopath to one we know will work
build_directory = buildpath/"build"
build_directory.mkpath
ENV["GOPATH"] = build_directory
system "echo", ENV["GOPATH"]
system "cd " + build_directory
system "go", "build", "-o", "hugo", "main.go"
bin.install 'hugo'
end
#error
main.go:17:2: cannot find package "github.com/spf13/hugo/commands" in any of:
/usr/local/Cellar/go/1.2/libexec/src/pkg/github.com/spf13/hugo/commands (from $GOROOT)
/private/tmp/hugo-mW6N/hugo-0.9/build/src/github.com/spf13/hugo/commands (from $GOPATH)
#ok, so I would assume it's just downloading to the wrong directory or something
#but this code works:
# override any environmental vars, set our gopath to one we know will work
+ ENV["GOPATH"] = "#{HOMEBREW_PREFIX}/var/go/gopath"
+
+ system "go get github.com/spf13/hugo"
+ system "cd #{HOMEBREW_PREFIX}/var/go/gopath"
+ system "go build -o hugo main.go"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment