安装Ruby - 无法构建gem原生扩展

时间:2017-07-26 12:39:56

标签: ruby-on-rails ruby

我对你在这里写的东西一无所知:)我试图像往常一样在网上搜索答案,但不幸的是,找不到具体的东西。

我正在尝试安装Ruby on Rails,根据这里的描述Rails Tutorial

我在Windows上的Ubuntu上安装了Bash。你能告诉我我做错了什么吗?或者我该如何解决它才能正确安装?

当我查看ruby版本时,它会告诉我:

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

但是会出现错误:

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

我也做过:

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

现在出现了一些不同的东西:

    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.

其余的代码可以在文件中找到 - 手写的东西太多了。 :) Ruby 2- command line pict

请帮忙!!我想学习Ruby :) :)

另外,有没有办法复制命令行并以某种方式粘贴它或者我必须将它放在这里逐个字母? :)

2 个答案:

答案 0 :(得分:3)

尝试以下命令:

didDiscoverPeripheral

sudo apt-get install build-essential patch

希望它会有所帮助!

我还建议您安装RVM

然后运行sudo apt-get install ruby-dev zlib1g-dev liblzma-dev以安装必备的ruby版本。您可以选择所需的任何版本。例如rvm install your_version

完成这些步骤后,运行以下命令:

rvm install 2.4.1

gem install bundler

答案 1 :(得分:2)

您需要ruby开发文件来构建(和安装)原生扩展 sudo apt-get install ruby​​-dev