origin: Not working in macOS Monterey

[provide a description of the issue]

Version

oc version v3.10, v3.8 macOS mentorey 12.0.1

Steps To Reproduce
  1. Just run oc version and recieve this issue in screen short
Current Result
Screen Shot 2021-10-30 at 4 58 46 PM
Expected Result

oc version works well, and I can do my business job

Additional Information

[try to run $ oc adm diagnostics (or oadm diagnostics) command if possible] [if you are reporting issue related to builds, provide build logs with BUILD_LOGLEVEL=5] [consider attaching output of the $ oc get all -o json -n <namespace> command to the issue] [visit https://docs.openshift.org/latest/welcome/index.html]

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 2
  • Comments: 15 (6 by maintainers)

Most upvoted comments

https://github.com/golang/go/wiki/MacOS12BSDThreadRegisterIssue

I have a hacky “fix” which works for me. Im only using a tiny subset of functionality though (getting tokens for pushing images and a couple of info commands) so not sure if this makes the entire oc binary work.

Im also on an intel mac so not sure if this will work for arm. docker is used to build all the tools so you will need docker up and running too.

git clone https://github.com/openshift/origin.git
cd origin
git checkout v3.11.0

Then patch hack/lib/build/binaries.sh to comment out the go install command

diff --git a/hack/lib/build/binaries.sh b/hack/lib/build/binaries.sh
index 7a5cbb5eb3..3fa2a028c3 100644
--- a/hack/lib/build/binaries.sh
+++ b/hack/lib/build/binaries.sh
@@ -233,13 +233,13 @@ os::build::internal::build_binaries() {
       fi

       if [[ ${#nonstatics[@]} -gt 0 ]]; then
-        GOOS=${platform%/*} GOARCH=${platform##*/} go install \
-          -pkgdir "${pkgdir}/${platform}" \
-          -tags "${OS_GOFLAGS_TAGS-} ${!platform_gotags_envvar:-}" \
-          -ldflags="${local_ldflags}" \
-          "${goflags[@]:+${goflags[@]}}" \
-          -gcflags "${gogcflags}" \
-          "${nonstatics[@]}"
+        # GOOS=${platform%/*} GOARCH=${platform##*/} go install \
+        #   -pkgdir "${pkgdir}/${platform}" \
+        #   -tags "${OS_GOFLAGS_TAGS-} ${!platform_gotags_envvar:-}" \
+        #   -ldflags="${local_ldflags}" \
+        #   "${goflags[@]:+${goflags[@]}}" \
+        #   -gcflags "${gogcflags}" \
+        #   "${nonstatics[@]}"

         # GOBIN is not supported on cross-compile in Go 1.5+ - move to the correct target
         if [[ $platform != $host_platform ]]; then
OS_BUILD_ENV_GOLANG=1.11 OS_ONLY_BUILD_PLATFORMS=darwin ./hack/build-release.sh

This will build the binaries for mac and dump them in _output/local/bin/darwin/ARCH

❯ l _output/local/bin/darwin/amd64/
.rwxr-xr-x 206M lee 16 Nov 10:57 hyperkube
.rwxr-xr-x 260M lee 16 Nov 10:57 hypershift
.rwxr-xr-x 107M lee 16 Nov 10:57 kubectl
.rwxr-xr-x 2.1M lee 16 Nov 10:57 oadm
.rwxr-xr-x 107M lee 16 Nov 10:57 oc
.rwxr-xr-x 240M lee 16 Nov 10:57 openshift
.rwxr-xr-x  28M lee 16 Nov 10:57 openshift-node-config
.rwxr-xr-x  66M lee 16 Nov 10:57 template-service-broker
oc version
oc v3.11.0+0cbc58b
kubernetes v1.11.0+d4cacc0
features: Basic-Auth

Hope that helps!

Not exaclty a fix, but the version you can install with brew (openshift-cli) seems to work fine. I got the same error with this version.

@Themodem thanks for the workaround! After doing brew install go then following your steps, I now have an ‘oc’ binary that works.