rubyrubygemsrubocop

Rubocop installing error: Failed to build gems


I'm currently having this problem when i try to install Rubocop(I can't install nokigiri either):

~$ sudo gem install rubocop

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

    current directory: /var/lib/gems/2.5.0/gems/jaro_winkler-1.5.2/ext/jaro_winkler
/usr/bin/ruby2.5 -r ./siteconf20190320-24856-1cn9xqz.rb extconf.rb
mkmf.rb can't find header files for ruby at /usr/lib/ruby/include/ruby.h

extconf failed, exit code 1

Gem files will remain installed in /var/lib/gems/2.5.0/gems/jaro_winkler-1.5.2 for inspection.
Results logged to /var/lib/gems/2.5.0/extensions/x86_64-linux/2.5.0/jaro_winkler-1.5.2/gem_make.out

I've tried others solutions, but none worked. Anyone knows why i'm getting this error ?

Thx


Solution

  • You need to install development headers for ruby 2.5, you don't have a development environment installed:

    sudo apt-get install ruby2.5-dev

    May also be called -devel depending on your packaging system.