Mark98074
Mark98074

Reputation: 43

Error: Failed to build gem native extension (can't find header files for ruby.h)

I'm trying to install azure_mgmt_storage on Ubuntu 14.04.5 LTS. (And I'm new to Linux and Ruby.) Here's the command I tried:

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

current directory: /var/lib/gems/2.4.0/gems/unf_ext-0.0.7.5/ext/unf_ext
/usr/bin/ruby2.4 -r ./siteconf20180221-102454-dq4ty1.rb extconf.rb
mkmf.rb can't find header files for ruby at /usr/lib/ruby/include/ruby.h

I've have Rails 4.02 installed, and Ruby 2.4.3p205 (2017-12-14 revision 61247). Based on another post, I also ran these:

sudo apt-get install ruby-dev
sudo apt-get install ruby2.0-dev
sudo apt-get install ruby2.2-dev
sudo apt-get install ruby2.3-dev

How do I get ruby.h installed? Thanks!

Upvotes: 4

Views: 4075

Answers (2)

Peyman Karimi
Peyman Karimi

Reputation: 345

I've had the same problem, and finally solved it by:

apt-get --reinstall install ruby

Upvotes: 2

Thilo
Thilo

Reputation: 17735

Well I suspect you actually need ruby2.4-dev if you're using ruby 2.4. But I'd recommend not using system ruby and installing gems globally with sudo in the first place. Using a ruby environment manager such as rbenv is the best way to avoid dependency hell. Here's a good overview of the available options: http://kgrz.io/programmers-guide-to-choosing-ruby-version-manager.html

Upvotes: 4

Related Questions