新手问题 安装 rails 出错

qdlin · 2015年12月19日 · 最后由 qdlin 回复于 2015年12月20日 · 3057 次阅读

$ ruby -v ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-linux] $ gem -v 2.4.5.1 $ rvm -v rvm 1.26.11 (latest) by Wayne E. Seguin [email protected], Michal Papis [email protected] [https://rvm.io/] $ gem install rails ERROR: Loading command: install (LoadError) cannot load such file -- zlib ERROR: While executing gem ... (NoMethodError) undefined method `invoke_with_build_args' for nil:NilClass

$:sudo apt-get install libssl-dev $:gem install rails 依然报错

zlib 有么

#1 楼 @i5ting 谢谢 sudo apt-get install zlib1g sudo apt-get install zlib1g.dev

这两个都安装了,再次安装出现以下错误。 gem install rails Building native extensions. This could take a while... ERROR: Error installing rails: ERROR: Failed to build gem native extension.

/home/qdl/.rvm/rubies/ruby-2.2.4/bin/ruby extconf.rb checking if the C compiler accepts ... *** 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 options.

Provided configuration options: --with-opt-dir --without-opt-dir --with-opt-include --without-opt-include=${opt-dir}/include --with-opt-lib --without-opt-lib=${opt-dir}/lib --with-make-prog --without-make-prog --srcdir=. --curdir --ruby=/home/qdl/.rvm/rubies/ruby-2.2.4/bin/$(RUBY_BASE_NAME) --help --clean /home/qdl/.rvm/rubies/ruby-2.2.4/lib/ruby/2.2.0/mkmf.rb:456:in try_do': The compiler failed to generate an executable file. (RuntimeError) You have to install development tools first. from /home/qdl/.rvm/rubies/ruby-2.2.4/lib/ruby/2.2.0/mkmf.rb:571:inblock in try_compile' from /home/qdl/.rvm/rubies/ruby-2.2.4/lib/ruby/2.2.0/mkmf.rb:522:in with_werror' from /home/qdl/.rvm/rubies/ruby-2.2.4/lib/ruby/2.2.0/mkmf.rb:571:intry_compile' from extconf.rb:80:in nokogiri_try_compile' from extconf.rb:87:inblock in add_cflags' from /home/qdl/.rvm/rubies/ruby-2.2.4/lib/ruby/2.2.0/mkmf.rb:619:in with_cflags' from extconf.rb:86:inadd_cflags' from extconf.rb:336:in `

'

Gem files will remain installed in /home/qdl/.rvm/gems/ruby-2.2.4/gems/nokogiri-1.6.7.1 for inspection. Results logged to /home/qdl/.rvm/gems/ruby-2.2.4/gems/nokogiri-1.6.7.1/ext/nokogiri/gem_make.out

然后根据错误提示,安装: sudo apt-get install build-essential patch sudo apt-get install libgmp-dev

然后再安装:gem install rails rails -v Rails 4.2.5

OK 了,谢谢

需要 登录 后方可回复, 如果你还没有账号请 注册新账号