我正在使用 Arch Linux 并安装了 Ruby(这是 2.0.0 版)。
当我安装 Ruby 时,它说我应该添加:
$(ruby -rubygems -e "puts Gem.user_dir")/bin
在我的路径中,我将它添加到 .bashrc
当我尝试 gem install rails 或任何其他 gem 时,它给出错误:无法构建 gem native 扩展。这是完整的错误:
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 不存在这个问题。还有其他我可以尝试的选择吗?
提前致谢!
最佳答案
要构建 native 扩展,您需要 c++ 编译器和工具。这个说的很清楚:
sh: make: command not found
除了 make
实用程序,您显然需要编译器本身(例如 gcc
)和公司。因此,
sudo apt-get install gcc
会成功的。顺便说一句,上面正确建议的 RVM 方式肯定也需要构建工具。
关于ruby-on-rails - gem 安装 : ERROR: Failed to build gem native extension,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17385111/