1

I am trying to get a widget from https://gist.github.com/iainjmitchell/5271830 to work in dashing. I get the error below when starting dashing.

scheduler caught exception:

uninitialized constant BbcNews::Nokogiri'
C:/dashboard/jobs/news.rb:8:in `latest_headlines'
C:/dashboard/jobs/news.rb:30:in `block in <top <required>>

I have tried the suggestions of adding 'nokogori' to the top of the news.rb file and it fails to load 'nokogiri/nokogiri'

news.rb

class BbcNews
  def initialize()
    @http = Net::HTTP.new('feeds.bbci.co.uk')
  end

  def latest_headlines()
    response = @http.request(Net::HTTP::Get.new("/news/rss.xml"))
    doc = Nokogiri::XML(response.body)
    news_headlines = [];
    doc.xpath('//channel/item').each do |news_item|
      news_headline = NewsHeadlineBuilder.BuildFrom(news_item)
      news_headlines.push(news_headline)
    end
    news_headlines
  end
end

class NewsHeadlineBuilder
  def self.BuildFrom(news_item)
    {
      title: news_item.xpath('title').text, 
      description: news_item.xpath('description').text, 
    }
  end
end

@BBC_News = BbcNews.new()

SCHEDULER.every '1m', :first_in => 0 do |job|
  headlines = @BBC_News.latest_headlines
  send_event('news', { :headlines => headlines})
end

if i add require 'nokogiri' to the top of news.rb then i get the following errors:

C:\dashboard>dashing start
C:/Ruby22/lib/ruby/gems/2.2.0/gems/backports-  3.6.4/lib/backports/std_lib.rb:9:in `require': cannot load such file -- nokogiri/nokogiri (LoadError)
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/backports-3.6.4/lib/backports/std_lib.rb:9:in `require_with_backports'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/nokogiri-1.6.6.2-x86-mingw32/lib/nokogiri.rb:29:in `rescue in <top (required)>'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/nokogiri-1.6.6.2-x86-mingw32/lib/nokogiri.rb:25:in `<top (required)>'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/backports-3.6.4/lib/backports/std_lib.rb:9:in `require'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/backports-3.6.4/lib/backports/std_lib.rb:9:in `require_with_backports'
from C:/dashboard/jobs/news.rb:2:in `<top (required)>'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/backports-3.6.4/lib/backports/st d_lib.rb:9:in `require'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/backports-3.6.4/lib/backports/std_lib.rb:9:in `require_with_backports'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/dashing-1.3.4/lib/dashing/app.rb:157:in `block in require_glob'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/dashing-1.3.4/lib/dashing/app.rb:156:in `each'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/dashing-1.3.4/lib/dashing/app.rb:156:in `require_glob'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/dashing-1.3.4/lib/dashing/app.rb:167:in `<top (required)>'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/dashing-1.3.4/lib/dashing.rb:3:in `require'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/dashing-1.3.4/lib/dashing.rb:3:in `<top (required)>'
from config.ru:1:in `require'
from config.ru:1:in `block in <main>'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/rack-1.5.2/lib/rack/builder.rb:55:in `instance_eval'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/rack-1.5.2/lib/rack/builder.rb:55:in `initialize'
from config.ru:1:in `new'
from config.ru:1:in `<main>'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/thin-1.6.3/lib/rack/adapter/loader.rb:33:in `eval'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/thin-1.6.3/lib/rack/adapter/loader.rb:33:in `load'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/thin-1.6.3/lib/thin/controllers/controller.rb:182:in `load_rackup_config'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/thin-1.6.3/lib/thin/controllers/controller.rb:72:in `start'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/thin-1.6.3/lib/thin/runner.rb:200:in `run_command'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/thin-1.6.3/lib/thin/runner.rb:156:in `run!'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/thin-1.6.3/bin/thin:6:in `<top (required)>'
from C:/Ruby22/bin/thin:23:in `load'
from C:/Ruby22/bin/thin:23:in `<main>'
Ahmad Sherif
  • 5,923
  • 3
  • 21
  • 27
tom harrison
  • 3,273
  • 11
  • 42
  • 71
  • Do you have nokogiri gem instsalled? – Ahmad Sherif Mar 27 '15 at 11:05
  • I do yes, I can see the nokogiri file in c:/ruby22/bin and have run bundle install – tom harrison Mar 27 '15 at 11:10
  • Just to confirm, you have `require 'nokogiri'` at the top of the file and you run your script using `bundle exec ruby news.rb`, am I right? – Ahmad Sherif Mar 27 '15 at 11:12
  • I have required 'nokogiri at the top of the news.rb file, I am using http://dashing.io/ , it's a dashboard software, it runs the news.rb and when attempting to run the file it throws up the error – tom harrison Mar 27 '15 at 11:26
  • Alright, so do you run it using `bundle exec dashing start`? – Ahmad Sherif Mar 27 '15 at 11:29
  • I start it by going to the dashing dashboard - c:/dashboard and then running 'dashing start' which starts a nodejs localhost:3030 – tom harrison Mar 27 '15 at 11:31
  • OK, what's the output of running `bundle exec dashing start`? – Ahmad Sherif Mar 27 '15 at 11:36
  • that brings up the list of errors I have listed above. C:/Ruby22/lib/ruby/gems/2.2.0/gems/backports- 3.6.4/lib/backports/std_lib.rb:9:in etc.. – tom harrison Mar 27 '15 at 11:40
  • My guess is that nokogiri isn't installed correctly. I think its C extension wasn't installed/compiled correctly. Do you mind running `gem i nokogiri` and see if it's being installed correctly? – Ahmad Sherif Mar 27 '15 at 11:50
  • i get : Nokogiri is built with the packaged libraries: libxml2-2.9.2, libxslt-1.1.28, zl ib-1.2.8, libiconv-1.14. Successfully installed nokogiri-1.6.6.2-x86-mingw32 Parsing documentation for nokogiri-1.6.6.2-x86-mingw32 Done installing documentation for nokogiri after 2 seconds 1 gem installed – tom harrison Mar 27 '15 at 11:59
  • And is there a file named `nokogiri.so` or `nokogiri.dll` (or nokogiri with any extension) in `C:/Ruby22/lib/ruby/gems/2.2.0/gems/nokogiri-1.6.6.2-x86-mingw32/lib/nokogiri/`? – Ahmad Sherif Mar 27 '15 at 12:02
  • There's no nokogiri.so or nokogiri.dll in that file location, just css,html.syntax_error,version,xml,xslt and a bunch of folders. – tom harrison Mar 27 '15 at 12:05
  • There is a nokogiri.rb in C:\Ruby22\lib\ruby\gems\2.2.0\gems\nokogiri-1.6.6.2-x86-mingw32\lib – tom harrison Mar 27 '15 at 12:05
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/73932/discussion-between-ahmad-sherif-and-tom-harrison). – Ahmad Sherif Mar 27 '15 at 12:07

0 Answers0