Elastic Beanstalk, Bundler could not find compatible versions for gem "bundler" - ruby-on-rails

I have tried Elastic Beanstalk for rails. When I run eb deploy I got this error. I need to install at least bundler 1.8.4. Any idea how to resolve this?
Bundler could not find compatible versions for gem "bundler":
In Gemfile:
bundler (>= 1.8.4) ruby
Current Bundler version:
bundler (1.7.3)
This Gemfile requires a different version of Bundler.
Perhaps you need to update Bundler by running `gem install bundler`? (Executor::NonZeroExitStatus)

I am upgrading the pre-installed bundler by adding an elastic beanstalk config file to my project. I am running an older version of Elastic beanstalk box, so feel free to change the ruby paths to fit your box.
file name:
.ebextensions/upgrade_bundler.config
file content:
commands:
update_bundler:
command: /opt/rubies/ruby-2.1.5/bin/gem install bundler -v 1.8.4

Related

Travis Running Gem Install Bundler Without Version

Travis is running the the command below and throwing an error:
$ gem install bundler
217ERROR: Error installing bundler:
218 The last version of bundler (>= 0) to support your Ruby & RubyGems was 2.3.26. Try installing it with `gem install bundler -v 2.3.26`
219 bundler requires Ruby version >= 2.6.0. The current ruby version is 2.5.0.
Now I don't know who told it to do that when I have the following in the .travis file:
before_install:
- gem install bundler -v 2.3.26
What could be causing travis to behave like this?

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.

Can't make successful deploy to Beanstalk

I'm using the eb CLI to deploy my RoR API to Beanstalk, and although the deploy works, the app degrated. I can see that it fails with:
+ bundle install
/opt/rubies/ruby-2.5.7/lib/ruby/site_ruby/2.5.0/rubygems.rb:284:in `find_spec_for_exe': Could not find 'bundler' (2.1.4) required by your /var/app/ondeck/Gemfile.lock. (Gem::GemNotFoundException)
To update to the latest version installed on your system, run `bundle update --bundler`.
To install the missing version, run `gem install bundler:2.1.4`
from /opt/rubies/ruby-2.5.7/lib/ruby/site_ruby/2.5.0/rubygems.rb:303:in `activate_bin_path'
from /opt/rubies/ruby-2.5.7/bin/bundle:23:in `<main>'.
I'm not finding in the AWS docs what I should do to fix this and prevent from happening again. Has anyone experienced the same, or knows why it's happening, and more important, how to fix it.
The bundler version of your elastic beanstalk is not 2.1.4 which is required by your project. Add an elastic beanstalk config file to upgrade the pre-installed bundler of elastic beanstalk.
#.ebextensions/bundler_update.config
commands:
update_bundler:
command: /opt/rubies/ruby-2.5.7/bin/gem install bundler -v 2.1.4
Ruby and Bundler version should match yours.

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.

Cannot start Rails console. Wrong bundler version (which is installed)

When I run rails console in my production server with this command
rails c
I get this message:
You must use Bundler 2 or greater with this lockfile.
I checked bundler version:
gem list bundler
And I got this
bundler (2.0.2, default: 1.17.3, 1.16.3)
bundler-unload (1.0.2)
rubygems-bundler (1.4.4)
I read I could set bundler version with this command
bundle _2.0.2_ -v
And I got this message
Bundler version 2.0.2
But I keep getting the same error when running rails console.
Finally, some more information. My Gemfile.lock says I bundled with v2.0.1 (development bundler version). I'm using rvm in production and rbenv in development (not on purpose; I always used rbenv but I inherited an application using rvm in production).
What should I do to run rails console in production server in this situation? Can I uninstall older bundler versions and keep only v2.0.2? Should I updgrade to v2.0.2 in development to have the same versions?
Thanks!

Resources