I'm attempting to deploy a Rails 7 app (Ruby 3.0.4) to Elastic Beanstalk which uses Amazon Linux 2. Possibly could be an issue with installing dependencies for nokogiri?
Could not find nokogiri-1.13.7-x86_64-linux in any of the sources
2022/07/17 13:57:15.371714 [ERROR] An error occurred during execution of command [app-deploy] - [stage ruby application]. Stop running the command. Error: install dependencies in Gemfile failed with error Command /bin/sh -c bundle 2.3.15 install --local failed with error exit status 7. Stderr:Don't run Bundler as root. Bundler can ask for sudo if it is needed, and installing your bundle as root will break this application for all non-root users on this machine. Could not find nokogiri-1.13.7-x86_64-linux in any of the sources
I'm using Bundler 2.3.18 on my mac, I see Elastic Beanstalk is using Bundler 2.3.15, I'm not sure if that will cause issues?
I tried removing all my gems and reinstalling, then deploying to AWS EB.
- I deleted gemfile.lock
- I commented out the Gemfile and ran
bundle clean --force
then uncommented the Gemfile afterwards. rm -rf vendor/cache
to remove cached gems- ran
bundle
(re-installed gems again)
Initially I couldn't use bin/dev due to a foreman error so I reinstalled foreman with rbenv local 3.0.4 && gem install foreman
After reading https://nokogiri.org/tutorials/installing_nokogiri.html I ran bundle lock --add-platform x86_64-linux
I tried this a fallback solution https://nokogiri.org/tutorials/installing_nokogiri.html#solution_1
rm -rf vendor/cache
bundle config set force_ruby_platform true
bundle install
I will get an error about the pg gem if I don't cache the gem files under vendor/cache
bundle package --all
in my gemfile.lock I see the x86_64-linux entries.
PLATFORMS
ruby
x86_64-linux
and
nokogiri (1.13.7)
mini_portile2 (~> 2.8.0)
racc (~> 1.4)
nokogiri (1.13.7-x86_64-linux)
racc (~> 1.4)
pg (1.4.1)
I have a .ebextensions/options.config
file with the below. I tried what was in this SO answer but it didn't work for me.
packages:
yum:
amazon-linux-extras: []
git: []
patch: []
gcc: []
libxml2: []
libxml2-devel: []
libxslt: []
libxslt-devel: []
commands:
01_A:
command: sudo amazon-linux-extras enable postgresql13
02_B:
command: sudo yum install -y postgresql-devel
At the elastic beanstalk CLI I ran:
eb create staging-env -db.engine postgres --database.instance db.t3.micro --database.username my_user --database.password my_pass --database.size 5 --database.version 13.4 --instance_type t3.micro --single
It always fails at the EC2 instance step and the eb-engine.log file will reference nokogiri as the cause.
Update
In cfn-init.cmd.log I'm seeing entries like below which indicate that the dependencies for nokogiri are being installed. Possibly there is a dependency that I missed still?
[INFO] yum list installed libxml2
[INFO] Completed successfully.
In eb-engine.log the bundle command is being run with the --local
option by elastic beanstalk. So it's only looking at vendor/cache
and the x86_64-linux nokogiri isn't there.
error **Command /bin/sh -c bundle _2.3.15_ install --local** failed with error exit status 7. Could not find nokogiri-1.13.7-x86_64-linux in any of the sources
I tried passing bundle install in the ebextensions/options.config file but it fails.
04_bundle:
command: 'bundle install'