Search code examples
ruby-on-railsrubyubuntugemfilesnap

keep getting this error "Your Ruby version is 3.0.2, but your Gemfile specified 3.2.2"


I have installed the latest release of ruby with "Sudo snap install ruby --classic" and i have confirmed with "which ruby" and "ruby -v" commands that the ruby exists and that the latest version ruby 3.2.2 also exists but whenever i tyried to run my rails app on the server i get this error "Your Ruby version is 3.0.2, but your Gemfile specified 3.2.2"


Solution

  • I think your Ruby version is changing to 3.0.2 when you navigate to your Rails application repository or folder, you can try the following steps to potentially resolve the problem:

    1. Install RVM (Ruby Version Manager).
    2. Check if your preferred Ruby version is already installed using the command "rvm list".
    3. If your Ruby version is not installed, install it by running the command "rvm install 3.2.2" (replace "3.2.2" with your desired version).
    4. Set the Ruby version to be used by running the command "rvm use 3.2.2".
    5. give "bundle i"

    OR

    1. Use the command "rvm --create --ruby-version 3.2.2" to create the .ruby-version file for automatic selection of the Ruby version.
    2. give "bundle install" command

    Note: delete Gemfile.lock file before giving bundle install