将RoR部署到Heroku并且Sqlite3失败

时间:2012-03-25 02:58:12

标签: ruby-on-rails ruby-on-rails-3 heroku

我在同一个主题上发现了一些帖子(here's一个)并认为我做了正确的更改,但我仍然无法解决问题。

完成捆绑安装后,我推送到heroku,当它到达sqlite3安装时出现以下错误。

Installing sqlite3 (1.3.5) with native extensions
   Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
   /usr/local/bin/ruby extconf.rb
   checking for sqlite3.h... no
   sqlite3.h is missing. Try 'port install sqlite3 +universal'
   or 'yum install sqlite-devel' and check your shared library search path (the
   location where your sqlite3 shared library is located).
   *** 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=/usr/local/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
   Gem files will remain installed in /tmp/build_13nbwv3kitbub/vendor/bundle/ruby/1.9.1/gems/sqlite3-1.3.5 for inspection.
   Results logged to /tmp/build_13nbwv3kitbub/vendor/bundle/ruby/1.9.1/gems/sqlite3-1.3.5/ext/sqlite3/gem_make.out
   An error occured while installing sqlite3 (1.3.5), and Bundler cannot continue.
   Make sure that `gem install sqlite3 -v '1.3.5'` succeeds before bundling.
 !
 !     Failed to install gems via Bundler.
 !
 !     Heroku push rejected, failed to compile Ruby/rails app

To git@heroku.com:morning-dawn-1372.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'git@heroku.com:morning-dawn-1372.git'

My Gemfile如下所示:

source 'https://rubygems.org'

gem 'rails', '3.2.2'

# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'

gem 'json'

group :development, :test do 
  gem 'sqlite3-ruby', :require => 'sqlite3'
  gem 'sqlite3', '1.3.5'
end 

# Gems used only for assets and not required
# in production environments by default.
group :assets do
  gem 'sass-rails',   '~> 3.2.3'
  gem 'coffee-rails', '~> 3.2.1'

  # See https://github.com/sstephenson/execjs#readme for more supported runtimes
  # gem 'therubyracer' 

  gem 'uglifier', '>= 1.0.3'
end

gem 'jquery-rails'

group :production do
  gem 'pg', '0.12.2'
end

# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'

# To use Jbuilder templates for JSON
# gem 'jbuilder'

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

# Deploy with Capistrano
# gem 'capistrano'

# To use debugger
# gem 'ruby-debug'

看起来我有两个

Using sqlite3 (1.3.5)
Using sqlite3-ruby (1.3.3)

在我的系统上。不确定这是否是一个问题,但解释了为什么我在gemfile中排除了两者。

环境信息:

$ ruby -v 
ruby 1.8.7 (2012-02-08 patchlevel 358) [i386-cygwin] 

$ rails -v 
Rails 3.2.2 

3 个答案:

答案 0 :(得分:12)

运行bundle命令,然后确保在推送到Heroku之前将Gemfile和Gemfile.lock都签入到repo中。

答案 1 :(得分:1)

如果在没有组的Gemfile中指定sqlite,您也会收到此错误 - 例如

gem 'rails', '3.2.13'

# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'

# below is the line that's giving you trouble    
gem "sqlite3", "~> 1.3.7"

Heroku不允许在生产中使用sqlite,因此您必须删除此行或将其更改为

...
group :development, :test do
  gem "sqlite3", "~> 1.3.7", :require => "sqlite3"
end

然后执行bundle install,然后git addgit commit您对Gemfile和Gemfile.lock的更改。

完成此操作后,您的git push heroku master应该有效。

答案 2 :(得分:1)

试试这个:

  • 打开Gemfile.lock并向下滚动到'specs:'
  • 下的sqlite3(1.3.x)
  • 确保它仅显示为sqlite3(1.3.x)且没有额外的爵士乐。
  • 如果显示任何额外的标签,例如“-x86-mingw32”,则将其删除。
  • 运行捆绑安装。
  • 然后尝试推动Heroku大师。

为我工作。

修改

现在我知道了,请不要手动更改Gemfile.lock。 这是我在Windows上开始使用Rails进行编码时编写的。 尝试更新特定的gem或将其锁定到Gemfile中的版本。