i'm noob. This is my problem when i try.

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

current directory: /var/lib/gems/2.3.0/gems/nio4r-1.2.1/ext/nio4r

/usr/bin/ruby2.3 -r ./siteconf20160630-19108-12sbtb7.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/nio4r-1.2.1 for inspection. Results logged to /var/lib/gems/2.3.0/extensions/x86-linux/2.3.0/nio4r-1.2.1/gem_make.out

  • What commands did you use to try to install Rails?
    – edwinksl
    Jul 1, 2016 at 1:31

1 Answer 1


I needed to install ruby-dev:

sudo apt-get install ruby-dev zlib1g-dev liblzma-dev

Cf: This question on StackOverflow. It recommends sudo apt-get install build-essential patch first, but my system didn't need that.

  • Simply sudo apt install ruby-dev did it for me on 17.10 Sep 30, 2017 at 13:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .