Rails(一个月Rails)"捆绑安装"失败,创造新的应用程序

时间:2014-05-14 06:02:27

标签: ruby-on-rails ruby sqlite gem

我整天都在网上寻找解决方案,但似乎无法找到解决这个问题的方法;我见过几乎相同的查询,但我对这些解决方案没有成功。  我刚刚开始使用One Month Rails,每次尝试创建一个新的应用程序时都是这样的:

Jaimess-MacBook-Pro:Desktop Jaimes$ rails new pinteresting
      create  
      create  README.rdoc
      create  Rakefile
      create  config.ru
      create  .gitignore
      create  Gemfile
      create  app
      create  app/assets/javascripts/application.js
      create  app/assets/stylesheets/application.css
      create  app/controllers/application_controller.rb
      create  app/helpers/application_helper.rb
      create  app/views/layouts/application.html.erb
      create  app/assets/images/.keep
      create  app/mailers/.keep
      create  app/models/.keep
      create  app/controllers/concerns/.keep
      create  app/models/concerns/.keep
      create  bin
      create  bin/bundle
      create  bin/rails
      create  bin/rake
      create  config
      create  config/routes.rb
      create  config/application.rb
      create  config/environment.rb
      create  config/secrets.yml
      create  config/environments
      create  config/environments/development.rb
      create  config/environments/production.rb
      create  config/environments/test.rb
      create  config/initializers
      create  config/initializers/backtrace_silencers.rb
      create  config/initializers/cookies_serializer.rb
      create  config/initializers/filter_parameter_logging.rb
      create  config/initializers/inflections.rb
      create  config/initializers/mime_types.rb
      create  config/initializers/session_store.rb
      create  config/initializers/wrap_parameters.rb
      create  config/locales
      create  config/locales/en.yml
      create  config/boot.rb
      create  config/database.yml
      create  db
      create  db/seeds.rb
      create  lib
      create  lib/tasks
      create  lib/tasks/.keep
      create  lib/assets
      create  lib/assets/.keep
      create  log
      create  log/.keep
      create  public
      create  public/404.html
      create  public/422.html
      create  public/500.html
      create  public/favicon.ico
      create  public/robots.txt
      create  test/fixtures
      create  test/fixtures/.keep
      create  test/controllers
      create  test/controllers/.keep
      create  test/mailers
      create  test/mailers/.keep
      create  test/models
      create  test/models/.keep
      create  test/helpers
      create  test/helpers/.keep
      create  test/integration
      create  test/integration/.keep
      create  test/test_helper.rb
      create  tmp/cache
      create  tmp/cache/assets
      create  vendor/assets/javascripts
      create  vendor/assets/javascripts/.keep
      create  vendor/assets/stylesheets
      create  vendor/assets/stylesheets/.keep
         run  bundle install

一切顺利,一旦捆绑安装完成,我会得到这个迷宫般的错误消息

Fetching gem metadata from https://rubygems.org/..........
Fetching additional metadata from https://rubygems.org/..
Resolving dependencies...
Using rake 10.3.1
Using i18n 0.6.9
Using json 1.8.1
Using minitest 5.3.3
Using thread_safe 0.3.3
Using tzinfo 1.1.0
Using activesupport 4.1.1
Using builder 3.2.2
Using erubis 2.7.0
Using actionview 4.1.1
Using rack 1.5.2
Using rack-test 0.6.2
Using actionpack 4.1.1
Using mime-types 1.25.1
Using polyglot 0.3.4
Using treetop 1.4.15
Using mail 2.5.4
Using actionmailer 4.1.1
Using activemodel 4.1.1
Using arel 5.0.1.20140414130214
Using activerecord 4.1.1
Using bundler 1.6.1
Using coffee-script-source 1.7.0
Using execjs 2.0.2
Using coffee-script 2.2.0
Using thor 0.19.1
Using railties 4.1.1
Using coffee-rails 4.0.1
Using hike 1.2.3
Using multi_json 1.10.0
Using jbuilder 2.0.7
Using jquery-rails 3.1.0
Using tilt 1.4.1
Using sprockets 2.11.0
Using sprockets-rails 2.1.3
Using rails 4.1.1
Using rdoc 4.1.1
Using sass 3.2.19
Using sass-rails 4.0.3
Using sdoc 0.4.0
Using spring 1.1.3

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

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

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/Jaimes/.rvm/rubies/ruby-2.1.1/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/Jaimes/.rvm/rubies/ruby-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/Jaimes/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/mkmf.rb:587:in `try_cpp'
    from /Users/Jaimes/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/mkmf.rb:1120:in `block in find_header'
    from /Users/Jaimes/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/mkmf.rb:918:in `block in checking_for'
    from /Users/Jaimes/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/mkmf.rb:351:in `block (2 levels) in postpone'
    from /Users/Jaimes/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/mkmf.rb:321:in `open'
    from /Users/Jaimes/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/mkmf.rb:351:in `block in postpone'
    from /Users/Jaimes/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/mkmf.rb:321:in `open'
    from /Users/Jaimes/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/mkmf.rb:347:in `postpone'
    from /Users/Jaimes/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/mkmf.rb:917:in `checking_for'
    from /Users/Jaimes/.rvm/rubies/ruby-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/Jaimes/.rvm/gems/ruby-2.1.1/gems/sqlite3-1.3.9 for inspection.
Results logged to /Users/Jaimes/.rvm/gems/ruby-2.1.1/extensions/x86_64-darwin-12/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.
         run  bundle exec spring binstub --all
/Users/Jaimes/.rvm/gems/ruby-2.1.1@global/gems/bundler-1.6.1/lib/bundler/resolver.rb:352:in `resolve': Could not find gem 'sqlite3 (>= 0) ruby' in the gems available on this machine. (Bundler::GemNotFound)
    from /Users/Jaimes/.rvm/gems/ruby-2.1.1@global/gems/bundler-1.6.1/lib/bundler/resolver.rb:165:in `start'
    from /Users/Jaimes/.rvm/gems/ruby-2.1.1@global/gems/bundler-1.6.1/lib/bundler/resolver.rb:129:in `resolve'
    from /Users/Jaimes/.rvm/gems/ruby-2.1.1@global/gems/bundler-1.6.1/lib/bundler/definition.rb:203:in `resolve'
    from /Users/Jaimes/.rvm/gems/ruby-2.1.1@global/gems/bundler-1.6.1/lib/bundler/definition.rb:133:in `specs'
    from /Users/Jaimes/.rvm/gems/ruby-2.1.1@global/gems/bundler-1.6.1/lib/bundler/definition.rb:178:in `specs_for'
    from /Users/Jaimes/.rvm/gems/ruby-2.1.1@global/gems/bundler-1.6.1/lib/bundler/definition.rb:167:in `requested_specs'
    from /Users/Jaimes/.rvm/gems/ruby-2.1.1@global/gems/bundler-1.6.1/lib/bundler/environment.rb:18:in `requested_specs'
    from /Users/Jaimes/.rvm/gems/ruby-2.1.1@global/gems/bundler-1.6.1/lib/bundler/runtime.rb:13:in `setup'
    from /Users/Jaimes/.rvm/gems/ruby-2.1.1@global/gems/bundler-1.6.1/lib/bundler.rb:120:in `setup'
    from /Users/Jaimes/.rvm/gems/ruby-2.1.1@global/gems/bundler-1.6.1/lib/bundler/setup.rb:17:in `<top (required)>'
    from /Users/Jaimes/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /Users/Jaimes/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
Jaimess-MacBook-Pro:Desktop Jaimes$ 

我在其他地方看到过一些关于安装sqlite3的回复,但没有一个在这里工作过,其中一个特别涉及'yum'命令,当我将其插入时无法识别:

yum install sqlite-devel

之后我才得到:

-bash: yum: command not found

我完全失去了我做错了什么或者我忽略了什么,需要一位经验丰富的红宝石程序员的新眼睛!

1 个答案:

答案 0 :(得分:0)

问题是您需要为gem

安装依赖项(头文件)

因为gem是sqlite3,我建议您在系统上安装sqlite。我认为你正在使用CentOS(?) - 如果是这样,你可能想试试这个:

yum install sqlite

如果这不起作用,那么这里有一个很棒的教程:Error installing sqlite3 gem via bundler

wget http://www.sqlite.org/sqlite-autoconf-3070701.tar.gz
tar -zxvf sqlite-autoconf-3070701.tar.gz
cd sqlite-autoconf-3070701
./configure --prefix=$HOME
make && make install

cd $RAILS_APP_DIR
vi Gemfile

除此之外 - 最好的建议是在Google上查看如何在系统上安装sqlite(而不是gem - 实际文件)。这将允许您根据需要安装gem,或者通常情况下,您将能够指定任何额外的参数来使用