<p dir="auto">Doing a make in the kubernetes source tree produces this error when building with a system version of go:</p>
<p dir="auto">go install runtime: mkdir /usr/lib/golang/pkg/linux_amd64_cgo/: permission denied</p>
<p dir="auto">The build shouldn't be trying to install into system directories.  The error is traced is this line:</p>
<p dir="auto">'CGO_ENABLED=0 go install -installsuffix cgo "${goflags[@]:+${goflags[@]}}" -ldflags "${version_ldflags}" "${binary}"' exited with status 1</p>
<p dir="auto">Which seems to have come from commit <a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/kubernetes/kubernetes/commit/9a901ed46db225f588cc691feeb47e7ace92bbc8/hovercard" href="https://github.com/kubernetes/kubernetes/commit/9a901ed46db225f588cc691feeb47e7ace92bbc8"><tt>9a901ed</tt></a>.</p>
<p dir="auto">On my system (Fedora 21), I'm now unable to successfully build master. I get permission denied errors trying to write to <code class="notranslate">/usr/lib/golang/pkg/linux_amd64_cgo/</code>.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="$ ./hack/build-go.sh cmd/kube-apiserver
    cmd/kube-apiserver
go install runtime: mkdir /usr/lib/golang/pkg/linux_amd64_cgo/: permission denied
!!! Error in /home/vagrant/go/src/github.com/GoogleCloudPlatform/kubernetes/hack/lib/golang.sh:328
  'CGO_ENABLED=0 go install -installsuffix cgo &quot;${goflags[@]:+${goflags[@]}}&quot; -ldflags &quot;${version_ldflags}&quot; &quot;${binary}&quot;' exited with status 1
Call stack:
  1: /home/vagrant/go/src/github.com/GoogleCloudPlatform/kubernetes/hack/lib/golang.sh:328 kube::golang::build_binaries(...)
  2: ./hack/build-go.sh:26 main(...)
Exiting with status 1
!!! Error in /home/vagrant/go/src/github.com/GoogleCloudPlatform/kubernetes/hack/lib/golang.sh:252
  '( set -x; kube::golang::setup_env; local version_ldflags; version_ldflags=$(kube::version::ldflags); local host_platform; host_platform=$(kube::golang::host_platform); local goflags; eva
l &quot;goflags=(${KUBE_GOFLAGS:-})&quot;; local use_go_build; local -a targets=(); local arg; for arg in &quot;$@&quot;;
do
    if [[ &quot;${arg}&quot; == &quot;--use_go_build&quot; ]]; then
        use_go_build=true;
    else
        if [[ &quot;${arg}&quot; == -* ]]; then
            goflags+=(&quot;${arg}&quot;);
        else
            targets+=(&quot;${arg}&quot;);
        fi;
    fi;
done; if [[ ${#targets[@]} -eq 0 ]]; then
    targets=(&quot;${KUBE_ALL_TARGETS[@]}&quot;);
fi; local -a platforms=(&quot;${KUBE_BUILD_PLATFORMS[@]:+${KUBE_BUILD_PLATFORMS[@]}}&quot;); if [[ ${#platforms[@]} -eq 0 ]]; then
    platforms=(&quot;${host_platform}&quot;);
fi; local binaries; binaries=($(kube::golang::binaries_from_targets &quot;${targets[@]}&quot;)); local platform; for platform in &quot;${platforms[@]}&quot;;
do
    kube::golang::set_platform_envs &quot;${platform}&quot;; kube::log::status &quot;Building go targets for ${platform}:&quot; &quot;${targets[@]}&quot;; if [[ -n ${use_go_build:-} ]]; then
        local output_path=&quot;${KUBE_GOPATH}/bin&quot;; if [[ $platform != $host_platform ]]; then
            output_path=&quot;${output_path}/${platform//\//_}&quot;;
        fi; for binary in &quot;${binaries[@]}&quot;;
        do
            local bin=$(basename &quot;${binary}&quot;); if [[ ${GOOS} == &quot;windows&quot; ]]; then
                bin=&quot;${bin}.exe&quot;;
            fi; if kube::golang::is_statically_linked_library &quot;${binary}&quot;; then
                CGO_ENABLED=0 go build -installsuffix cgo -o &quot;${output_path}/${bin}&quot; &quot;${goflags[@]:+${goflags[@]}}&quot; -ldflags &quot;${version_ldflags}&quot; &quot;${binary}&quot;;
            else
                go build -o &quot;${output_path}/${bin}&quot; &quot;${goflags[@]:+${goflags[@]}}&quot; -ldflags &quot;${version_ldflags}&quot; &quot;${binary}&quot;;
            fi;
        done;
    else
        for binary in &quot;${binaries[@]}&quot;;
        do
            if kube::golang::is_statically_linked_library &quot;${binary}&quot;; then
                CGO_ENABLED=0 go install -installsuffix cgo &quot;${goflags[@]:+${goflags[@]}}&quot; -ldflags &quot;${version_ldflags}&quot; &quot;${binary}&quot;;
            else
                go install &quot;${goflags[@]:+${goflags[@]}}&quot; -ldflags &quot;${version_ldflags}&quot; &quot;${binary}&quot;;
            fi;
        done;
    fi;
done )' exited with status 1
Call stack:
  1: /home/vagrant/go/src/github.com/GoogleCloudPlatform/kubernetes/hack/lib/golang.sh:252 kube::golang::build_binaries(...)
  2: ./hack/build-go.sh:26 main(...)
Exiting with status 1"><pre class="notranslate"><code class="notranslate">$ ./hack/build-go.sh cmd/kube-apiserver
    cmd/kube-apiserver
go install runtime: mkdir /usr/lib/golang/pkg/linux_amd64_cgo/: permission denied
!!! Error in /home/vagrant/go/src/github.com/GoogleCloudPlatform/kubernetes/hack/lib/golang.sh:328
  'CGO_ENABLED=0 go install -installsuffix cgo "${goflags[@]:+${goflags[@]}}" -ldflags "${version_ldflags}" "${binary}"' exited with status 1
Call stack:
  1: /home/vagrant/go/src/github.com/GoogleCloudPlatform/kubernetes/hack/lib/golang.sh:328 kube::golang::build_binaries(...)
  2: ./hack/build-go.sh:26 main(...)
Exiting with status 1
!!! Error in /home/vagrant/go/src/github.com/GoogleCloudPlatform/kubernetes/hack/lib/golang.sh:252
  '( set -x; kube::golang::setup_env; local version_ldflags; version_ldflags=$(kube::version::ldflags); local host_platform; host_platform=$(kube::golang::host_platform); local goflags; eva
l "goflags=(${KUBE_GOFLAGS:-})"; 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 platform; for platform in "${platforms[@]}";
do
    kube::golang::set_platform_envs "${platform}"; kube::log::status "Building go targets for ${platform}:" "${targets[@]}"; if [[ -n ${use_go_build:-} ]]; then
        local output_path="${KUBE_GOPATH}/bin"; if [[ $platform != $host_platform ]]; then
            output_path="${output_path}/${platform//\//_}";
        fi; for binary in "${binaries[@]}";
        do
            local bin=$(basename "${binary}"); if [[ ${GOOS} == "windows" ]]; then
                bin="${bin}.exe";
            fi; if kube::golang::is_statically_linked_library "${binary}"; then
                CGO_ENABLED=0 go build -installsuffix cgo -o "${output_path}/${bin}" "${goflags[@]:+${goflags[@]}}" -ldflags "${version_ldflags}" "${binary}";
            else
                go build -o "${output_path}/${bin}" "${goflags[@]:+${goflags[@]}}" -ldflags "${version_ldflags}" "${binary}";
            fi;
        done;
    else
        for binary in "${binaries[@]}";
        do
            if kube::golang::is_statically_linked_library "${binary}"; then
                CGO_ENABLED=0 go install -installsuffix cgo "${goflags[@]:+${goflags[@]}}" -ldflags "${version_ldflags}" "${binary}";
            else
                go install "${goflags[@]:+${goflags[@]}}" -ldflags "${version_ldflags}" "${binary}";
            fi;
        done;
    fi;
done )' exited with status 1
Call stack:
  1: /home/vagrant/go/src/github.com/GoogleCloudPlatform/kubernetes/hack/lib/golang.sh:252 kube::golang::build_binaries(...)
  2: ./hack/build-go.sh:26 main(...)
Exiting with status 1
</code></pre></div>
<p dir="auto">It looks like this comes from <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="62540455" data-permission-text="Title is private" data-url="https://github.com/kubernetes/kubernetes/issues/5574" data-hovercard-type="pull_request" data-hovercard-url="/kubernetes/kubernetes/pull/5574/hovercard" href="https://github.com/kubernetes/kubernetes/pull/5574">#5574</a>. Could someone please take a look? Thanks!</p>