Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Heroku app crashes, logs say "No such file to load -- nokogiri (LoadError)"

I had a working app, added Nokogiri, to parse some xml, runs fine locally.

My Gemfile includes: gem 'nokogiri'

I ran bundle install and verified my Gemfile.lock includes DEPENDENCIES ... nokogiri

In my controller class I added (didnt thinkI had to but got an error locally if I didnt):

class MydealController < ApplicationController
  require 'rubygems'
  require 'open-uri'
  require 'nokogiri'

when I use my browser to get the url in MydealController that uses nokogiri doc = Nokogiri::XML(getresult) Heroku crashes.

heroku logs shows this error No such file to load -- nokogiri (LoadError)

Looking at what happens when I git push heroku I do not see nokogiri on the list of many many gems that get installed. Heroku says the push was fine, but nokogiri is not listed and I get the aforementioned error...

like image 341
jpw Avatar asked Feb 11 '11 01:02

jpw


2 Answers

It seems that when using Windows Gemfile.lock will contain version of nokogiri gem specific for windows, solution is to remove Gemfile.lock and push to heroku.

More info on this subject here

like image 133
Haris Krajina Avatar answered Sep 18 '22 01:09

Haris Krajina


Your mission should you choose to accept it.

Ensure:

  1. nokogiri is in Gemfile.lock
  2. Gemfile.lock is committed to git
  3. you push the commit that has nokogiri in Gemfile.lock to Heroku

Good luck! This message will self destruct in 10 seconds...

like image 23
Khoa Nguyen Avatar answered Sep 19 '22 01:09

Khoa Nguyen