在Mavericks升级后,新的Rails应用程序无法完成捆绑安装

时间:2014-09-08 17:33:13

标签: ruby-on-rails xcode sqlite osx-mavericks

我的近期目标是继续从RailsApp运行一些教程。我以前没有遇到过运行rails和编写应用程序以及做一些旧的教程的问题。一个新的出现了使用模板文件的启动应用程序。我需要升级我的红宝石和放大器为此版本的rails版本,但它仍然不起作用(问题:Error with RailsApps starter app for rails-devise-roles tutorial)所以我继续升级小牛队。

我的问题是如何让rails创建一个新的应用程序并运行?我现在不能发展任何东西。我不知道如何恢复到旧版本的ruby(也许是不使用sqlite3的版本?)[<

我用google搜索&堆栈溢出搜索类似的问题,到目前为止,没有一个解决方案对我有用。

基本信息: $ ruby​​

/Users/suzanne/.rvm/rubies/ruby-2.1.2/bin/ruby

$ ruby​​ -v

ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-darwin13.0]

$ xcode-select --print-path

/Applications/Xcode.app/Contents/Developer

我还打开了XCode,打开后请求更新的库。启动页面上列出的版本是版本5.1.1(5B1008)

现在我已经完成了以下步骤来测试rails并获得一个基本的新应用程序

mkdir myapp
cd myapp
rvm use ruby-2.1.2@myapp --ruby-version --create
gem install rails
rails new . 

此时我收到此错误:

Could not find gem 'sqlite3 (>= 0) ruby' in the gems available on this machine.

安装了XCode,安装了gcc,安装了sqlite3。

$ whereis sqlite3

/usr/bin/sqlite3

$ bundle install

Fetching gem metadata from https://rubygems.org/..........
Resolving dependencies...
Using rake 10.3.2
Using i18n 0.6.11
Using json 1.8.1
Using minitest 5.4.1
Using thread_safe 0.3.4
Using tzinfo 1.2.2
Using activesupport 4.1.5
Using builder 3.2.2
Using erubis 2.7.0
Using actionview 4.1.5
Using rack 1.5.2
Using rack-test 0.6.2
Using actionpack 4.1.5
Using mime-types 1.25.1
Using polyglot 0.3.5
Using treetop 1.4.15
Using mail 2.5.4
Using actionmailer 4.1.5
Using activemodel 4.1.5
Using arel 5.0.1.20140414130214
Using activerecord 4.1.5
Using bundler 1.7.2
Using coffee-script-source 1.8.0
Using execjs 2.2.1
Using coffee-script 2.3.0
Using thor 0.19.1
Using railties 4.1.5
Using coffee-rails 4.0.1
Using hike 1.2.3
Using multi_json 1.10.1
Using jbuilder 2.1.3
Using jquery-rails 3.1.2
Using tilt 1.4.1
Using sprockets 2.11.0
Using sprockets-rails 2.1.4
Using rails 4.1.5
Using rdoc 4.1.1
Using sass 3.2.19
Using sass-rails 4.0.3
Using sdoc 0.4.1
Using spring 1.1.3

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    /Users/suzanne/.rvm/rubies/ruby-2.1.2/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.

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=/Users/suzanne/.rvm/rubies/ruby-2.1.2/bin/ruby
    --with-sqlite3-dir
    --without-sqlite3-dir
    --with-sqlite3-include
    --without-sqlite3-include=${sqlite3-dir}/include
    --with-sqlite3-lib
    --without-sqlite3-lib=${sqlite3-dir}/lib
    --enable-local
    --disable-local
/Users/suzanne/.rvm/rubies/ruby-2.1.2/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/suzanne/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/mkmf.rb:587:in `try_cpp'
    from /Users/suzanne/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/mkmf.rb:1120:in `block in find_header'
    from /Users/suzanne/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/mkmf.rb:918:in `block in checking_for'
    from /Users/suzanne/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/mkmf.rb:351:in `block (2 levels) in postpone'
    from /Users/suzanne/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/mkmf.rb:321:in `open'
    from /Users/suzanne/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/mkmf.rb:351:in `block in postpone'
    from /Users/suzanne/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/mkmf.rb:321:in `open'
    from /Users/suzanne/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/mkmf.rb:347:in `postpone'
    from /Users/suzanne/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/mkmf.rb:917:in `checking_for'
    from /Users/suzanne/.rvm/rubies/ruby-2.1.2/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/suzanne/.rvm/gems/ruby-2.1.2@myapp/gems/sqlite3-1.3.9 for inspection.
Results logged to /Users/suzanne/.rvm/gems/ruby-2.1.2@myapp/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.

$ gem install sqlite3 -v'1.3.9'

Building native extensions.  This could take a while...
ERROR:  Error installing sqlite3:
    ERROR: Failed to build gem native extension.

    /Users/suzanne/.rvm/rubies/ruby-2.1.2/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.

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=/Users/suzanne/.rvm/rubies/ruby-2.1.2/bin/ruby
    --with-sqlite3-dir
    --without-sqlite3-dir
    --with-sqlite3-include
    --without-sqlite3-include=${sqlite3-dir}/include
    --with-sqlite3-lib
    --without-sqlite3-lib=${sqlite3-dir}/lib
    --enable-local
    --disable-local
/Users/suzanne/.rvm/rubies/ruby-2.1.2/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/suzanne/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/mkmf.rb:587:in `try_cpp'
    from /Users/suzanne/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/mkmf.rb:1120:in `block in find_header'
    from /Users/suzanne/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/mkmf.rb:918:in `block in checking_for'
    from /Users/suzanne/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/mkmf.rb:351:in `block (2 levels) in postpone'
    from /Users/suzanne/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/mkmf.rb:321:in `open'
    from /Users/suzanne/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/mkmf.rb:351:in `block in postpone'
    from /Users/suzanne/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/mkmf.rb:321:in `open'
    from /Users/suzanne/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/mkmf.rb:347:in `postpone'
    from /Users/suzanne/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/mkmf.rb:917:in `checking_for'
    from /Users/suzanne/.rvm/rubies/ruby-2.1.2/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/suzanne/.rvm/gems/ruby-2.1.2@myapp/gems/sqlite3-1.3.9 for inspection.
Results logged to /Users/suzanne/.rvm/gems/ruby-2.1.2@myapp/extensions/x86_64-darwin-13/2.1.0-static/sqlite3-1.3.9/gem_make.out

3 个答案:

答案 0 :(得分:1)

小牛队发生了变化,这意味着你必须安装命令行工具。

输入终端窗口

xcode-select --install

然后,系统会提示您安装命令行工具

一旦完成,你应该能够建立你的宝石

答案 1 :(得分:0)

尝试gem install sqlite3 -- --with-sqlite3-dir=/opt/local,然后再次运行bundle install

如果这不起作用,我认为你只需要安装sqlite3。如果你有Homebrew,这应该有效:

brew install sqlite3

答案 2 :(得分:0)

在CentOS 6.5上运行Rails 4.1.5会遇到同样的问题。

我修理了:

  1. 安装sqlite开发库(在CentOS it&#39; s $ yum install -y sqlite-devel);和
  2. 使用gem install sqlite3安装sqlite3 gem。
  3. 之后我能够创建一个新的rails项目。