Ckt22
Ckt22

Reputation: 191

Rails and Ruby versions always conflict, and will never be able to bundle install

I git cloned my own repo, when I want to start (rails s), there will be a request to install Rails (sudo apt install ruby-railties), even though I installed it. If I start the installation (gem install rails), there will be a message that the Ruby version is too old:

ERROR: Error installing rails:
        There are no versions of activesupport (= 7.0.0) compatible with your Ruby & RubyGems. Maybe try installing an older version of the gem you're looking for?
        activesupport requires Ruby version >= 2.7.0. The current ruby ​​version is 2.6.6.146.

If I switch to the requested version (rvm use 2.7), the following message will appear when I run rails s:

Could not find proper version of railties (6.1.4.1) in any of the sources
Run `bundle install` to install missing gems.

When I proceed to bundle install, there will be a need to switch the Ruby version:

Your Ruby version is 2.7.2, but your Gemfile specified 2.6.6

This is equivalent to going back to the beginning. This stupid loop prevented me from completing the bundle install and thus rails s.

Upvotes: 4

Views: 18895

Answers (3)

chriss.py chicken
chriss.py chicken

Reputation: 49

It worked for me when I updated my Ruby version to the latest 3.2.2, the latest available (presently). Use "rbenv install --l" to check for the latest version.

brew install rbenv ruby-build 
rbenv init
eval "$(rbenv init - zsh)"  
rbenv install --l 
rbenv install 3.2.2
rbenv global 3.2.2

Upvotes: 3

YerkoBits
YerkoBits

Reputation: 46

Setup the environment inside your project folder.

cd yourproject

Then install Ruby, Rails and Bundler.


Install Ruby v2.7.0, through Ruby Version Manager (RVM) https://rvm.io/

gpg2 --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB

\curl -sSL https://get.rvm.io | bash -s stable

source /etc/profile.d/rvm.sh

rvm install ruby 2.7.0
rvm use 2.7.0
rvm list

Install Rails, through RubyGems https://rubygems.org

(don't use apt install ruby-railties )

gem install rails
rails --version

(re)Install Bundler

gem install bundler

bundle install

Upvotes: 2

Babatunde Mustapha
Babatunde Mustapha

Reputation: 2663

Regarding the pg error, you need to change your 'pg' gem to a lower version. Let us see what you have in your gemfile.

Upvotes: 1

Related Questions