我是ruby on rails的新手,当我尝试运行基本命令时,我不断收到链接器错误。
我之前发布了this关于如何安装pg gem的问题,虽然该解决方案在2周前工作,但由于某些原因它不再起作用。
我也试过跟踪这个tutorial以获取ruby on rails,然后执行
$ rails new blog
$ cd blog
$ rails server
我得到了
Could not find gem 'sqlite3 (>= 0) ruby' in the gems available on this machine.
和bundle install给我
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
/Users/mahireusufzai/.rbenv/versions/2.1.1/bin/ruby extconf.rb
checking for sqlite3.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 options.
...
/Users/mahireusufzai/.rbenv/versions/2.1.1/lib/ruby/2.1.0/mkmf.rb:456:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from /Users/mahireusufzai/.rbenv/versions/2.1.1/lib/ruby/2.1.0/mkmf.rb:587:in `try_cpp'
from /Users/mahireusufzai/.rbenv/versions/2.1.1/lib/ruby/2.1.0/mkmf.rb:1120:in `block in find_header'
from /Users/mahireusufzai/.rbenv/versions/2.1.1/lib/ruby/2.1.0/mkmf.rb:918:in `block in checking_for'
from /Users/mahireusufzai/.rbenv/versions/2.1.1/lib/ruby/2.1.0/mkmf.rb:351:in `block (2 levels) in postpone'
from /Users/mahireusufzai/.rbenv/versions/2.1.1/lib/ruby/2.1.0/mkmf.rb:321:in `open'
from /Users/mahireusufzai/.rbenv/versions/2.1.1/lib/ruby/2.1.0/mkmf.rb:351:in `block in postpone'
from /Users/mahireusufzai/.rbenv/versions/2.1.1/lib/ruby/2.1.0/mkmf.rb:321:in `open'
from /Users/mahireusufzai/.rbenv/versions/2.1.1/lib/ruby/2.1.0/mkmf.rb:347:in `postpone'
from /Users/mahireusufzai/.rbenv/versions/2.1.1/lib/ruby/2.1.0/mkmf.rb:917:in `checking_for'
from /Users/mahireusufzai/.rbenv/versions/2.1.1/lib/ruby/2.1.0/mkmf.rb:1119:in `find_header'
from extconf.rb:35:in `<main>'
extconf failed, exit code 1
Gem files will remain installed in /Users/mahireusufzai/rubyTests/blog/vendor/cache/ruby/2.1.0/gems/sqlite3-1.3.9 for inspection.
Results logged to /Users/mahireusufzai/rubyTests/blog/vendor/cache/ruby/2.1.0/extensions/x86_64-darwin-13/2.1.0-static/sqlite3-1.3.9/gem_make.out
An error occurred while installing sqlite3 (1.3.9), and Bundler cannot continue.
Make sure that `gem install sqlite3 -v '1.3.9'` succeeds before bundling.
这两个消息看起来非常相似,并且我尝试的其他SO问题的解决方案都没有起作用。我正在使用OSX,所以我想知道问题是否与Xcode有关。
答案 0 :(得分:1)
当它说“你必须首先安装开发工具”时。它给你的问题。
它正在尝试在本地计算机上构建代码,但无法找到OS X开发工具和编译器。
尝试在命令行上运行它,然后再试一次:
xcode-select --install
编辑:也按照第一个错误中的建议检查mkmf.log。