Error: Failed to build gem native extension when trying to download Rubocop
Do sudo gem install rake
and then do sudo gem install rubocop
again and it should work.
It doesn't seem to matter that you have the right version of rake installed. For me rake --version
reported 10.5.0
but I was still getting the same error message as you.
Looking at the error message, it is looking for rake
at a specific path, not just anywhere on my PATH
:
/usr/bin/ruby2.3: No such file or directory -- /usr/share/rubygems-integration/all/gems/rake-10.5.0/bin/rake (LoadError)
which rake
reports /usr/local/bin/rake
, not /usr/share/rubygems-integration/all/gems/rake-10.5.0/bin/rake
.
And in fact, as the error message says, there is no file at /usr/share/rubygems-integration/all/gems/rake-10.5.0/bin/rake
.
This is probably to do with rake
having been apt-get install
ed rather than gem install
ed. sudo gem install rake
creates that file.
I was able to resolve this problem with
sudo mkdir -p /usr/share/rubygems-integration/all/gems/rake-10.5.0/bin
sudo ln -s /usr/bin/rake /usr/share/rubygems-integration/all/gems/rake-10.5.0/bin/
See this commit on GitHub.