Rspec and gem errors despite having needed programs - ruby-on-rails

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
'''

Related

Bundler version wrong?

I'm having trouble creating a new Rails app. I'm using a fresh WSL2 + Ubuntu 18.04 install.
Long story short, I followed the Rails installation procedure from https://gorails.com/setup/windows/10 but when installing bundle using gem install bundler, I end up with 2 bundler versions (2.1.2 and 2.1.4).
If I stick with 2.1.2 webpacker throws an error, so I definitely need to install the newest version. The problem is, when I install 2.1.4 the default version remains 2.1.2, so then I go to cd /.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/specifications/default and remove bundler-2.1.2.gemspec, and then I do a gem install bundler --default to get only v2.1.4 as default:
gem list bundler
*** LOCAL GEMS ***
bundler (default: 2.1.4)
But here is the problem; if I run bundler -v I get:
bundler -v
Bundler version 2.1.2
But the real problem is that, when running rails new, it clearly tries to use 2.1.2 which inevitably fails.
How can I solve this?
Thank you
Try gem uninstall bundler --version 2.1.2.
From the app directory run these commands:
gem install bundler
bundle update --bundler
bundle install
This rebuilds the Gemfile.lock with the correct Bundler version.
EDIT: You can create the directory first with rails new my_rails_app, then do cd .. ; rails new my_rails_app after running the above commands.

rails bundler version issue

I have rails project working on Ubuntu.
Now I installed WSL on another machine and cloned the very same project.
Now when I try to install bundler with
gem install bundler
it installed bundler 2.0.2 and on bundle install it gives error:
Could not find gem 'bundler (< 2.0, >= 1.3.0)', which is required by gem 'rails (~> 5.0.0)'
Now I looked at the gemfile.lock it was bundled with 1.16.4, I installed it with
gem install bundler -v '1.16.4'
Now I do a simple bundle install, then it uses 2.0.2, so I have to do
bundle _1.16.4_ install
It completed successfully, but now when I am trying to do rails db:create, it says
The git source https://github.com/activerecord-hackery/ransack.git is not yet checked out. Please run bundle install before trying to start your application
What's wrong here?
Uninstall bundler 2.0.2:
gem uninstall bundler -v 2.0.2
If you still have problem, you can use:
bundle exec rails db:create
You can update to using bundler 2.x if possible with:
bundle update --bundler
This will change the BUNDLED_WITH version in Gemfile.lock.
see: https://bundler.io/guides/bundler_2_upgrade.html
You could also set the default bundler version:
bundler config default 1.16.4
gem list bundler
However I have found this to be a bit error prone.
Try to remove all your gems (go to the gems folder of your ruby, remove the specifications folder and the gems folder),
gem list should be more or less empty
gem install bundler
And try to bundle install again from scratch.

Issues after upgrading to Ruby 2.5.1 - "Incompatible library version"

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.

Solidus gem showing error regarding ruby version during bundle install

I am trying to install Solidus gem which is a fork of spree and while running bundle install this shows up
Installing solidus_core 1.1.0
Gem::InstallError: solidus_core requires Ruby version >= 2.1.0.
An error occurred while installing solidus_core (1.1.0), and Bundler cannot
continue.
even when I am running ruby version 2.2.3
ruby -v
ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-darwin15]
I am using rbenv on OS X El Capitan to control the ruby versions. Is there a problem with ruby version control or any other issue?
Try to set ruby '2.2.3' in Gemfile, and execute bundle install.
If it's not resolved, please check your bundle path to execute this:
$ which bundle
/usr/bin/bundle # global
$ gem install bundler
$ bundle install --path vendor/bundle

Issues installing ruby gems

I am trying to install bundler using ruby gems and RVM, but I am running into this error when I run the bundle init command:
/Library/Ruby/Site/2.0.0/rubygems/dependency.rb:315:in `to_specs': Could not find 'bundler' (>= 0) among 13 total gem(s) (Gem::LoadError)
Checked in 'GEM_PATH=/Users/CalebKleveter/.rvm/gems/ruby-2.2.3:/Users/CalebKleveter/.rvm/gems/ruby-2.2.3#global', execute `gem env` for more information
from /Library/Ruby/Site/2.0.0/rubygems/dependency.rb:324:in `to_spec'
from /Library/Ruby/Site/2.0.0/rubygems/core_ext/kernel_gem.rb:64:in `gem'
from /Users/CalebKleveter/.gem/ruby/2.0.0/bin/bundle:22:in `<main>'
I am installing it using this command:
gem install --user-install bundler
I was having issues before when downloading bundler. I was getting this error:
WARNING: You don't have /Users/CalebKleveter/.gem/ruby/2.2.0/bin in your PATH,
gem executables will not run.
So I ran this command to fix it:
PATH=$PATH:/Users/CalebKleveter/.gem/ruby/2.2.0/bin export PATH
Am I installing it in the wrong spot?
All gems were working earlier, but I ran this command:
rvm use 2.2.3
So I am using ruby version 2.2.3, I was using version 2.0.0 before if I remember correctly. Is that the issue?
It's not an issue per se, but you might find incompatibilities between old gems and current version of rails.
Run rvm list and then set the default to the latest version of rails and update your gems.

Resources