postgresql - 使用 Sinatra + DataMapper + Postgres + Heroku 部署一个简单的测试应用程序返回 : Installing do_sqlite3 (0. 10.7) 错误

标签 postgresql sqlite heroku sinatra datamapper

目标:使用 Sinatra + DataMapper + Postgres + Heroku 部署一个简单的测试应用

问题:当使用 gem 'dm-postgres-adapter' gem 'dm-sqlite-adapter' 将应用程序推送到 Heroku 时,我得到了这个。 使用 native 扩展安装 do_sqlite3 (0.10.7) 不幸的是,发生了 fatal error 。请通过 https://github.com/carlhuda/bundler/issues 向 Bundler 问题跟踪器报告此错误。以便我们修复它。谢谢!

我访问了那个 github 链接,有人遇到了同样的问题,但被定向到 Heroku,https://github.com/carlhuda/bundler/issues/1488 .我已经向 Heroku 的邮件列表发送了一封电子邮件,正在等待回复。

我遇到了 LoadError: no such file to load -- dm-sqlite-adapter 所以我将其添加到 Gemfile 和 Gemfile.lock 中,这是我所能得到的最大

我曾尝试在本地安装和设置 Postgres,但这是我正在慢慢学习但还无法开始工作的全新痛苦。

我还阅读了这里的每一个问题,其中有一个问题,有些让我进步到了这一点,有些没有得到提问者的回应,这让我很困惑。

gem 文件

-----------------
source :rubygems
gem 'sinatra', '1.1.0'
gem 'thin', '1.2.7'
gem 'data_mapper'
gem 'dm-postgres-adapter'
gem 'dm-sqlite-adapter'

Gemfile.lock

------------------------
...
dm-sqlite-adapter (1.2.0)
  dm-do-adapter (~> 1.2.0)
  do_sqlite3 (~> 0.10.6)
...

简介

--------------------
web: bundle exec ruby recall.rb -p $PORT

召回.rb

---------------------
require 'rubygems'  
require 'sinatra'
require 'data_mapper'

DataMapper.setup(:default, ENV['DATABASE_URL'] || "sqlite3://#{Dir.pwd}/recall.db")


class Note
    include DataMapper::Resource
    property :id, Serial
    property :content, Text, :required => true
    property :complete, Boolean, :required => true, :default => 0
    property :created_at, DateTime
    property :updated_at, DateTime
end

DataMapper.auto_upgrade!

get '/' do
    @notes = Note.all :order => :id.desc
    @title = 'All Notes'
    erb :home
end

注意事项

-------------------------
10.7 Lion
Xcode 4 is installed
sqlite3 installed by Homebrew


~ which sqlite3
  
/usr/bin/sqlite3

~ gem list sql
sqlite3 (1.3.5)
sqlite3-ruby (1.3.3)

~ gem list do_sqlite3
do_sqlite3 (0.10.7)

~ brew info sqlite3
sqlite 3.7.9
http//sqlite.org/
Depends on: readline
/usr/local/Cellar/sqlite/3.7.9 (9 files, 1.9M)
http//github.com/mxcl/homebrew/commits/master/Library/Formula/sqlite.rb

错误日志

------------------------------
~ rubyfish2 git:(master) git push heroku master
Counting objects: 22, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (14/14), done.
Writing objects: 100% (15/15), 2.42 KiB, done.
Total 15 (delta 8), reused 0 (delta 0)

-----> Heroku receiving push
-----> Removing .DS_Store files
-----> Ruby app detected
-----> Installing dependencies using Bundler version 1.1.rc.7

Running: bundle install --without development:test --path vendor/bundle --binstubs bin/ --deployment

Fetching gem metadata from http//rubygems.org/.........

Using addressable (2.2.6)

Using bcrypt-ruby (3.0.1)

Using daemons (1.1.5)

Using dm-core (1.2.0)

Using dm-aggregates (1.2.0)

Using dm-constraints (1.2.0)

Using dm-migrations (1.2.0)

Using fastercsv (1.5.4)

Using json (1.6.4)

Using json_pure (1.6.4)

Using multi_json (1.0.4)

Using dm-serializer (1.2.1)

Using dm-timestamps (1.2.0)

Using dm-transactions (1.2.0)

Using stringex (1.3.0)

Using uuidtools (2.1.2)

Using dm-types (1.2.1)

Using dm-validations (1.2.0)

Using data_mapper (1.2.0)

Using data_objects (0.10.7)

Using dm-do-adapter (1.2.0)

Using do_postgres (0.10.7)

Using dm-postgres-adapter (1.2.0)

Installing do_sqlite3 (0.10.7) with native extensions Unfortunately, a fatal error has occurred. Please report this error to the Bundler issue tracker at https//github.com/carlhuda/bundler/issues so that we can fix it. Thanks!

/usr/local/lib/ruby/1.9.1/rubygems/installer.rb:483:in `rescue in block in build_extensions': ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError)

/usr/local/bin/ruby extconf.rb

checking for sqlite3.h... no

*** 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

Gem files will remain installed in /tmp/build_1ikvsvr378qb6/vendor/bundle/ruby/1.9.1/gems/do_sqlite3-0.10.7 for inspection.

Results logged to /tmp/build_1ikvsvr378qb6/vendor/bundle/ruby/1.9.1/gems/do_sqlite3-0.10.7/ext/do_sqlite3/gem_make.out

from /usr/local/lib/ruby/1.9.1/rubygems/installer.rb:486:in `block in build_extensions'

from /usr/local/lib/ruby/1.9.1/rubygems/installer.rb:446:in `each'

from /usr/local/lib/ruby/1.9.1/rubygems/installer.rb:446:in `build_extensions'

from /usr/local/lib/ruby/1.9.1/rubygems/installer.rb:198:in `install'

from /tmp/build_1ikvsvr378qb6/vendor/bundle/ruby/1.9.1/gems/bundler-1.1.rc.7/lib/bundler/source.rb:90:in `block in install'

from /tmp/build_1ikvsvr378qb6/vendor/bundle/ruby/1.9.1/gems/bundler-1.1.rc.7/lib/bundler/rubygems_integration.rb:82:in `preserve_paths'

from /tmp/build_1ikvsvr378qb6/vendor/bundle/ruby/1.9.1/gems/bundler-1.1.rc.7/lib/bundler/source.rb:89:in `install'

from /tmp/build_1ikvsvr378qb6/vendor/bundle/ruby/1.9.1/gems/bundler-1.1.rc.7/lib/bundler/installer.rb:73:in `block in install_gem_from_spec'

from /tmp/build_1ikvsvr378qb6/vendor/bundle/ruby/1.9.1/gems/bundler-1.1.rc.7/lib/bundler/rubygems_integration.rb:97:in `with_build_args'

from /tmp/build_1ikvsvr378qb6/vendor/bundle/ruby/1.9.1/gems/bundler-1.1.rc.7/lib/bundler/installer.rb:72:in `install_gem_from_spec'

from /tmp/build_1ikvsvr378qb6/vendor/bundle/ruby/1.9.1/gems/bundler-1.1.rc.7/lib/bundler/installer.rb:56:in `block in run'

from /tmp/build_1ikvsvr378qb6/vendor/bundle/ruby/1.9.1/gems/bundler-1.1.rc.7/lib/bundler/installer.rb:55:in `run'

from /tmp/build_1ikvsvr378qb6/vendor/bundle/ruby/1.9.1/gems/bundler-1.1.rc.7/lib/bundler/installer.rb:12:in `install'

from /tmp/build_1ikvsvr378qb6/vendor/bundle/ruby/1.9.1/gems/bundler-1.1.rc.7/lib/bundler/cli.rb:220:in `install'

from /tmp/build_1ikvsvr378qb6/vendor/bundle/ruby/1.9.1/gems/bundler-1.1.rc.7/lib/bundler/vendor/thor/task.rb:22:in `run'

from /tmp/build_1ikvsvr378qb6/vendor/bundle/ruby/1.9.1/gems/bundler-1.1.rc.7/lib/bundler/vendor/thor/invocation.rb:118:in `invoke_task'

from /tmp/build_1ikvsvr378qb6/vendor/bundle/ruby/1.9.1/gems/bundler-1.1.rc.7/lib/bundler/vendor/thor.rb:263:in `dispatch'

from /tmp/build_1ikvsvr378qb6/vendor/bundle/ruby/1.9.1/gems/bundler-1.1.rc.7/lib/bundler/vendor/thor/base.rb:386:in `start'

from /tmp/build_1ikvsvr378qb6/vendor/bundle/ruby/1.9.1/gems/bundler-1.1.rc.7/bin/bundle:13:in `<top (required)>'

from vendor/bundle/ruby/1.9.1/bin/bundle:19:in `load'

from vendor/bundle/ruby/1.9.1/bin/bundle:19:in `<main>'
 !
 !     Failed to install gems via Bundler.
 !
 !     Heroku push rejected, failed to compile Ruby app

最佳答案

安装 do_sqlite 时出现错误(Installing do_sqlite3 (0.10.7) with native extensions...)只是因为这个 gem 需要安装 sqlite3 库,他们不在 Heroku 上。要修复它,请从您的 Gemfile 中删除 dm-sqlite-adapter(它依赖于 do_sqlite)。如果你想保留 Sqlite 用于开发并使用 Postgres 用于生产,你可以使用 Gembundler's groups :

gem 'dm-postgres-adapter', :group => :production
gem 'dm-sqlite-adapter', :group => :development

这样,postgresql 适配器将安装在 Heroku 的生产环境中,但 sqlite 将在本地用于开发。

设置 Datamapper 的代码行是:

DataMapper.setup(:default, ENV['DATABASE_URL'] || "sqlite3://#{Dir.pwd}/recall.db")

这会查找环境变量 DATABASE_URL,如果存在则使用它,否则使用 sqlite url。获取 LoadError: no such file to load -- dm-sqlite-adapter 错误表明实际上未设置此变量。运行 heroku config,应该有 DATABASE_URLSHARED_DATABASE_URL 的条目。如果未设置,则需要添加数据库。

看看this other SO question它处理类似的问题。解决方案是运行 heroku addons:add shared-database:5mb

关于postgresql - 使用 Sinatra + DataMapper + Postgres + Heroku 部署一个简单的测试应用程序返回 : Installing do_sqlite3 (0. 10.7) 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8866411/

相关文章:

sql - 在 PostgreSQL 中从一个表中减去另一个表

SQL选择子组的最早日期

linq - 如何编写LINQ查询以将多行合并为一行?

postgresql - Heroku 上的 Alembic/Flask-migrate 迁移运行但不创建表

防止 SQL 注入(inject)的 PostgreSQL 美元引号字符串常量

mysql - 数据库设计 : Associating tables of variable types

android - 将项目从 listView 存储到应用程序的 SqLite 数据库

android - 内容提供者中的生命周期/流量控制?

ruby-on-rails - Heroku 关注 : how to handle multiple databases in a Rails app?

ios - Heroku 偶尔返回 "hostname"not found