Elastic Beanstalk: can't find gem bundler (= 0.a) with executable bundle (Gem::GemNotFoundException)
So here's the programmatic solution to the above problem. Create the below file under .ebextensions/gem_install_bundler.config
:
files:
# Runs before `./10_bundle_install.sh`:
"/opt/elasticbeanstalk/hooks/appdeploy/pre/09_gem_install_bundler.sh" :
mode: "000775"
owner: root
group: users
content: |
#!/usr/bin/env bash
EB_APP_STAGING_DIR=$(/opt/elasticbeanstalk/bin/get-config container -k app_staging_dir)
EB_SCRIPT_DIR=$(/opt/elasticbeanstalk/bin/get-config container -k script_dir)
# Source the application's ruby, i.e. 2.6. Otherwise it will be 2.3, which will give this error: `bundler requires Ruby version >= 2.3.0`
. $EB_SCRIPT_DIR/use-app-ruby.sh
cd $EB_APP_STAGING_DIR
echo "Installing compatible bundler"
gem install bundler -v 2.0.1
Then when you next eb deploy
, the bundler will have been updated to version 2.0.1, and you won't get the above error again.
More information in the docs here:
https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/custom-platform-hooks.html
and here:
https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers-ec2.html#linux-files
Last note: Ensure that you either commit these changes before running eb deploy
, or stage them and run eb deploy --staged
. See: https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/eb3-cli-git.html. I learned this the hard way!
Can't find gem railties (= 0.a) with executable rails (Gem::GemNotFoundException)
try to run gem install bundler
then run bundle
if you still getting the error then run,
bundle install --path vendor/bundle
How to fix bundle error in AWS elastic beanstalkd
this solve with add this after files "# Runs before './10_bundle_install.sh':" ' change with ` –
Rails: Could not find bundler (2.2.11) required by Gemfile.lock. (Gem::GemNotFoundException)
Make sure you're entering "bundle" update, if you have the bundler gem installed.
bundle update
If you don't have bundler installed, do gem install bundler
.
How to fix Rails 5.2 application bundler issue for AWS Elastic Beanstalk deployment
In Rails 5.2 you have to install bundler 2.0.1 version. To fix this issue you can follow below steps -
Step #1. You have add eb extensions for installing bundler 2.0.1 version to AWS Elastic beanstalk -
# Go to your project root directory
$ mkdir .ebextensions
$ vim .ebextensions/bundler_install.config
files:
# Runs before `./10_bundle_install.sh`:
"/opt/elasticbeanstalk/hooks/appdeploy/pre/09_gem_install_bundler.sh" :
mode: "000775"
owner: root
group: root
content: |
#! /bin/bash
EB_APP_STAGING_DIR=$(/opt/elasticbeanstalk/bin/get-config container -k app_staging_dir)
EB_SCRIPT_DIR=$(/opt/elasticbeanstalk/bin/get-config container -k script_dir)
# Source the application's ruby, i.e. 2.6. Otherwise it will be 2.3, which will give this error: `bundler requires Ruby version >= 2.3.0`
. $EB_SCRIPT_DIR/use-app-ruby.sh
cd $EB_APP_STAGING_DIR
echo "Installing compatible bundler"
gem install bundler -v 2.0.1
Step #2. Go to AWS Elastic beanstalk All applications -> example-rails52 -> example-eb-rails52-env then click Configuration -> Software -> Modify and then added this env variable
BUNDLER_VERSION=2.0.1
and click save
Step #3. Deploy the app again
$ eb deploy
Hope it should work.
Why do I get `Could not find 'bundler' (1.17.3)` after upgrading Ruby?
This is because gem install bundler
will install the newer 2.x version of bundler and the Gemfile.lock
specifies the version of bundler to use at the bottom.
You can either:
Install bundler 1.x
gem install bundler:1.17.3
If this does not work try deleting Gemfile.lock
and doing bundle install
.
Upgrade Gemfile.lock to use 2.x
bundle update --bundler
Related Topics
Rails 4 Strong Parameters Without Required Parameters
How to Remove All Elements That Satisfy a Condition in Array in Ruby
Alias_Method and Class_Methods Don't Mix
Ruby on Rails - Paperclip and Dynamic Parameters
Env: Ruby\R: No Such File or Directory
Ruby Rest-Client File Upload as Multipart Form Data with Basic Authenticaion
Write a Migration with Reference to a Model Twice
How to Get Rspec to Run All Tests Nested Under a Folder
How to Set a Request.Referrer Inside My Rspec
How to Pass <Arguments> to Irb If I Don't Specify <Programfile>
What Are Tainted Objects, and When Should We Untaint Them
Unicode Characters in Ruby 1.9.3 Irb with Rvm
Carrierwave File Upload with Different File Types
Does Concurrency Happen Even When Only One Thread Is in a Thread Pool