Trials
According to the fastlane setup guideline https://docs.fastlane.tools/getting-started/android/setup/, fastlane relies on the ruby + bundler but the system ruby is not recommended.
Thus, to install Ruby in another project scope instead of modifying the system environment, I tried install ruby 3.2.0 via rbenv and ruby-build.
However, it failed and the ruby version is different from the system installed one. I get the ruby version by executing
$ruby -v
ruby 2.6.10p210 (2022-04-12 revision 67958) [universal.arm64e-darwin22]
Solution
Another approach is to install the fastlane by Homebrew
It showed another error as below :
Error: Cannot install in Homebrew on ARM processor in Intel default prefix (/usr/local)!
Please create a new installation in /opt/homebrew using one of the
"Alternative Installs" from:
https://docs.brew.sh/Installation
You can migrate your previously installed formula list with:
brew bundle dump
Currently my homebrew is in
$which brew
/usr/local/bin/brew
As a result, the idea to solve this issue is reinstall the homebrew in /opt/homebrew
direction.
Step 1 : Install Homebrew for your MacOS
Running this command,
$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
followed by the steps in homebrew install guide
Step 2 : Set your default Homebrew to /opt/homebrew
I'm using zsh terminal, so just need to add a new eval config in your zsh config file.
$echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zshrc
You can see Homebrew path has been changed when reopen your zsh terminal.
$which brew
/opt/homebrew/bin/brew
Step 3 : Run brew install fastlane
$brew install fastlane
Fastlane works again!