'Xcode is using ruby 2.7 but terminal version shows 2.6
I want to apologise in advance if I write somethings that are not accurate enough as I may lack of knowledge.
I am working on a new Mac Mini M1 machine and I am using Xcode 12.2.1 on Monterrey. During the environment setup, I installed homebrew and I may (not sure) also installed ruby.
The Xcode project that I am trying to build has a build phase executing a ruby file and I see the following error:
When using my terminal, if I run which ruby and which -a ruby I see the following output.
But when I run ruby -v I see:
and when I run gem env
At this point I am confused
- Which version is the system version and which one is the homebrew (If any)
- Do I have 2 versions of ruby installed?
- Why Xcode and which returns 2.7 but ruby --version returns 2.6
Solution 1:[1]
Thanks to Matt's article, I was able to figure out that:
- /System/Library/Frameworks/Ruby.framework is the folder where the one provided by apple is located.
- Homebrew installs rbenv which is used to manage ruby versions
- If I run rbenv versions then I get which versions of ruby are installed.
Then from here I follow the steps to select a new ruby version:
% rbenv global 2.7.3
% rbenv rehash
% rbenv init
% cd
% echo 'eval "$(rbenv init -)"' >> .zshrc
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | matt |





