drblhw5731
2015-12-04 03:45
浏览 145

kubernetes在ubuntu中找不到正确的路径

My OS is ubuntu 14.04.3 Server, and I want to build kubernetes.

Firstly, I use "apt-get" command install Golang, but the version is 1.2.1, so I use apt-get --purge autoremove command to remove it.And install the newest 1.5.1 from golang website.

But executing make command, it seems kubernetes always "think" current golang is 1.2.1:

$ make
hack/build-go.sh
+++ [1203 06:20:30] Building go targets for linux/amd64:
    cmd/kube-proxy
    cmd/kube-apiserver
    cmd/kube-controller-manager
    cmd/kubelet
    cmd/kubemark
    cmd/hyperkube
    cmd/linkcheck
    plugin/cmd/kube-scheduler
    cmd/kubectl
    cmd/integration
    cmd/gendocs
    cmd/genkubedocs
    cmd/genman
    cmd/mungedocs
    cmd/genbashcomp
    cmd/genconversion
    cmd/gendeepcopy
    cmd/genswaggertypedocs
    examples/k8petstore/web-server/src
    github.com/onsi/ginkgo/ginkgo
    test/e2e/e2e.test
+++ [1203 06:20:30] +++ Warning: stdlib pkg with cgo flag not found.
+++ [1203 06:20:30] +++ Warning: stdlib pkg cannot be rebuilt since /usr/local/go/pkg is not writable by nan
+++ [1203 06:20:30] +++ Warning: Make /usr/local/go/pkg writable for nan for a one-time stdlib install, Or
+++ [1203 06:20:30] +++ Warning: Rebuild stdlib using the command 'CGO_ENABLED=0 go install -a -installsuffix cgo std'
+++ [1203 06:20:30] +++ Falling back to go build, which is slower
    # k8s.io/kubernetes/pkg/util/yaml
_output/local/go/src/k8s.io/kubernetes/pkg/util/yaml/decoder.go:26: import /home/nan/kubernetes/Godeps/_workspace/pkg/linux_amd64/github.com/ghodss/yaml.a: object is [linux amd64 go1.2.1 X:none] expected [linux amd64 go1.5.1 X:none]
# k8s.io/kubernetes/pkg/util/validation
_output/local/go/src/k8s.io/kubernetes/pkg/util/validation/errors.go:23: import /home/nan/kubernetes/_output/local/go/pkg/linux_amd64/k8s.io/kubernetes/pkg/util/errors.a: object is [linux amd64 go1.2.1 X:none] expected [linux amd64 go1.5.1 X:none]
# k8s.io/kubernetes/pkg/api/resource
_output/local/go/src/k8s.io/kubernetes/pkg/api/resource/quantity.go:27: import /home/nan/kubernetes/Godeps/_workspace/pkg/linux_amd64/speter.net/go/exp/math/dec/inf.a: object is [linux amd64 go1.2.1 X:none] expected [linux amd64 go1.5.1 X:none]
# github.com/spf13/cobra
Godeps/_workspace/src/github.com/spf13/cobra/command.go:27: import /home/nan/kubernetes/Godeps/_workspace/pkg/linux_amd64/github.com/inconshreveable/mousetrap.a: object is [linux amd64 go1.2.1 X:none] expected [linux amd64 go1.5.1 X:none]
# k8s.io/kubernetes/pkg/util/iptables
_output/local/go/src/k8s.io/kubernetes/pkg/util/iptables/iptables.go:27: import /home/nan/kubernetes/Godeps/_workspace/pkg/linux_amd64/github.com/coreos/go-semver/semver.a: object is [linux amd64 go1.2.1 X:none] expected [linux amd64 go1.5.1 X:none]
# github.com/prometheus/common/expfmt
Godeps/_workspace/src/github.com/prometheus/common/expfmt/decode.go:23: import /home/nan/kubernetes/Godeps/_workspace/pkg/linux_amd64/github.com/prometheus/client_model/go.a: object is [linux amd64 go1.2.1 X:none] expected [linux amd64 go1.5.1 X:none]
# github.com/emicklei/go-restful
Godeps/_workspace/src/github.com/emicklei/go-restful/container.go:16: import /home/nan/kubernetes/Godeps/_workspace/pkg/linux_amd64/github.com/emicklei/go-restful/log.a: object is [linux amd64 go1.2.1 X:none] expected [linux amd64 go1.5.1 X:none]
!!! Error in /home/nan/kubernetes/hack/lib/golang.sh:376
  'CGO_ENABLED=0 go build -o "${outfile}" "${goflags[@]:+${goflags[@]}}" -ldflags "${goldflags}" "${binary}"' exited with status 2
Call stack:
  1: /home/nan/kubernetes/hack/lib/golang.sh:376 kube::golang::build_binaries_for_platform(...)
  2: /home/nan/kubernetes/hack/lib/golang.sh:535 kube::golang::build_binaries(...)
  3: hack/build-go.sh:26 main(...)
Exiting with status 1
!!! Error in /home/nan/kubernetes/hack/lib/golang.sh:456
  '( kube::golang::setup_env; local host_platform; host_platform=$(kube::golang::host_platform); local goflags goldflags; eval "goflags=(${KUBE_GOFLAGS:-})"; goldflags="${KUBE_GOLDFLAGS:-} $(kube::version::ldflags)"; local use_go_build; local -a targets=(); local arg; for arg in "$@";
do
    if [[ "${arg}" == "--use_go_build" ]]; then
        use_go_build=true;
    else
        if [[ "${arg}" == -* ]]; then
            goflags+=("${arg}");
        else
            targets+=("${arg}");
        fi;
    fi;
done; if [[ ${#targets[@]} -eq 0 ]]; then
    targets=("${KUBE_ALL_TARGETS[@]}");
fi; local -a platforms=("${KUBE_BUILD_PLATFORMS[@]:+${KUBE_BUILD_PLATFORMS[@]}}"); if [[ ${#platforms[@]} -eq 0 ]]; then
    platforms=("${host_platform}");
fi; local binaries; binaries=($(kube::golang::binaries_from_targets "${targets[@]}")); local parallel=false; if [[ ${#platforms[@]} -gt 1 ]]; then
    local gigs; gigs=$(kube::golang::get_physmem); if [[ ${gigs} -ge ${KUBE_PARALLEL_BUILD_MEMORY} ]]; then
        kube::log::status "Multiple platforms requested and available ${gigs}G >= threshold ${KUBE_PARALLEL_BUILD_MEMORY}G, building platforms in parallel"; parallel=true;
    else
        kube::log::status "Multiple platforms requested, but available ${gigs}G < threshold ${KUBE_PARALLEL_BUILD_MEMORY}G, building platforms in serial"; parallel=false;
    fi;
fi; if [[ "${parallel}" == "true" ]]; then
    kube::log::status "Building go targets for ${platforms[@]} in parallel (output will appear in a burst when complete):" "${targets[@]}"; local platform; for platform in "${platforms[@]}";
    do
        ( kube::golang::set_platform_envs "${platform}"; kube::log::status "${platform}: go build started"; kube::golang::build_binaries_for_platform ${platform} ${use_go_build:-}; kube::log::status "${platform}: go build finished" ) &> "/tmp//${platform//\//_}.build" &
    done; local fails=0; for job in $(jobs -p);
    do
        wait ${job} || let "fails+=1";
    done; for platform in "${platforms[@]}";
    do
        cat "/tmp//${platform//\//_}.build";
    done; exit ${fails};
else
    for platform in "${platforms[@]}";
    do
        kube::log::status "Building go targets for ${platform}:" "${targets[@]}"; kube::golang::set_platform_envs "${platform}"; kube::golang::build_binaries_for_platform ${platform} ${use_go_build:-};
    done;
fi )' exited with status 1
Call stack:
  1: /home/nan/kubernetes/hack/lib/golang.sh:456 kube::golang::build_binaries(...)
  2: hack/build-go.sh:26 main(...)
Exiting with status 1
make: *** [all] Error 1

But the go in "PATH" is 1.5.1:

$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/usr/local/go/bin
$ which go
/usr/local/go/bin/go
$ go version
go version go1.5.1 linux/amd64

So how can I fix this issue?

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • du42561 2015-12-04 05:28
    已采纳

    As explained in "How can you completely remove a package?", a sudo apt-get --purge autoremove might have removed go completely.
    But that doesn't mean it has cleaned what was compiled before

    Make sure that /home/nan/kubernetes/Godeps/_workspace and /home/nan/kubernetes/_output are deleted after a make clean (See issue 16771).
    Make sure /usr/local/go/pkg is writable for the user nan. (See hack/lib/golang.sh)

    Finally, issue 16229 mentions:

    Would be nice to at least update the docs to indicate that you can't use go>1.4.

    So try and install go 1.4.x only.

    Update: the OP Nan Xiao reports in the comments having managed to build it with go 1.5.1 or 1.5.2 without any more issue.

    已采纳该答案
    打赏 评论

相关推荐 更多相似问题