简体   繁体   中英

Installing Ruby - Failed to build gem native extension

I don't know anything about the stuff that you write here :) I tried to search for answers online, as I usually do, but unfortunately, couldn't find anything specific.

I am trying to install Ruby on Rails, according to a description from here Rails Tutorial

I have installed Bash on Ubuntu on Windows. Could you tell me what have I done wrong? Or how can I fix it to install it properly?

when I check ruby version it shows me:

ruby 2.3.1p112 (2016-04-26) [x86-64-linux-gnu]

However an error appears:

ERROR: Failed to build gem native extension.

current directory: /var/lib/gems/2.3.0./gems/nio4r-2.1.0/ext/nio4r/usr/bin/ruby2.3 -r ./siteconf20170726-93-g151dm.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-2.1.0 for inspection.
Results logged to /var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0/nio4r-2.1.0/gem_make.out

I have also done:

apt-get install make
apt-get install ruby-dev

And now something different appeared:

    ERROR: Failed to build gem native extension.

    current directory: /var/lib/gems/2.3.0./gems/nio4r-2.1.0/ext/nio4r/usr/bin/ruby2.3 -r ./siteconf20170726-530-13b2fuh.rb extconf.rb
checking for unistd.h...***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 option.

The rest of the code can be found in the file - too much things to write by hand. :) Ruby 2- command line pict

Please help!! I want to learn Ruby :) :)

Plus, is there a way to copy command line and to paste it somehow or do I have to put it here letter by letter? :)

Try these commands:

sudo apt-get install build-essential patch

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

Hope it will help!

I also recommend you to install RVM .

Then run rvm install your_version to install an essential ruby version. You can choose any version you need. For instance rvm install 2.4.1

After those steps, run following commands:

gem install bundler

gem install rails

You need ruby development files to build (& install) native extensions
sudo apt-get install ruby-dev

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM