Home > OS >  Your Ruby version is 3.1.2, but your Gemfile specified 2.6.8
Your Ruby version is 3.1.2, but your Gemfile specified 2.6.8

Time:10-20

I'm getting this error message when I try to do a pod install on Mac on a Turbo Module in React Native. I believe it's because of my version of Xcode installed.

> RCT_NEW_ARCH_ENABLED=1 bundle exec pod install
Your Ruby version is 3.1.2, but your Gemfile specified 2.6.8

When I run ruby -v it returns 2.6.8.

> ruby -v
ruby 2.6.8p205 (2021-07-07 revision 67951) [universal.arm64e-darwin21]

I'm not sure what to do to fix this or where it's finding 3.1.2.

CodePudding user response:

2.6.8 is the builtin ruby in macOS Monterey, which can be found at /usr/bin/ruby. If bundle is finding 3.1.2 then you have another version of ruby installed (possibly via homebrew?). You can see all versions of ruby on your current PATH using the command which -a. The order of results is the order in which they are found on the PATH, as you can confirm by typing echo $PATH. Execution is on a first-come-first-served basis. On my machine the which command produces:

% which -a ruby
/opt/homebrew/opt/ruby/bin/ruby
/usr/bin/ruby

showing that I have a homebrew copy of ruby first on my PATH, followed by the macOS copy.

Similarly, you can check which installation of bundle is being used:

% which -a bundle
/opt/homebrew/opt/ruby/bin/bundle
/opt/homebrew/lib/ruby/gems/3.1.0/bin/bundle
/usr/bin/bundle

You can override the PATH ordering by editing .zshrc (long-term change); by explicitly setting it to a new set of path values in the current terminal (one-time change for the active terminal window); or by typing the fully qualified path name of the version of the command you wish to run (ex: /usr/bin/bundle ... to use the system version).

  • Related