How to fix "Your Ruby version is 3.0.6, but your Gemfile specified 2.6.10" running rake command?

54 views Asked by At

I would like to setup a project Ruby on Rails and when I run a rake command (example : rake db:setup), I get this error: Your Ruby version is 3.0.6, but your Gemfile specified 2.6.10

Howerver, the command rails s works.

I tried several solutions but nothing solved my issue. Can you help me please ?

My configs :

  • Macos with M chip.
  • Ruby version of project : 2.6.10 (installed with RVM)
  • Ruby version of homebrew : 3.0.6

Files of project : Gemfile and .ruby-version have good the version 2.6.10 so I don't understand.

Moreover, when I open a new terminal in my project, by default ruby -v is 3.0.6 so I run rvm use 2.6.10 each time. Do you know how to use 2.6.10 by default opening a new terminal in my project ?

My ~/.bash_profile :

[[ -s "$HOME/.profile" ]] && source "$HOME/.profile" # Load the default .profile

eval "$(/opt/homebrew/bin/brew shellenv)"
export PATH="/opt/homebrew/opt/node@14/bin:$PATH"

# Added by Toolbox App
export PATH="$PATH:/usr/local/bin"

export PATH="/opt/homebrew/opt/[email protected]/bin:$PATH"
export PATH="/opt/homebrew/opt/[email protected]/bin:$PATH"

export PATH="/opt/homebrew/opt/[email protected]/bin:$PATH"

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*

export PATH="$HOME/.rvm/gems/ruby-2.6.10/bin:$PATH"

My ~/.bashrc :

# Add RVM to PATH for scripting.
eval "$(rvm init -)"

# Add RVM to PATH for scripting. Make sure this is the last PATH variable change.
export PATH="$HOME/.rvm/gems/ruby-2.6.10/bin:$PATH"

# Add RVM to PATH for scripting. Make sure this is the last PATH variable change.
export PATH="$PATH:$HOME/.rvm/bin"

Gemfile .ruby-version

Thanks a lot.

I tried to use the command rvm use ruby 2.6.10. So, ruby -v is correct but I always get the error : Your Ruby version is 3.0.6, but your Gemfile specified 2.6.10

0

There are 0 answers