Issues after upgrading to Ruby 2.5.1 - "Incompatible library version" - ruby-on-rails

After using Homebrew to upgrade to Ruby 2.5.1, I am having issues creating my database in pg.
When I run rake db:create for the first time, the rake is aborted with an error like:
rake db:create
rake aborted!
LoadError: incompatible library version - /Users/jp/.rvm/gems/ruby-2.5.1/gems/bootsnap-1.3.0/lib/bootsnap/bootsnap.bundle
/Users/jp/.rvm/gems/ruby-2.5.1/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require'
/Users/jp/.rvm/gems/ruby-2.5.1/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `block in require_with_bootsnap_lfi'
/Users/jp/.rvm/gems/ruby-2.5.1/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/loaded_features_index.rb:65:in `register'
I've confirmed that I have that version of Ruby running:
ruby -v
ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin17]
I've also checked my Gemfile, and I have a recent Rails version installed (rails (5.2.0)).
Have not found any similar issues on Stack Overflow or elsewhere. Any idea where to begin with this one?

I just spend several hours on a very similar error, after upgrading a Ruby app from ruby 2.4 to 2.6. I'm using rbenv and bundler on MacOS Mojave.
I uninstalled about a dozen old versions of ruby and started clean. This got me past the exact error in the question.
This may be overkill, but it worked for me:
List all installed ruby versions:
rbenv versions
Uninstall all versions of Ruby.
rbenv uninstall 2.1
rbenv uninstall 2.1.9
etc.
Install needed version(s) of Ruby
rbenv install
bundle install
I tried running my app after bundle install and got dozens of warnings like these:
Ignoring binding_of_caller-0.8.0 because its extensions are not built. Try: gem pristine binding_of_caller --version 0.8.0
Ignoring binding_of_caller-0.7.2 because its extensions are not built. Try: gem pristine binding_of_caller --version 0.7.2
Ignoring bootsnap-1.4.6 because its extensions are not built. Try: gem pristine bootsnap --version 1.4.6
At that time, I could not run bundle exec rake
% bundle exec rake
bundler: command not found: rake
Install missing gem executables with `bundle install`
Running bundle appeared successful, but did not update Gemfile.lock, and did not fix the problem.
Finally, restoring all the gems to pristine solved the problem:
gem pristine --all
I could now run the app, rake, etc.

This may be a pg gem version problem. Use gem 'pg', '~> 0.21.0' in your Gemfile then do the bundle install. This will resolve.

Related

Rspec and gem errors despite having needed programs

Unfortunately, an unexpected error occurred, and Bundler cannot continue.
First, try this link to see if there are any existing issue reports for this error:
https://github.com/rubygems/rubygems/search?q=wrong+number+of+arguments+%28given+4%2C+expected+1%29&type=Issues
If there aren't any reports for this error yet, please fill in the new issue form located at https://github.com/rubygems/rubygems/issues/new?labels=Bundler&template=bundler-related-issue.md, and copy and paste the report template above in there.
I try to run 'bundle install' and I get this error. I am trying to run specs for a school project testing me on Ruby on Rails associations among other things. The project uses pSQL, Ruby and RoR. I am able to run 'bundle install && ./setup_db.sh' in the active_record_queries folder but not in the associations folder for that is where I receive the above comment. When I run just 'bundle install' I receive: Your RubyGems version (2.7.6)) has a bug that prevents required_ruby_version from working for Bundler. Any scripts that use gem install bundler will break as soon as Bundler drops support for your Ruby version. Please upgrade RubyGems to avoid future breakage and silence this warning by running gem update --system 3.2.3
I also need to run ./setup_db.sh after as stated in the read me.
Why am I getting this error message?
/rails1_practice
├── README.md (<- you are here)
├── active_record_queries
| └── README.md
├── associations
| └── README.md
├── migrations
| └── README.md
├── sql
| └── README.md
ace#ace-ThinkPad-T460:/$ rake about rake aborted! No Rakefile found
(looking for: rakefile, Rakefile, rakefile.rb, Rakefile.rb)
ace#ace-ThinkPad-T460:/$ rake about rake aborted! No Rakefile found
(looking for: rakefile, Rakefile, rakefile.rb, Rakefile.rb)
(See full trace by running task with --trace) ace#ace-ThinkPad-T460:/$
rails -v Rails 7.0.2.2 ace#ace-ThinkPad-T460:/$ ruby -v ruby 3.1.1p18
(2022-02-18 revision 53f5fc4236) [x86_64-linux]
ace#ace-ThinkPad-T460:/$ rbenv -v rbenv 1.2.0-11-ge4f61e6
ace#ace-ThinkPad-T460:/$ gem -v
3.3.7
'''
ace#ace-ThinkPad-T460:~/Desktop/codes/exactly!/rails1-practice/associations$ ./setup_db.sh
Your RubyGems version (2.7.6)) has a bug that prevents required_ruby_version from working for Bundler. Any scripts that use gem install bundler will break as soon as Bundler drops support for your Ruby version. Please upgrade RubyGems to avoid future breakage and silence this warning by running gem update --system 3.2.3
Could not find gem 'rails (>= 5.2.4.1, ~> 5.2.4)' in locally installed gems.
Run bundle install to install missing gems.
Your RubyGems version (2.7.6)) has a bug that prevents required_ruby_version from working for Bundler. Any scripts that use gem install bundler will break as soon as Bundler drops support for your Ruby version. Please upgrade RubyGems to avoid future breakage and silence this warning by running gem update --system 3.2.3
Could not find gem 'rails (>= 5.2.4.1, ~> 5.2.4)' in locally installed gems.
Run bundle install to install missing gems.
Your RubyGems version (2.7.6)) has a bug that prevents required_ruby_version from working for Bundler. Any scripts that use gem install bundler will break as soon as Bundler drops support for your Ruby version. Please upgrade RubyGems to avoid future breakage and silence this warning by running gem update --system 3.2.3
Could not find gem 'rails (>= 5.2.4.1, ~> 5.2.4)' in locally installed gems.
Run bundle install to install missing gems.
Your RubyGems version (2.7.6)) has a bug that prevents required_ruby_version from working for Bundler. Any scripts that use gem install bundler will break as soon as Bundler drops support for your Ruby version. Please upgrade RubyGems to avoid future breakage and silence this warning by running gem update --system 3.2.3
Could not find gem 'rails (>= 5.2.4.1, ~> 5.2.4)' in locally installed gems.
Run bundle install to install missing gems.
Your RubyGems version (2.7.6)) has a bug that prevents required_ruby_version from working for Bundler. Any scripts that use gem install bundler will break as soon as Bundler drops support for your Ruby version. Please upgrade RubyGems to avoid future breakage and silence this warning by running gem update --system 3.2.3
Could not find gem 'rails (>= 5.2.4.1, ~> 5.2.4)' in locally installed gems.
Run bundle install to install missing gems.
Your RubyGems version (2.7.6)) has a bug that prevents required_ruby_version from working for Bundler. Any scripts that use gem install bundler will break as soon as Bundler drops support for your Ruby version. Please upgrade RubyGems to avoid future breakage and silence this warning by running gem update --system 3.2.3
Could not find gem 'rails (>= 5.2.4.1, ~> 5.2.4)' in locally installed gems.
Run bundle install to install missing gems.
Your RubyGems version (2.7.6)) has a bug that prevents required_ruby_version from working for Bundler. Any scripts that use gem install bundler will break as soon as Bundler drops support for your Ruby version. Please upgrade RubyGems to avoid future breakage and silence this warning by running gem update --system 3.2.3
Could not find gem 'rails (>= 5.2.4.1, ~> 5.2.4)' in locally installed gems.
Run bundle install to install missing gems.
ace#ace-ThinkPad-T460:~/Desktop/codes/exactly!/rails1-practice/associations$ gem update --systemn 3.2.3
Failed to load /home/ace/.gemrc, wrong number of arguments (given 2, expected 1)
ERROR: While executing gem ... (OptionParser::InvalidOption)
invalid option: --systemn
ace#ace-ThinkPad-T460:~/Desktop/codes/exactly!/rails1-practice/associations$ gem update system
Failed to load /home/ace/.gemrc, wrong number of arguments (given 2, expected 1)
Updating installed gems
Nothing to update
'''

Ran "bundle install," but Rails keeps telling me it can't find a gem

I tried following the advice here (restarting the terminal) -- Rails keeps telling me that it's not currently installed, but this doesn't seem to work. Basically in my Rails project I can't start it (or even check the version) because it keeps telling me a gem can't be found.
rails -v
...
Ignoring sqlite3-1.3.13 because its extensions are not built. Try: gem pristine sqlite3 --version 1.3.13
Ignoring websocket-driver-0.6.5 because its extensions are not built. Try: gem pristine websocket-driver --version 0.6.5
Ignoring websocket-native-1.0.0 because its extensions are not built. Try: gem pristine websocket-native --version 1.0.0
Could not find nokogiri-1.10.4 in any of the sources
Run `bundle install` to install missing gems.
Then I run
bundle install
...
Using spring 2.1.0
Using spring-watcher-listen 2.0.1
Bundle complete! 10 Gemfile dependencies, 50 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
But after restarting the terminal, running "rails -v" still results in the same error. What to do?

I installed rails 6 beta, but I can't start my sample application

I installed rails 6 beta and I used rvm also.
gem install rails --pre
My Gemfile has:
gem 'rails', '~> 6.0.0.beta1'
When I try and run the rails using:
rails s
I get this error:
Ignoring bindex-0.5.0 because its extensions are not built. Try: gem
pristine bindex --version 0.5.0 Ignoring bootsnap-1.4.0 because its
extensions are not built. Try: gem pristine bootsnap --version 1.4.0
Ignoring byebug-11.0.0 because its extensions are not built. Try: gem
pristine byebug --version 11.0.0 Rails is not currently installed on
this system. To get the latest version, simply type:
$ sudo gem install rails
You can then rerun your "rails" command.
I already installed rails, so not sure why I am seeing this error?
The bundler of your current ruby version has an older version of rails installed.
So make these steps:
Check your current ruby version (ruby -v) and if its working together with rails 6 (requires ruby 2.5.0 or higher)
Install the new bundler in the ruby version (gem install bundler)
Install explicit rails 6 (for the ruby version with the new bundler) gem install rails
Run bundle install
Retry starting the server rails s
PS: If you want more than one ruby version on your system you should use rbenv or use Docker for the development.
Question: Your sudo command really needed? So your ruby is only accessible as root user? You overthink it :)

EC2 - Gem bundler is not installed, run `gem install bundler` first

I am deploying a rails app to EC2 with using Capistrano, but within the deployment process, I got
...
ERROR: Gem bundler is not installed, run `gem install bundler` first.
command finished in 344ms
*** [deploy:update_code] rolling back
...
I am not sure what's the problem, here's the list of installed gems on EC2:
bundler (1.3.5)
rake (10.0.4)
rubygems-bundler (1.1.1)
rvm (1.11.3.7)
ruby -v
ruby 1.9.3p392 (2013-02-22 revision 39386) [x86_64-linux]
Can anyone give me a tip how to fix it?
Thanks
Can you give some details:
Are you using rvm ?
What is the rails version in your Gemfile ?
Gem version ?
If you are using rvm, check for the gemset being used, remove .bundle and do a fresh $ bundle to install the gems.
Post the entire o/p from command $ gem list from your project folder.

bundle fails with rake error on vagrant

I've been following the railscast on setting up Vagrant with rails found here:
http://railscasts.com/episodes/292-virtual-machines-with-vagrant
I have rbenv running on vagrant with a slightly more updated version of ruby(1.9.3p125). Everything goes fine until I try to bundle. Here's the error I get:
vagrant#lucid32:/vagrant$ bundle
Fetching gem metadata from http:rubygems...
Fetching gem metadata from http:rubygems...
Resolving dependencies...
Using rake (10.0.3)
Errno::EPROTO: Protocol error - /vagrant/bin
An error occurred while installing rake (10.0.3), and Bundler cannot continue.
Make sure that gem install rake -v '10.0.3' succeeds before bundling.
I've tried gem installing that version of rake, then running rbenv rehash which seems to install, but running bundle again still gives me the same error.
I was able to resolve this by downgrading bundler from 1.3.2 to 1.2.5.
rvm use #global
gem uninstall bundler
gem install bundler -v 1.2.5
# switch back to the default gemset
rvm use
bundle install
# everything should work now
The only other thing that I changed was I reverted from rvm 1.18.19 to 1.17.10, but I am not positive that step is necessary.

Resources