gem 安装:错误:无法构建 gem 本机扩展 [英] gem install: ERROR: Failed to build gem native extension
问题描述
我正在使用 Arch Linux 并安装了 Ruby(这是 2.0.0 版).
I am using Arch Linux and installed Ruby (this is version 2.0.0).
当我安装 Ruby 时,它说我应该添加:
When I installed Ruby it said I should add:
$(ruby -rubygems -e "puts Gem.user_dir")/bin
到我的路径,我将它添加到 .bashrc
to my path, I added it to .bashrc
当我尝试 gem install rails 或任何其他 gem 时,它给出错误:无法构建 gem 本机扩展.这是完整的错误:
When I try to gem install rails or any other gem it gives the Error: Failed to build gem native extension. this is the full error:
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /usr/lib/ruby/gems/2.0.0 directory.
[alexander@localhost ~]$ sudo gem install rails --no-user-install
Building native extensions. This could take a while...
ERROR: Error installing rails:
ERROR: Failed to build gem native extension.
/usr/bin/ruby extconf.rb
creating Makefile
make "DESTDIR="
sh: make: command not found
Gem files will remain installed in /usr/lib/ruby/gems/2.0.0/gems/atomic-1.1.10 for inspection.
当我查看这个错误时,我看到人们通过安装 ruby-dev 包来解决这个错误,但是这在 Arch Linux 中不存在.我可以尝试其他任何选择吗?
When I look this error up I see that people solve this error by installing ruby-dev packages, however this does not exist for Arch Linux. Any other option that I can try?
提前致谢!
推荐答案
要构建本机扩展,您需要 C++ 编译器和工具.这句话说的很清楚:
To build native extensions you need the c++-compiler and tools. This is said clearly:
sh: make: command not found
除了 make
实用程序,您显然需要编译器本身(例如 gcc
)和公司.因此,
Except of make
utility you obviously need the compiler itself (e. g. gcc
) and company. Thus,
sudo apt-get install gcc
会解决问题.顺便说一句,上面正确建议的 RVM 方式肯定也需要构建工具.
will do the trick. BTW, the properly suggested above RVM-way will definitely require build-tools as well.
这篇关于gem 安装:错误:无法构建 gem 本机扩展的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!