gohugoio / hugo

The world’s fastest framework for building websites.
https://gohugo.io
Apache License 2.0
74.81k stars 7.46k forks source link

When I try to $ go get, I got error "imports runtime/pprof: unrecognized import path "runtime/pprof" " #795

Closed sotayamashita closed 9 years ago

sotayamashita commented 9 years ago

When I try to go get, I got a error below:

imports runtime/pprof: unrecognized import path "runtime/pprof"

Is there any solution?

Thanks in advance

tatsushid commented 9 years ago

runtime/pprof is a Go's standard package so I guess something inconsistency happens in your environment. Please check GOROOT and GOPATH environment values refer the directories you expect

fbartho commented 9 years ago

I'm having the same problem.

anthonyfok commented 9 years ago

I don't think this is a Hugo issue, as runtime/pprof is supposed to be part of Go core.

go get runs perfectly on my Debian GNU/Linux system, with the golang, golang-src etc. packages that are part of the official Debian repository. While I don't have brew, if I were to do this:

mv /usr/share/go/src/pkg/runtime/pprof /usr/share/go/src/pkg/runtime/pprof-bye

then I would see the very same error:

$ go get -v github.com/spf13/hugo
import "runtime/pprof": import path doesn't contain a hostname
package runtime/pprof: unrecognized import path "runtime/pprof"

or, with the -u flag:

$ go get -v -u github.com/spf13/hugo
github.com/spf13/hugo (download)
bitbucket.org/kardianos/osext (download)
bitbucket.org/pkg/inflect (download)
github.com/BurntSushi/toml (download)
github.com/PuerkitoBio/purell (download)
github.com/armon/consul-api (download)
github.com/coreos/go-etcd (download)
github.com/dchest/cssmin (download)
github.com/eknkc/amber (download)
github.com/gorilla/websocket (download)
github.com/kr/pretty (download)
github.com/kr/text (download)
github.com/mitchellh/mapstructure (download)
github.com/russross/blackfriday (download)
github.com/shurcooL/sanitized_anchor_name (download)
github.com/spf13/afero (download)
github.com/spf13/cast (download)
github.com/spf13/jwalterweatherman (download)
github.com/spf13/cobra (download)
github.com/spf13/pflag (download)
github.com/spf13/fsync (download)
github.com/spf13/viper (download)
github.com/xordataexchange/crypt (download)
golang.org/x/crypto (download)
gopkg.in/yaml.v1 (download)
github.com/yosssi/ace (download)
github.com/spf13/nitro (download)
gopkg.in/fsnotify.v0 (download)
import "runtime/pprof": import path doesn't contain a hostname
package github.com/spf13/hugo
    imports bitbucket.org/kardianos/osext
    imports bitbucket.org/pkg/inflect
    imports github.com/BurntSushi/toml
    imports github.com/PuerkitoBio/purell
    imports github.com/armon/consul-api
    imports github.com/coreos/go-etcd/etcd
    imports github.com/dchest/cssmin
    imports github.com/eknkc/amber
    imports github.com/eknkc/amber/parser
    imports github.com/gorilla/websocket
    imports github.com/kr/pretty
    imports github.com/kr/text
    imports github.com/mitchellh/mapstructure
    imports github.com/russross/blackfriday
    imports github.com/shurcooL/sanitized_anchor_name
    imports github.com/spf13/afero
    imports github.com/spf13/cast
    imports github.com/spf13/jwalterweatherman
    imports github.com/spf13/cobra
    imports github.com/spf13/pflag
    imports github.com/spf13/fsync
    imports github.com/spf13/hugo/commands
    imports github.com/spf13/hugo/create
    imports github.com/spf13/hugo/helpers
    imports github.com/spf13/viper
    imports github.com/xordataexchange/crypt/backend
    imports github.com/xordataexchange/crypt/backend/consul
    imports github.com/xordataexchange/crypt/backend/etcd
    imports github.com/xordataexchange/crypt/config
    imports github.com/xordataexchange/crypt/encoding/secconf
    imports golang.org/x/crypto/cast5
    imports golang.org/x/crypto/openpgp
    imports golang.org/x/crypto/openpgp/armor
    imports golang.org/x/crypto/openpgp/errors
    imports golang.org/x/crypto/openpgp/elgamal
    imports golang.org/x/crypto/openpgp/packet
    imports golang.org/x/crypto/openpgp/s2k
    imports gopkg.in/yaml.v1
    imports github.com/spf13/hugo/hugofs
    imports github.com/spf13/hugo/hugolib
    imports github.com/spf13/hugo/parser
    imports github.com/spf13/hugo/source
    imports github.com/spf13/hugo/target
    imports github.com/spf13/hugo/tpl
    imports github.com/yosssi/ace
    imports github.com/spf13/hugo/transform
    imports github.com/spf13/nitro
    imports github.com/spf13/hugo/livereload
    imports github.com/spf13/hugo/utils
    imports github.com/spf13/hugo/watcher
    imports gopkg.in/fsnotify.v0
    imports runtime/pprof: unrecognized import path "runtime/pprof"

Perhaps something is missing in the Go installation? How about trying this?

$ brew uninstall go
$ brew install go
sotayamashita commented 9 years ago

@tatsushid Thank you. I solved this problem to set $GOPATH and $GOROOT.

@anthonyfok You right. In my case, it is not hugo problem.

I'm having the same problem.

@fbartho You should check your whether your $GOROOT and $GOPATH are work or not and You should read below comment by @tatsushid .

runtime/pprof is a Go's standard package so I guess something inconsistency happens in your environment. Please check GOROOT and GOPATH environment values refer the directories you expect

I also asked this issue on Homebrew/homebrew.I close it too.

fbartho commented 9 years ago

I have the following:

$  echo $GOROOT
/usr/local/go
$  echo $GOPATH
/Users/fbarthelemy/Code/gopath
$  ls -al /usr/local/go
lrwxr-xr-x  1 root  admin  27 Sep 30 12:28 /usr/local/go -> /Users/fbarthelemy/Code/go/
$  go version
go version go1.4 darwin/amd64

@sota0805 / @tatsushid Any recommendations on what I should try next? My other go code works fine, it's simply when I try to brew install hugo that things don't work.

anthonyfok commented 9 years ago

Hi @fbartho,

How about this?

$ export GOROOT=/Users/fbarthelemy/Code/go

I read somewhere that Go does not like symlinks when linked the wrong way around. (I don't know which way is the right way, but I definitely won't set $GOROOT to a symlink.)

Also, check and see if the directory $GOROOT/src/pkg/runtime/pprof/, i.e. /Users/fbarthelemy/Code/go/src/pkg/runtime/pprof/, exists, and if it contains these two files:

Hope this helps!

fbartho commented 9 years ago

tl;dr: This worked. Thanks @anthonyfok, @sota0805!

I noticed that there was 2 go's installed on the system, it looks like when I installed hugo, it first installed it's own copy of go (failing to detect mine?), anyhow, I cleaned up my custom go, and reinstalled cleanly via homebrew, then had to fight to setup GOROOT correctly.

# When installing go via homebrew, setting up goroot appears to be a pain!
GOVERSION=$(brew list go | head -n 1 | cut -d '/' -f 6)
export GOROOT=$(brew --prefix)/Cellar/go/$GOVERSION/libexec
export PATH=$PATH:$GOROOT/bin:
github-actions[bot] commented 2 years ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.