Skip to content

Instantly share code, notes, and snippets.

@dwbutler
Last active December 10, 2015 22:08
Show Gist options
  • Save dwbutler/4499941 to your computer and use it in GitHub Desktop.
Save dwbutler/4499941 to your computer and use it in GitHub Desktop.
Trying to get RDF::Raptor to run under FFI 1.3.0. This gist documents https://github.com/ffi/ffi/issues/245

##Issue ffi/ffi#245

TypeError: no implicit conversion from nil to integer

##Platform

uname -a
Darwin dbutler.local 12.2.0 Darwin Kernel Version 12.2.0: Sat Aug 25 00:48:52 PDT 2012; root:xnu-2050.18.24~1/RELEASE_X86_64 x86_64

I have also seen the issue occur in Ubuntu (on Travis CI).

##Running ###Installing libraptor OSX:

brew install raptor

Ubuntu:

sudo apt-get install libraptor2-0
sudo ln -s /usr/lib/libraptor2.so.0 /usr/lib/libraptor2.so

###Running the code

git clone -b ffi-1.3.0 [email protected]:ruby-rdf/rdf-raptor.git
cd rdf-raptor
bundle
rake

##Travis CI I tried running a Travis build with rbx-head/FFI 1.2.0, but it looks like Travis isn't yet picking up the pre-bundled gem. https://travis-ci.org/ruby-rdf/rdf-raptor/builds/4060556

I also tried running Travis with rbx-head/FFI 1.3.0, but got more strange errors: https://travis-ci.org/ruby-rdf/rdf-raptor/jobs/4060688

Here's a sample run with Ruby 1.9.3 / FFI 1.3.0: https://travis-ci.org/ruby-rdf/rdf-raptor/jobs/4061068

##Test Results (Duplicate errors redacted)

  6) RDF::Raptor::RDFXML::Reader interface should yield triples
     Failure/Error: @reader.each_triple do |subject, predicate, object|
     TypeError:
       no implicit conversion from nil to integer
     # ./lib/rdf/raptor/ffi/v2/parser.rb:202:in `raptor_parser_parse_chunk'
     # ./lib/rdf/raptor/ffi/v2/parser.rb:202:in `parse_end!'
     # ./lib/rdf/raptor/ffi/v2/parser.rb:156:in `parse_stream'
     # ./lib/rdf/raptor/ffi/v2/parser.rb:85:in `parse'
     # ./lib/rdf/raptor/ffi.rb:112:in `parse'
     # ./lib/rdf/raptor/ffi.rb:94:in `each_triple'
     # ./spec/format/rdfxml_spec.rb:71

  7) RDF::Raptor::RDFXML::Reader interface should open and parse a file
     Failure/Error: RDF::Reader.open("etc/doap.xml") do |reader|
     TypeError:
       no implicit conversion from nil to integer
     # ./lib/rdf/raptor/format.rb:22:in `raptor_world_guess_parser_name'
     # ./lib/rdf/raptor/format.rb:22:in `detect'
     # ./spec/format/rdfxml_spec.rb:77

##Relevant Code lib/rdf/raptor/ffi/v2.rb

Line 86: attach_function :raptor_world_guess_parser_name, [:raptor_world, :raptor_uri, :mime_type, :buffer, :size_t, :string], :string
Line 94: attach_function :raptor_parser_parse_chunk, [:raptor_parser, :string, :size_t, :int], :int

lib/rdf/raptor/ffi/v2/parser.rb

Line 202: result = V2.raptor_parser_parse_chunk(self, nil, 0, 1) # EOF

lib/rdf/raptor/format.rb

Line 22: parser_name = RDF::Raptor::FFI::V2.raptor_world_guess_parser_name(RDF::Raptor::FFI::V2.world, nil, nil, sample, sample.length, nil)

##Raptor Documentation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment