cotag / http-parser

A super fast http parser for ruby
MIT License
18 stars 17 forks source link

http-parser fails to build in `current directory: /var/lib/gems/3.0.0/gems/http-parser-1.2.3/ext` #17

Open erwinwolff opened 2 years ago

erwinwolff commented 2 years ago

I have this weird error. When I do something like this gem install http-parser --platform=ruby

I get the output

Building native extensions. This could take a while...
ERROR:  Error installing http-parser:
    ERROR: Failed to build gem native extension.

    current directory: /var/lib/gems/3.0.0/gems/http-parser-1.2.3/ext
/usr/bin/ruby -I/usr/lib/ruby/site_ruby/3.0.0 -rrubygems /var/lib/gems/3.0.0/gems/rake-13.0.6/exe/rake RUBYARCHDIR\=/var/lib/gems/3.0.0/extensions/x86_64-linux/3.0.0-static/http-parser-1.2.3 RUBYLIBDIR\=/var/lib/gems/3.0.0/extensions/x86_64-linux/3.0.0-static/http-parser-1.2.3
rake aborted!
ArgumentError: wrong number of arguments (given 2, expected 1)
/var/lib/gems/3.0.0/gems/rake-13.0.6/exe/rake:27:in `<main>'
Tasks: TOP => default => x86_64-linux/libhttp-parser-ext.so => x86_64-linux/http-parser/http_parser.o => x86_64-linux/http-parser
(See full trace by running task with --trace)

rake failed, exit code 1

Gem files will remain installed in /var/lib/gems/3.0.0/gems/http-parser-1.2.3 for inspection.
Results logged to /var/lib/gems/3.0.0/extensions/x86_64-linux/3.0.0-static/http-parser-1.2.3/gem_make.out

HOWEVER ....

When I go to the directory /var/lib/gems/3.0.0/gems/http-parser-1.2.3/ (note that I dont include the /ext/ part)

And I execute the command /usr/bin/ruby -I/usr/lib/ruby/site_ruby/3.0.0 -rrubygems /var/lib/gems/3.0.0/gems/rake-13.0.6/exe/rake RUBYARCHDIR\=/var/lib/gems/3.0.0/extensions/x86_64-linux/3.0.0-static/http-parser-1.2.3 RUBYLIBDIR\=/var/lib/gems/3.0.0/extensions/x86_64-linux/3.0.0-static/http-parser-1.2.3

I get the correct output:

mkdir -p x86_64-linux/http-parser
gcc -fexceptions -O -fno-omit-frame-pointer -fno-strict-aliasing -Wall -Wextra -O3 -fPIC   -o x86_64-linux/http-parser/http_parser.o -c ./http-parser/http_parser.c
gcc -shared -o x86_64-linux/libhttp-parser-ext.so x86_64-linux/http-parser/http_parser.o -fexceptions
/usr/bin/ruby -I/var/lib/gems/3.0.0/gems/rspec-support-3.11.0/lib:/var/lib/gems/3.0.0/gems/rspec-core-3.11.0/lib /var/lib/gems/3.0.0/gems/rspec-core-3.11.0/exe/rspec --pattern spec/\*\*\{,/\*/\*\*\}/\*_spec.rb
..................................

Finished in 0.02042 seconds (files took 0.21255 seconds to load)
34 examples, 0 failures

in the /var/lib/gems/3.0.0/gems/http-parser-1.2.3/ext directory I get the above output again.

So I think there might be something wrong with the packaging

jirutka commented 2 years ago

The built native extensions should be installed into $GEM_HOME/extensions/<platform>/<ruby-abi>/<gem-name>-<gem-version>, but this gem installs it into $GEM_HOME/gems/<gem-name>-<gem-version>/ext/<platform>.

jirutka commented 2 years ago

Moreover, it bundles an ancient version of the http-parser library that contains multiple vulnerabilities and it doesn’t even try to use a system-provided libhttp-parser. This gem is dangerous.