header-ruby-logoIf you’re still plagued by having to use Ruby 1.9.3 and you may be using, idk, Vagrant or any other type of testing environment, or just your own machine, you may have encountered the following error when installing either “debugger-ruby_core_source” or the “debugger-linecache” package.

This can particularly happen if you’re using RVM or other ruby version managers

Now, most stackoverflow answers and blogs will tell you to issue the following command:

    gem install debugger-ruby_core_source -v 1.2.3 --no-rdoc --no-ri -- --with-ruby-include=$rvm_path/src/ruby-1.9.3-p484
    gem install debugger-linecache -v 1.1.2 --no-rdoc --no-ri -- --with-ruby-include=$rvm_path/src/ruby-1.9.3-p484

Note that some sites may even say “install debugger-ruby_core_source first!” but that doesn’t work. And you still get this message:

ERROR:  Error installing debugger-linecache:
    ERROR: Failed to build gem native extension.

    /usr/local/rvm/rubies/ruby-1.9.3-p484/bin/ruby extconf.rb --with-ruby-include=/usr/local/rvm/rubies/ruby-1.9.3-p484
checking for vm_core.h... no
checking for vm_core.h... no
Makefile creation failed
No source for ruby-1.9.3-p484 provided with debugger-ruby_core_source gem.
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.

Provided configuration options:

Gem files will remain installed in /usr/local/rvm/gems/ruby-1.9.3-p484/gems/debugger-linecache-1.1.2 for inspection.
Results logged to /usr/local/rvm/gems/ruby-1.9.3-p484/gems/debugger-linecache-1.1.2/ext/trace_nums/gem_make.out

So what’s going on? I’ll tell you.

Full-Proof Installation

First, let me tell you how you should be installing RVM and Ruby 1.9.3 in vagrant.

Step 1: Install RVM and Ruby

Here’s the command:

# install RVM and Ruby
curl -L https://get.rvm.io | bash -s stable
source /usr/local/rvm/scripts/rvm
rvm use --install 1.9.3

Got it? Awesome.

Step 2: Fetch Ruby Source Code

Here comes the important part. INSTALL THE RUBY SOURCE CODE! This is the part NO ONE tells you. Here’s what you add right below that installation:

rvm fetch ruby-1.9.3-p484

Whoa, whoa, yep. That’s it. When your package tells you it can’t find vm_core, or that it can’t compile, this is probably the culprit. So make sure you fetch the source code.

Step 3: Install Debugger-Ruby-Core_Source first

If it wasn’t enough, we’ll install this nifty package first. This was the original fix on ruby’s github issue page. It works, some of the time, in some instances, sometimes. Let’s be sure we got it covered.

gem install debugger-ruby_core_source -v 1.2.3 --no-rdoc --no-ri -- --with-ruby-include=$rvm_path/src/ruby-1.9.3-p484

Ahh, what are all these damn options? More fallbacks:

  • “-v 1.2.3” specify correct debugger-ruby_core_source version that works with your debugger-linecache.
  • “–no-rdoc –no-ri” don’t install documentation!
  • “– –with-ruby-include=$rvm_path/src/ruby-1.9.3-p484” this makes sure that everything gets compiled correctly. Remember how we fetched the ruby source? Here’s where it gets used!

Step 4: Install Debugger-linecache

Ahh, finally here. This step is basically almost the same as the one above:

gem install debugger-linecache -v 1.1.2 --no-rdoc --no-ri -- --with-ruby-include=$rvm_path/src/ruby-1.9.3-p484

Yay! And watch the success roll out.


Jk. But yeah, make sure to reference this article if you use it.