Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build or install on Apple M1 #579

Closed
llaenowyd opened this issue Feb 24, 2021 · 8 comments
Closed

build or install on Apple M1 #579

llaenowyd opened this issue Feb 24, 2021 · 8 comments
Labels
bug Something isn't working

Comments

@llaenowyd
Copy link

Meta:

CircleCI CLI Version:
latest

Operating System:
BigSur

CircleCI CLI Diagnostic:
Following brew instructions:

Last 15 lines from /Users/collin/Library/Logs/Homebrew/circleci/01.make:
2021-02-21 10:03:26 -0500

make
pack

bash .circleci/pack.sh
make: *** [pack] Error 1

Following alternative installation method:

% curl -fLSs https://raw.githubusercontent.com/CircleCI-Public/circleci-cli/master/install.sh | bash
Starting installation.
Installing CircleCI CLI v0.1.14966
Installing to /Volumes/T7/bin/circleci
An error occured installing the tool.
The contents of the directory /var/folders/vx/zz3mf6ys7dl76ystc7jwqynm0000gn/T/tmp.iRcDaIbA have been left in place to help to debug the issue.

but

%file /var/folders/vx/zz3mf6ys7dl76ystc7jwqynm0000gn/T/tmp.iRcDaIbA/circleci
/var/folders/vx/zz3mf6ys7dl76ystc7jwqynm0000gn/T/tmp.iRcDaIbA/circleci: Mach-O 64-bit executable x86_64

and

% /var/folders/vx/zz3mf6ys7dl76ystc7jwqynm0000gn/T/tmp.iRcDaIbA/circleci version  
0.1.14966+1cd24ae (release)

Looks like a scripting problem in both cases TBH, possibly not directly due to the cpu arch?

@llaenowyd llaenowyd added the bug Something isn't working label Feb 24, 2021
@gmemstr
Copy link
Contributor

gmemstr commented Mar 11, 2021

@llaenowyd What does install --help return on your machine? I don't think this is related to the CPU arch, and judging by the output this is the last step it attempted before erroring out.

@llaenowyd
Copy link
Author

llaenowyd commented Mar 11, 2021

That's clarifying - if it's intended to be run with elevated privilege, I didn't realize.

% bash ./install.sh --help
Starting installation.
Installing CircleCI CLI v0.1.15108
Installing to /usr/local/bin
install: /usr/local/bin: Permission denied
An error occured installing the tool.
The contents of the directory /var/folders/vx/zz3mf6ys7dl76ystc7jwqynm0000gn/T/tmp.2QIiGC4J have been left in place to help to debug the issue.

and

% ls /usr/local/bin/
ls: /usr/local/bin/: No such file or directory

@gmemstr
Copy link
Contributor

gmemstr commented Mar 11, 2021

@llaenowyd My bad - install is a command run within the install script to move the files to the correct place, which I believe is built-in to macOS. We do note the requirement for elevated privs here: https://github.com/CircleCI-Public/circleci-cli#install-script

Unfortunately, I don't know for sure why the brew step is failing -- I don't currently have a mac to test it with.

@llaenowyd
Copy link
Author

Oh I did not know that, ok. I'm discovering that homebrew introduces more variables with arm64 support - somewhat averse to using it until there's an "all good for m1" announcement, and as of now, nothing is installed with it:

% brew list
%
% install --help
install: illegal option -- -
usage: install [-bCcpSsv] [-B suffix] [-f flags] [-g group] [-m mode]
               [-o owner] file1 file2
       install [-bCcpSsv] [-B suffix] [-f flags] [-g group] [-m mode]
               [-o owner] file1 ... fileN directory
       install -d [-v] [-g group] [-m mode] [-o owner] directory ...
% file `which install`
/usr/bin/install: Mach-O universal binary with 2 architectures: [x86_64:Mach-O 64-bit executable x86_64] [arm64e:Mach-O 64-bit executable arm64e]
/usr/bin/install (for architecture x86_64):	Mach-O 64-bit executable x86_64
/usr/bin/install (for architecture arm64e):	Mach-O 64-bit executable arm64e

@fkztw
Copy link

fkztw commented May 25, 2021

Encountered this same problem on MacBook with M1 chip.
I can confirm that sudo bash ./install.sh did successfully install circleci with Mach-O x86_64 binary format for me and it works on my MacBook with M1 chip.

$ file /usr/local/bin/circleci
/usr/local/bin/circleci: Mach-O 64-bit executable x86_64

The reason why brew install circleci failed is that no pre-compiled bottle could be found.
(Check this PR which is labeled with no ARM bottle: Homebrew/homebrew-core#76657)

Follow the suggestion in error message and use brew install --build-from-source circleci to install circleci still got the error below:

2021-05-25 23:37:25 +0800

make
pack

bash .circleci/pack.sh
make: *** [pack] Error 1

After tracing the source code, I think the problem is that Homebrew Formula use make pack before building the binary: https://github.com/Homebrew/homebrew-core/blob/70c30cc5a55029f0c5d774e314005cd68a370030/Formula/circleci.rb#L32
which execute bash .circleci/pack.sh
Take a look at .circleci/pack.sh:

function get_arch_type() {
if [[ $(uname -m) == "i686" ]]; then
echo "386"
elif [[ $(uname -m) == "x86_64" ]]; then
echo "amd64"
fi
}
function get_arch_base() {
if [[ "$OSTYPE" == "linux-gnu" ]]; then
echo "linux"
elif [[ "$OSTYPE" == "darwin"* ]]; then
echo "darwin"
fi
}
ARCH="$(get_arch_base)_$(get_arch_type)"
CMD="bin/$ARCH/packr2"

The values of uname -a and $OSTYPE for my MacBook with M1 chip:

$ uname -m
arm64

$ echo $OSTYPE
darwin20.0

This make the value of CMD become bin/darwin_/packr2 which causes the problem.

@nandahkrishna
Copy link

nandahkrishna commented Jun 11, 2021

Hello, Homebrew maintainer here. When Homebrew/homebrew-core#79094 is merged, CircleCI CLI will be bottled (available via binary package) on ARM. We prefer using Homebrew formulae over vendored dependencies and in this case, that seemed to be the solution to getting CircleCI CLI built on M1.

I had some issues getting packr to work as intended and finally did manage to, but I thought I'd ask here if you'd be willing to move away from packr. The project doesn't seem to be actively maintained and there's a note in the README pointing to a replacement (see: README, gobuffalo/packr#252 and gobuffalo/packr#253).

Thanks!

@kelvintaywl
Copy link
Contributor

kelvintaywl commented Sep 6, 2021

hello @llaenowyd , did you have any luck recently on this? 🤓

I just wanted to mention that I am now able to install the CircleCI CLI via homebrew on Apple M1 successfully.

➜  ~ brew install circleci
==> Homebrew is run entirely by unpaid volunteers. Please consider donating:
  https://github.com/Homebrew/brew#donations
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
==> Updated Formulae
Updated 1 formula.

==> Downloading https://ghcr.io/v2/homebrew/core/circleci/manifests/0.1.15932
Already downloaded: /Users/kelvin/Library/Caches/Homebrew/downloads/317ae4b4bacac9e9eb695531554cf923068b178cd728f2dc3a11eab426776215--circleci-0.1.15932.bottle_manifest.json
==> Downloading https://ghcr.io/v2/homebrew/core/circleci/blobs/sha256:28b702cac
Already downloaded: /Users/kelvin/Library/Caches/Homebrew/downloads/42e9e1378ee3eabea6d2649d4c9d9eff255c8cc85b2a0f465fafe6fe329828df--circleci--0.1.15932.arm64_big_sur.bottle.tar.gz
==> Pouring circleci--0.1.15932.arm64_big_sur.bottle.tar.gz
==> Caveats
zsh completions have been installed to:
  /opt/homebrew/share/zsh/site-functions
==> Summary
🍺  /opt/homebrew/Cellar/circleci/0.1.15932: 7 files, 14.2MB


➜  ~ circleci version

0.1.15932+3471602 (homebrew)

Screen Shot 2021-09-06 at 18 06 12

@abdelDriowya
Copy link
Contributor

Closing as there's no answer from OP

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants