【问题标题】:ruby on rails error for databasesruby on rails 数据库错误
【发布时间】:2014-12-28 07:13:40
【问题描述】:

我是新手 当我尝试捆绑安装时,显示以下错误 当我使用 mysql2 而不是 sqllite 时同样的错误

我正在使用 linux 主机 并且站点显示内部服务器错误 据我所知 服务器正在使用 phussion 乘客

Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

        /opt/ruby/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=/opt/ruby/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
/opt/ruby/lib/ruby/1.9.1/mkmf.rb:381:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
        from /opt/ruby/lib/ruby/1.9.1/mkmf.rb:506:in `try_cpp'
        from /opt/ruby/lib/ruby/1.9.1/mkmf.rb:970:in `block in find_header'
        from /opt/ruby/lib/ruby/1.9.1/mkmf.rb:790:in `block in checking_for'
        from /opt/ruby/lib/ruby/1.9.1/mkmf.rb:284:in `block (2 levels) in postpone'
        from /opt/ruby/lib/ruby/1.9.1/mkmf.rb:254:in `open'
        from /opt/ruby/lib/ruby/1.9.1/mkmf.rb:284:in `block in postpone'
        from /opt/ruby/lib/ruby/1.9.1/mkmf.rb:254:in `open'
        from /opt/ruby/lib/ruby/1.9.1/mkmf.rb:280:in `postpone'
        from /opt/ruby/lib/ruby/1.9.1/mkmf.rb:789:in `checking_for'
        from /opt/ruby/lib/ruby/1.9.1/mkmf.rb:969:in `find_header'
        from extconf.rb:30:in `<main>'


Gem files will remain installed in /home/jformmp7/ruby/gems/gems/sqlite3-1.3.10 for inspection.
Results logged to /home/jformmp7/ruby/gems/gems/sqlite3-1.3.10/ext/sqlite3/gem_make.out
An error occurred while installing sqlite3 (1.3.10), and Bundler cannot
continue.
Make sure that `gem install sqlite3 -v '1.3.10'` succeeds before bundling.

gemfile 的内容

来源'https://rubygems.org'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.1.6'
# Use sqlite3 as the database for Active Record
#gem 'sqlite3'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.3'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.0'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
gem 'therubyracer',  platforms: :ruby
#gem "therubyracer"
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0',          group: :doc

# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring',        group: :development

# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use unicorn as the app server
# gem 'unicorn'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

# Use debugger
# gem 'debugger', group: [:development, :test]

#gem 'mysql2'

【问题讨论】:

    标签: mysql ruby-on-rails sqlite rubygems


    【解决方案1】:

    我猜你在 ubuntu 上?

    过去发生在我身上,希望能通过打字解决。

    sudo apt-get install sqlite3 libsqlite3-dev
    bundle install
    

    【讨论】:

    • 我的主机不会授予此权限
    • 还有其他方法吗,因为我的托管服务提供商是 bigrock 并且没有 sudo 和 apt-get 安装权限
    • 没有 root 可能会非常困难。您可以为您的铁路应用发布 Gemfile 的内容吗?不要忘记删除 IP 和用户/密码
    • 我已经发布了 gemfile 内容
    • 你需要sqlite吗?如果你说你想使用mysql,你应该尝试从那个gemfile中注释掉sqlite3。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-07-24
    • 1970-01-01
    • 1970-01-01
    • 2017-06-15
    • 2014-04-17
    • 2011-10-02
    • 2016-04-25
    相关资源
    最近更新 更多