Nokogiri-1.11.4 Bundler::GemNotFound error with rake in ruby build

I’m doing a ruby web service build, really nothing special in it
In the Gemfile.lock here are some of the relevant gems:

    rake (13.0.3)
    nokogiri (1.11.4)

the error:

Jan 17 10:58:43 PM  bundler: failed to load command: rake (/opt/render/project/.gems/bin/rake)
Jan 17 10:58:43 PM  /opt/render/project/rubies/ruby-2.7.3/lib/ruby/site_ruby/2.7.0/bundler/definition.rb:481:in `materialize': Could not find nokogiri-1.11.4 in any of the sources (Bundler::GemNotFound)

any ideas what could be going wrong?

Is this a rake task you’re trying to invoke? Does prefixing it with bundle exec help at all?

John B

yea, just trying bundle exec rake db:migrate. It may be related to vendor/cache not sure

yeah, it does sound like it as it uses native extensions - did you ditch the vendor cache and try adding the gems again with bundle config set force_ruby_platform true

John B

1 Like

@snackattas Did you get this figured out?

Thanks @John_B!

I had the same issue and your suggestion worked for me!

For those having the same issue, according to John_B and ruby on rails - Could not find nokogiri-1.11.1 in any of the sources while deploying a heroku app - Stack Overflow, adding bundle config set force_ruby_platform true just before your bundle install solves the issue.

Example:

#!/usr/bin/env bash

set -o errexit

bundle config set force_ruby_platform true # https://stackoverflow.com/a/66311533
bundle install
bundle exec rake assets:precompile
bundle exec rake assets:clean
bundle exec rake db:migrate

Cheers!

That did it for me, thanks!

Thanks for the update!

John B

I’m attempting to set up a staging environment. This issue was a problem for me in the regular production environment but the set force_ruby_platform true worked for me there.

However, I have all of that set on my staging services as well but it’s running into the error:

bundler: failed to load command: sidekiq (/opt/render/project/.gems/bin/sidekiq)
Jul 5 02:53:29 PM /opt/render/project/rubies/ruby-2.7.4/lib/ruby/site_ruby/2.7.0/bundler/definition.rb:484:in `materialize’: Could not find nokogiri-1.12.5-x86_64-linux in any of the sources (Bundler::GemNotFound)

Looks like a good amount of my environmental variables aren’t getting filled out correctly, which could be a cause of the issue. The following are blank on my staging environment when using printenv while they are working just fine in production:
GEM_ROOT
RUBY_VERSION
RUBY_ENGINE
RUBY_ROOT
ruby_dir

It worked for me, but also I just needed to activate require "sprockets/railtie" on config/application.rb and add app/assets/config/manifest.js empty file.