rubyrubygemsbyebug

error when try install byebug


I get the error when I try to install byebug. What's the reason for this?

sudo gem install byebug -v '10.0.1'
Building native extensions. This could take a while...
ERROR:  Error installing byebug:
    ERROR: Failed to build gem native extension.

    current directory: /var/lib/gems/2.3.0/gems/byebug-10.0.1/ext/byebug
/usr/bin/ruby2.3 -r ./siteconf20180326-12662-69j4pj.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.3.0/gems/byebug-10.0.1 for inspection.
Results logged to /var/lib/gems/2.3.0/extensions/x86-linux/2.3.0/byebug-10.0.1/gem_make.out

Solution

  • This error mkmf.rb can't find header files for ruby at /usr/lib/ruby/include/ruby.h is telling you it can't find the header file needed to build the gem.

    Also, why are you installing with sudo ? What system are you on? Are you using a version manager rvm or rbenv ? I recommend https://rvm.io/rvm/install

    Try to install with system libraries

    gem install byebug -v '10.0.1' --use-system-libraries
    

    If that doesn't work please run the following commands and post their output:

    which ruby
    ruby -v
    gem -v
    echo "${PATH//:/\n}" #may not work if your not on an *nix system
    

    UPDATE:

    Go to root of the project. Pick a ruby version but it looks like the ruby is pointing to a system ruby, not an rvm version. Try install a new ruby:

    rvm install 2.4.1
    rvm use 2.4.1
    gem install byebug
    

    If you have a Gemfile in your project and if it has ruby -v make sure it matches your version you set with rvm and add gem 'byebug' to your Gemfile then run

    bundle install