Issues installing ruby gems - ruby-on-rails

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.

Related

Can not downgrade bundler

I am getting this error while trying to push my app to heroku:
Warning: the running version of Bundler (1.17.2) is older than the version that created the lockfile (1.17.3). We suggest you upgrade to the latest version of Bundler by runninggem install bundler. I have the following versions of bundler:
gem list | grep bundler
bundler (2.0.2, default: 1.17.3, 1.17.2)
I have tried various suggestions from different similar posts but I am not able to set the bundler version to 1.17.2 which is required by Heroku. I tried:
gem uninstall bundler
gem install bundler -v 1.17.2
1 gem installed
Then removed the lock file and rerunning the bundle update but the version 1.17.3 still comes as the default.
I tried gem uninstall bundler:1.17.3 which returned:
Successfully uninstalled bundler-1.17.3
Then: gem install bundler -v 1.17.2which returned:
Successfully installed bundler-1.17.2
1 gem installed
Now bundler -v returns a LoadError:
Traceback (most recent call last):
3: from /home/amairu/.rvm/gems/ruby-2.6.1#rails522/bin/ruby_executable_hooks:24:in `<main>'
2: from /home/amairu/.rvm/gems/ruby-2.6.1#rails522/bin/ruby_executable_hooks:24:in `eval'
1: from /home/amairu/.rvm/gems/ruby-2.6.1#rails522/bin/bundler:23:in `<main>'
/home/amairu/.rvm/gems/ruby-2.6.1#rails522/bin/bundler:23:in `load': cannot load such file -- /home/amairu/.rvm/rubies/ruby-2.6.1/lib/ruby/gems/2.6.0/gems/bundler-1.17.3/exe/bundler (LoadError)
I am using rvm and I also tried to uninstall in the global gem set:
rvm use 2.6.1#global
gem uninstall bundler:1.17.3 which does not return any output or message.
How can I set the bundler to 1.17.2?
set your bundler version as a default version like below if you want to use 2.0.2
bundle _2.0.2_ -v
I had troubles with bundlers recently (Bundler v2.0.2 was installed, v1.17.3 set as default) but with a different error (Can't find gem bundler (>= 0.a) with executable bundle (Gem::GemNotFoundException)).
Running gem update --system did a trick for me.
Install the correct bundler for your application with the following command:
gem install bundler -v "$(grep -A 1 "BUNDLED WITH" Gemfile.lock | tail -n 1)"

Bundler: You must use Bundler 2 or greater with this lockfile

I'm working with heroku and every time I try to push my app this message shows out:
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Ruby app detected
remote:
remote: !
remote: ! You must use Bundler 2 or greater with this lockfile.
remote: !
remote: /tmp/d20181109-104-g861yi/bundler-1.15.2/gems/bundler-1.15.2/lib/bundler/lockfile_parser.rb:108:in `warn_for_outdated_bundler_version': You must use Bundler 2 or greater with this lockfile. (Bundler::LockfileError)
remote: from /tmp/d20181109-104-g861yi/bundler-1.15.2/gems/bundler-1.15.2/lib/bundler/lockfile_parser.rb:95:in `initialize'
remote: from /app/tmp/buildpacks/b7af5642714be4eddaa5f35e2b4c36176b839b4abcd9bfe57ee71c358d71152b4fd2cf925c5b6e6816adee359c4f0f966b663a7f8649b0729509d510091abc07/lib/language_pack/helpers/bundler_wrapper.rb:130:in `new'
remote: from /app/tmp/buildpacks/b7af5642714be4eddaa5f35e2b4c36176b839b4abcd9bfe57ee71c358d71152b4fd2cf925c5b6e6816adee359c4f0f966b663a7f8649b0729509d510091abc07/lib/language_pack/helpers/bundler_wrapper.rb:130:in `block in parse_gemfile_lock'
remote: from /app/tmp/buildpacks/b7af5642714be4eddaa5f35e2b4c36176b839b4abcd9bfe57ee71c358d71152b4fd2cf925c5b6e6816adee359c4f0f966b663a7f8649b0729509d510091abc07/lib/language_pack/instrument.rb:18:in `block (2 levels) in instrument'
remote: from /app/tmp/buildpacks/b7af5642714be4eddaa5f35e2b4c36176b839b4abcd9bfe57ee71c358d71152b4fd2cf925c5b6e6816adee359c4f0f966b663a7f8649b0729509d510091abc07/lib/language_pack/instrument.rb:40:in `yield_with_block_depth'
remote: from /app/tmp/buildpacks/b7af5642714be4eddaa5f35e2b4c36176b839b4abcd9bfe57ee71c358d71152b4fd2cf925c5b6e6816adee359c4f0f966b663a7f8649b0729509d510091abc07/lib/language_pack/instrument.rb:17:in `block in instrument'
remote: from /app/tmp/buildpacks/b7af5642714be4eddaa5f35e2b4c36176b839b4abcd9bfe57ee71c358d71152b4fd2cf925c5b6e6816adee359c4f0f966b663a7f8649b0729509d510091abc07/vendor/ruby/heroku-18/lib/ruby/2.5.0/benchmark.rb:308:in `realtime'
remote: from /app/tmp/buildpacks/b7af5642714be4eddaa5f35e2b4c36176b839b4abcd9bfe57ee71c358d71152b4fd2cf925c5b6e6816adee359c4f0f966b663a7f8649b0729509d510091abc07/lib/language_pack/instrument.rb:16:in `instrument'
remote: from /app/tmp/buildpacks/b7af5642714be4eddaa5f35e2b4c36176b839b4abcd9bfe57ee71c358d71152b4fd2cf925c5b6e6816adee359c4f0f966b663a7f8649b0729509d510091abc07/lib/language_pack/helpers/bundler_wrapper.rb:86:in `instrument'
remote: ! Push rejected, failed to compile Ruby app.
remote:
remote: ! Push failed
remote: Verifying deploy...
remote:
remote: ! Push rejected to my-proyect-1234.
remote:
It says 'remote: ! You must use Bundler 2 or greater with this lockfile.'
But my Bundler version is 2.0.0.pre.1
Don't know what to do, I tried uninstalling bundle and installing it again, I errased the Gemfile.lock and typing bundle again
I had a similar experience.
Here's how I solved it
Display a list of all your local gems for the bundler gem
gem list bundler
N/B: The command above is for rbenv version manager, the one for rvm might be different
This will display the versions of the bundler gem installed locally
bundler (2.1.4, default: 1.17.2)
Note: Your versions might differ from the one here
if you don't have bundler version 2 installed locally, then run
gem install bundler
OR
gem install bundler -v 2.1.4
Note: Replace 2.1.4 with the version you want to install
if you have bundler version 2 already installed locally or just installed it, then you need to simply install an update for RubyGems Package Manager locally. To do this, run
gem update --system
And then finally run
bundle update --bundler
For Docker projects in Ruby on Rails
If you're experiencing this issue when trying to build your application using Docker, simply do this:
Delete the Gemfile.lock file
Please don't create it again by running bundle install.
Run your docker build or docker-compose build command as appropriate to build your project.
This will re-create the Gemfile.lock file and setup the appropriate version of bundler necessary for your project in the Gemfile.lock file.
N/B: As a side note, you can also add this environment variable to your Dockerfile with the Bundler version defined.
ENV BUNDLER_VERSION=2.1.4
A bit late to the party but I just ran into this today as well, and this solution avoids having to uninstall Bundler: just run
heroku buildpacks:set https://github.com/bundler/heroku-buildpack-bundler2
as per discussion on the Bundler issue here.
I had same issue on Local Machine(Development) as-
You must use Bundler 2 or greater with this lockfile.
The issue was with gemfile.lock because my local bundle version and project bundle version was not matching!
Here is solution-
I deleted gemfile.lock
Run the command - bundle install
That solved my problem, it is smooth!
Hope will work for others!
simple gem update bundler did it for me.
I resolved this issue by running gem uninstall bundler to remove 2.0.0.pre.1, renamed the Gemfile.lock file (to remove it from use) and then ran bundle install to reinstall the gemfiles. In my case, I already had access to the earlier bundler version installed by heroku (so when I ran gem uninstall, I was shown all versions available and chose to remove 2.0.0.pre.1).
Even with bundler 2 on the system this error still happens when deploying an app with Ruby 2.6 since Ruby 2.6 ships with a default version of bundler.
If you are using Ruby 2.6 then upgrade to Ruby 2.6.1 to avoid this issue.
The Ruby 2.6.0 is not the case of this problem.
The default version of Bundler incorrectly invoked when using bin stubs.
For more details please refer the following link
Solution:
Bundler 2 is available on the system and is the latest version, So it should be invoked instead of the default bundler version.
Update Rubygems
gem update --system
Update bundler
gem install bundler
Update Gemfile.lock in your project
bundler update --bundler
Yup, so generally uninstalling your version of bundler, removing the gemfile.lock, and finally running gem install bundler -v 1.15.2(which is the version heroku is using) worked.
After that running git push heroku master worked!
For local system
gem install bundler:2.0.0.pre.1
bundle _2.0.0.pre.1_ install
Where "2.0.0.pre.1" is whatever version you need to bundle with.
Don't delete your Gemfile.lock for this, it's there for a reason.
If you're using a docker image like FROM:ruby:2.X.X then you can do the following:
FROM ruby:2.6.2
... # omitted
COPY Gemfile /myapp/Gemfile
COPY Gemfile.lock /myapp/Gemfile.lock
RUN gem uninstall bundler
RUN gem install bundler -v 2.1.4
RUN bundle update --bundler
RUN bundle install
... # omitted
Heroku does not use Bundler 2.0, but 1.15.2, as the tracelog hints.
As far as I am aware, the "workaround" is to create your own buildpack, or simple fork their own:
Open lib/language_pack/ruby.rb in your editor, and change the following line:
BUNDLER_VERSION = "1.11.2"
(README.md at https://github.com/heroku/heroku-buildpack-ruby)
Update: As of Ruby 2.6.1 and Bundler 2.0.1, Heroku now does support Bundler 2.0.1. https://devcenter.heroku.com/articles/bundler-version#known-upgrade-issues
This is not the case for Ruby 2.6.0, as this is incorrectly invoked from binstubs, as #Schneems has mentioned in the comment. He has kindly reported this as a Ruby Bug #15622
For people who are not using Heroku:
I Tried everything and I was still receiving this error. even this link didn't help me: https://github.com/jekyll/jekyll/issues/7463
So this was my solution:
Push your code on GitHub.
delete project folder
create a new folder and pull your code
bundle install
That's it. bundler update --bundler was not helping me at the end and I didn't use it.
One more important thing:
I updated my ruby version but I was getting this error because my RVM default version was an old version.
even when you use rvm use VERSION_NUMBER -- default will not help because as soon as you log out from terminal the default version will change to the old one and you will have the same issue.
For this you can use this answer:
How to set default Ruby version with RVM?
or just uninstall old ruby version with rvm uninstall X.X.X and install the new one with rvm install X.X.X and make it default by rvm use --default X.X.X.
cheers.
I got the same problem for Ruby 2.6.3, nothing listed in answers could help.
The only the following solution worked for me:
bundle update rails
Remove Gemfile.lock
bundle
I had the same issue. In my Gemfile.lock i saw at the end "bundled with bundler 2.0.2", but running bundle --version gave me version 1.17... For me it solved just updateing my bundler with the following command: bundle update --bundler see bundler documentation
I deleted the project and made a git clone from the Heroku app, donĀ“t know if it is a good solution, but it worked for me.
I got the same issue in my local system, my ruby version was low due to which the error was occurring. Fixed it by switching it to updated versions of ruby.
Using bundler 2.0.1 allows for automatic version switching as required by the lock file. In this regard, installing bundler 2.0.1 worked for me.
Installing bundler 2.0.1
gem install bundler -v 2.0.1
Update bundler
bundle update -bundler
I had the same problem today.
In my case the problem was caused by using rvm gemset other than latest I have with ruby 2.7.1 and bundler 2.1.4 (same bundle Gemfile was locked with).
So just take a look at your rvm environment before doing any other solution listed here. Specially if you're running your project on production.
Happy hacks !
Delete gem history and modules installed in rails application.
$ rm -rf vendor/bundle
$ rm Gemfile.lock
and, bundle
$ bundle install --path=vendor/bundle
and, start Rails Server
$ bundle exec rails s
and, connect to browser.
http://localhost:3000/
Same error, but locally.
I finally figured out I was using wrong version of ruby on my command line (I'm using uru to manage ruby versions.)
After all, how could the gemfile use and produce a lock file with version 2.1.4, yet my search didn't find that version!
>gem list bundler
*** LOCAL GEMS ***
bundler (default: 1.16.2, 1.13.1)
capistrano-bundler (1.6.0, 1.1.4)
So I changed to the correct version of ruby and all was good.
Remember, gems are stored with your Ruby version!

Installing Rails with RVM, while checking rail -v: bundler-1.1.5 conflicts with bundler (~> 1.0.0)

I'm having a dearly hard time getting my rails environment up. Here is the issue.
$ gem install rails --version 3.0.1
Successfully installed rails-3.0.1
1 gem installed
Installing ri documentation for rails-3.0.1...
Installing RDoc documentation for rails-3.0.1...
$ rails -v
/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/site_ruby/1.9.1/rubygems/specification.rb:1637:in `raise_if_conflicts': **Unable to activate rails-3.0.1, because bundler-1.1.5 conflicts with bundler (~> 1.0.0) (Gem::LoadError)**
from /.rvm/rubies/ruby-1.9.2- p320/lib/ruby/site_ruby/1.9.1/rubygems/specification.rb:746:in `activate'
from /.rvm/rubies/ruby-1.9.2-p320/lib/ruby/site_ruby/1.9.1/rubygems.rb:1232:in `gem'
from /.rvm/gems/ruby-1.9.2-p320#rails3tutorial/bin/rails:18:in `<main>'
from /.rvm/gems/ruby-1.9.2-p320#rails3tutorial/bin/ruby_noexec_wrapper:14:in `eval'
from /.rvm/gems/ruby-1.9.2-p320#rails3tutorial/bin/ruby_noexec_wrapper:14:in `<main>'
Here in lies the issue. I've reinstalled ruby. I've installed 1.8.7, 1.9.2, 1.9.3 and still no luck across the board.
i've run
$ gem update bundler
But bundle is 'up to date', so still no luck
I've really poked at this all day now, and with no luck I open my palms to you all.
the issue is that in #global gemset you have higher version of bundler then the one required.
you can either specify the version on command line:
bundle _1.0.27_ exec rails -v
or use Gemfile:
printf 'source :rubygems\ngem "rails", "3.0.1"\n'
rails -v
this assumed you have the gem rubygems-bundler - but it comes by default with RVM so you should have it.
and last - remove bundler from #global:
rvm #global do gem uninstall bundler
but there is one caveat - while reinstalling ruby gem bundler will be installed again.

Unable to activate rails 3.0.1 because of bundler version conflict

so I run:
$ gem install rails --version 3.0.1
Successfully installed rails-3.0.1
1 gem installed
Installing ri documentation for rails-3.0.1...
Installing RDoc documentation for rails-3.0.1...
then I get the error:
$ rails -v
/usr/local/rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/specification.rb:1637:in `raise_if_conflicts': Unable to activate rails-3.0.1, because bundler-1.1.4 conflicts with bundler (~> 1.0.0) (Gem::LoadError)
from /usr/local/rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/specification.rb:746:in `activate'
from /usr/local/rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems.rb:1232:in `gem'
from /usr/local/rvm/gems/ruby-1.9.3-p125#rails3tutorial/bin/rails:18:in `<main>'
from /usr/local/rvm/gems/ruby-1.9.3-p125#rails3tutorial/bin/ruby_noexec_wrapper:14:in `eval'
from /usr/local/rvm/gems/ruby-1.9.3-p125#rails3tutorial/bin/ruby_noexec_wrapper:14:in `<main>'
So Rails 3.0.1 requires Bundler v1.0.0 - v1.0.22 (actually any 1.0.x version up to, but not including, 1.1.0), but you have a newer version of Bundler that's being loaded when Rails is started. You could uninstall the newer version(s) of Bundler (though this is a crappy way to deal with the issue) or since you're using RVM, just create a gemset for Rails 3.0.1.
$ rvm gemset create rails_3.0.1
$ rvm gemset use rails_3.0.1
$ gem install rails -v 3.0.1
$ rails -v
3.0.1
Note: this requires that Bundler not be in your global gemset for the Ruby version you're trying to use. If the global gemset contains a Bundler version equal to or higher than 1.1.0 then you'll get the same error as before.
Update: A little explanation about ~> and RubyGems versioning might be handy. The section on pessimistic version constraint in the RubyGems docs does a fantastic job of covering everything.
You may need to update to bundler 1.1.4.
gem update bundler
should do the trick.
This is possibly due to Ruby v1.9.2/3 uses bundler v1.1.4 while Rails v3.0.1 requires bundler v~1.0.0. Hence, by simply updating the Rails version to v3.2.6, the conflict is solved. This conflict can be easily solved by matching the Ruby and Rails version.
I had same problem with mysql. I uninstalled mysql gem and I installed the newest version of mysql gem. Is RVM ok?

Could not find RubyGem bundler

I've cloned diaspora for github, git://github.com/diaspora/diaspora.git
I tried to install it. An error generated when I use bundle install.
$ bundle install
/usr/local/lib/site_ruby/1.8/rubygems.rb:812:in `report_activate_error': Could not find RubyGem bundler (>= 0) (Gem::LoadError)
from /usr/local/lib/site_ruby/1.8/rubygems.rb:223:in `activate'
from /usr/local/lib/site_ruby/1.8/rubygems.rb:1146:in `gem'
from /usr/bin/bundle:18
I'm using rails 3 and ruby 1.8 on ubuntu 11.04. How to fix it? Please help
Did you install bundler gem?
$ gem install bundler
You might need sudo privileges.
Hmm, maybe you've got the bundle command and bundler gem installed for /usr/bin/ruby, and after that installed another Ruby in /usr/local/bin/ruby?
Could you do a which ruby and head -1 /usr/bin/bundle? Maybe also a gem list?
Presumably this has been fixed long ago, but for the benefit of others....
My issues was that while I had installed the bundler gem it had been installed in a different location to the current GEM_PATH - so it couldn't be found.
So,
GEM_PATH=/usr/lib/ruby/gems/1.8/ bundle install
did the business, setting the value of GEM_PATH to the actual location of the gems folder where the bundler gem has been installed.

Resources