gem install:错误:无法构建gem原生扩展

我使用的是Arch Linux并安装了Ruby(这是2.0.0版本)。

当我安装Ruby时,它说我应该添加:

$(ruby -rubygems -e "puts Gem.user_dir")/bin 

在我的路上,我把它添加到.bashrc

当我尝试gem安装rails或任何其他gem时,它会给出错误:无法构建gem原生扩展。 这是完整的错误:

 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来说并不存在。 我还可以尝试其他任何选项吗?

提前致谢!

要构建本机扩展,您需要c ++ – 编译器和工具。 这清楚地说:

 sh: make: command not found 

除了make实用程序,你显然需要编译器本身(例如gcc )和公司。 从而,

 sudo apt-get install gcc 

会做的伎俩。 顺便说一句,上面正确建议的RVM方式肯定也需要构建工具。

试试这个命令

sudo apt-get install ruby​​1.9.1-dev build-essential

sudo apt-get install ruby​​-compass