Heroku 未加载 do_postgres 依赖项

发布于 2024-10-20 20:42:42 字数 4156 浏览 2 评论 0原文

开始使用 Heroku,但它似乎没有加载 dm-postgres-adapter 所需的依赖项 (do_postgres (~> 0.10.2))。

Gemfile 是这样的:

source :gemcutter

gem 'dm-postgres-adapter', '1.0.2'
gem 'dm-sqlite-adapter', '1.0.2'
gem 'sinatra', '1.1.0'
gem 'mustache', '0.9'
gem 'datamapper', '1.0.2'
gem 'json', '1.5.1'

Gemfile.lock 的相关部分如下所示:

dm-postgres-adapter (1.0.2)
  dm-do-adapter (~> 1.0.2)
  do_postgres (~> 0.10.2)

当推送到 Heroku 时,它似乎没有安装 do_postgres:

-----> Heroku receiving push
-----> Sinatra app detected
-----> Gemfile detected, running Bundler version 1.0.7
       Unresolved dependencies detected; Installing...
       Using --without development:test
       Fetching source index for http://rubygems.org/
       Installing addressable (2.2.4)
       Installing data_objects (0.10.3)
       Installing extlib (0.9.15)
       Installing dm-core (1.0.2)
       Installing dm-aggregates (1.0.2)
       Installing dm-migrations (1.0.2)
       Installing dm-constraints (1.0.2)
       Installing fastercsv (1.5.4)
       Installing json_pure (1.5.1)
       Installing dm-serializer (1.0.2)
       Installing dm-timestamps (1.0.2)
       Installing dm-transactions (1.0.2)
       Installing stringex (1.1.0)
       Installing uuidtools (2.1.2)
       Installing dm-types (1.0.2)
       Installing dm-validations (1.0.2)
       Installing datamapper (1.0.2)
       Installing dm-do-adapter (1.0.2)
       Installing dm-postgres-adapter (1.0.2)
       Installing dm-sqlite-adapter (1.0.2)
       Installing mustache (0.9.0)
       Installing rack (1.2.1)
       Installing tilt (1.2.2)
       Installing sinatra (1.1.0)
       Using bundler (1.0.7)
       Your bundle is complete! It was installed into ./.bundle/gems/
       Compiled slug size is 1.7MB
-----> Launching... done

而且,事实上,Heroku 没有找到 gem 并且没有启动:

2011-03-07T10:48:31-08:00 heroku[slugc]: Slug compilation finished
2011-03-07T10:48:35-08:00 app[web.1]: /usr/ruby1.8.7/lib/ruby/site_ruby/1.8/rubygems.rb:779:in `report_activate_error': Could not find RubyGem do_postgres (~> 0.10.2) (Gem::LoadError)
2011-03-07T10:48:35-08:00 app[web.1]:   from /usr/ruby1.8.7/lib/ruby/site_ruby/1.8/rubygems.rb:214:in `activate'
2011-03-07T10:48:35-08:00 app[web.1]:   from /usr/ruby1.8.7/lib/ruby/site_ruby/1.8/rubygems.rb:249:in `activate'
2011-03-07T10:48:35-08:00 app[web.1]:   from /usr/ruby1.8.7/lib/ruby/site_ruby/1.8/rubygems.rb:248:in `activate'
2011-03-07T10:48:35-08:00 app[web.1]:   from /usr/ruby1.8.7/lib/ruby/site_ruby/1.8/rubygems.rb:248:in `each'
2011-03-07T10:48:35-08:00 app[web.1]:   from /usr/ruby1.8.7/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:35:in `require'
2011-03-07T10:48:35-08:00 app[web.1]:   from /app/04eca654-0ab6-43de-aae1-1dbed7bef1a1/home/.bundle/gems/ruby/1.8/gems/dm-core-1.0.2/lib/dm-core/adapters.rb:163:in `load_adapter'
2011-03-07T10:48:35-08:00 app[web.1]:   from /app/04eca654-0ab6-43de-aae1-1dbed7bef1a1/home/.bundle/gems/ruby/1.8/gems/dm-core-1.0.2/lib/dm-core/adapters.rb:133:in `adapter_class'
2011-03-07T10:48:35-08:00 app[web.1]:   from /app/04eca654-0ab6-43de-aae1-1dbed7bef1a1/home/.bundle/gems/ruby/1.8/gems/dm-core-1.0.2/lib/dm-core/adapters.rb:13:in `new'
2011-03-07T10:48:35-08:00 app[web.1]:   from /app/04eca654-0ab6-43de-aae1-1dbed7bef1a1/home/.bundle/gems/ruby/1.8/gems/dm-core-1.0.2/lib/dm-core.rb:266:in `setup'
2011-03-07T10:48:35-08:00 app[web.1]:   from ./lib/database.rb:21:in `initialize'

database.rb第 21 行是这样的:

  DataMapper.setup(:default, ENV['DATABASE_URL'] || 'sqlite3://' + Dir.pwd + '/database.db')

这是直接来自 Heroku 站点的代码: http://devcenter.heroku.com /articles/database#common_issues_migration_to_postgresql,位于“使用 DATABASE_URL 环境变量”下。该应用程序本地在 Sqlite 上运行,但 Heroku 使用 postgresql。我希望 DataMapper 能让转变变得轻而易举!

我已经尝试明确地包含

gem 'do_postgres', '~>0.10.2'

在 Gemfile 中,但没有成功。无论如何,这应该是没有必要的。也向 Heroku 支持提交了票证,但尚未收到他们的回复......

Getting started on Heroku, but it does not seem to be loading the necessary dependency (do_postgres (~> 0.10.2)) for dm-postgres-adapter.

The Gemfile is as such:

source :gemcutter

gem 'dm-postgres-adapter', '1.0.2'
gem 'dm-sqlite-adapter', '1.0.2'
gem 'sinatra', '1.1.0'
gem 'mustache', '0.9'
gem 'datamapper', '1.0.2'
gem 'json', '1.5.1'

With the relevant section of the Gemfile.lock looking as follows:

dm-postgres-adapter (1.0.2)
  dm-do-adapter (~> 1.0.2)
  do_postgres (~> 0.10.2)

When pushed to Heroku, it does not seem to install do_postgres:

-----> Heroku receiving push
-----> Sinatra app detected
-----> Gemfile detected, running Bundler version 1.0.7
       Unresolved dependencies detected; Installing...
       Using --without development:test
       Fetching source index for http://rubygems.org/
       Installing addressable (2.2.4)
       Installing data_objects (0.10.3)
       Installing extlib (0.9.15)
       Installing dm-core (1.0.2)
       Installing dm-aggregates (1.0.2)
       Installing dm-migrations (1.0.2)
       Installing dm-constraints (1.0.2)
       Installing fastercsv (1.5.4)
       Installing json_pure (1.5.1)
       Installing dm-serializer (1.0.2)
       Installing dm-timestamps (1.0.2)
       Installing dm-transactions (1.0.2)
       Installing stringex (1.1.0)
       Installing uuidtools (2.1.2)
       Installing dm-types (1.0.2)
       Installing dm-validations (1.0.2)
       Installing datamapper (1.0.2)
       Installing dm-do-adapter (1.0.2)
       Installing dm-postgres-adapter (1.0.2)
       Installing dm-sqlite-adapter (1.0.2)
       Installing mustache (0.9.0)
       Installing rack (1.2.1)
       Installing tilt (1.2.2)
       Installing sinatra (1.1.0)
       Using bundler (1.0.7)
       Your bundle is complete! It was installed into ./.bundle/gems/
       Compiled slug size is 1.7MB
-----> Launching... done

And, indeed, Heroku does not find the gem and does not launch:

2011-03-07T10:48:31-08:00 heroku[slugc]: Slug compilation finished
2011-03-07T10:48:35-08:00 app[web.1]: /usr/ruby1.8.7/lib/ruby/site_ruby/1.8/rubygems.rb:779:in `report_activate_error': Could not find RubyGem do_postgres (~> 0.10.2) (Gem::LoadError)
2011-03-07T10:48:35-08:00 app[web.1]:   from /usr/ruby1.8.7/lib/ruby/site_ruby/1.8/rubygems.rb:214:in `activate'
2011-03-07T10:48:35-08:00 app[web.1]:   from /usr/ruby1.8.7/lib/ruby/site_ruby/1.8/rubygems.rb:249:in `activate'
2011-03-07T10:48:35-08:00 app[web.1]:   from /usr/ruby1.8.7/lib/ruby/site_ruby/1.8/rubygems.rb:248:in `activate'
2011-03-07T10:48:35-08:00 app[web.1]:   from /usr/ruby1.8.7/lib/ruby/site_ruby/1.8/rubygems.rb:248:in `each'
2011-03-07T10:48:35-08:00 app[web.1]:   from /usr/ruby1.8.7/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:35:in `require'
2011-03-07T10:48:35-08:00 app[web.1]:   from /app/04eca654-0ab6-43de-aae1-1dbed7bef1a1/home/.bundle/gems/ruby/1.8/gems/dm-core-1.0.2/lib/dm-core/adapters.rb:163:in `load_adapter'
2011-03-07T10:48:35-08:00 app[web.1]:   from /app/04eca654-0ab6-43de-aae1-1dbed7bef1a1/home/.bundle/gems/ruby/1.8/gems/dm-core-1.0.2/lib/dm-core/adapters.rb:133:in `adapter_class'
2011-03-07T10:48:35-08:00 app[web.1]:   from /app/04eca654-0ab6-43de-aae1-1dbed7bef1a1/home/.bundle/gems/ruby/1.8/gems/dm-core-1.0.2/lib/dm-core/adapters.rb:13:in `new'
2011-03-07T10:48:35-08:00 app[web.1]:   from /app/04eca654-0ab6-43de-aae1-1dbed7bef1a1/home/.bundle/gems/ruby/1.8/gems/dm-core-1.0.2/lib/dm-core.rb:266:in `setup'
2011-03-07T10:48:35-08:00 app[web.1]:   from ./lib/database.rb:21:in `initialize'

database.rb line 21 is this:

  DataMapper.setup(:default, ENV['DATABASE_URL'] || 'sqlite3://' + Dir.pwd + '/database.db')

Which is code straight from the Heroku site: http://devcenter.heroku.com/articles/database#common_issues_migrating_to_postgresql , under "Using the DATABASE_URL Environment variable". The app runs on Sqlite locally, but Heroku uses postgresql. I was hoping DataMapper would make the transition a cinch!

I have tried explicitly including

gem 'do_postgres', '~>0.10.2'

in the Gemfile, to no avail. This should not be necessary, anyway. Submitted a ticket to Heroku support as well, but haven't heard back from them...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

怕倦 2024-10-27 20:42:42

Heroku 非常迅速地回复了我:

你好,

我注意到您正在使用 Windows
您的开发环境。有
目前捆绑程序存在限制
和跨平台使用,即如果你
在 Windows 上本地开发但部署
到像heroku这样的unix服务器。这
当前的解决方法是删除您的
Gemfile.lock。

最好,

[已删除]

事实上,在删除 Gemfile.lock 之后,Heroku 正确安装了 do_postgres gem。我最初提交 Gemfile.lock 是因为 Heroku 界面推荐它(“很快就会需要 Gemfile.lock”),所以也许在某处发出一点警告,表明这会破坏与 Windows 的兼容性会很好。当然,跨平台的事情不是我决定的。 :)

Heroku got back to me, very promptly:

Hello,

I noticed you're using windows for
your development environment. There is
currently a limitation on with bundler
and cross platform use, i.e. if you
develop locally on windows but deploy
to a unix server like heroku. The
current workaround is to remove your
Gemfile.lock.

Best,

[removed]

Indeed, after removing Gemfile.lock Heroku installed the do_postgres gem properly. I had originally committed Gemfile.lock because the Heroku interface recommended it, ("Gemfile.lock will soon be required"), so perhaps a little warning somewhere that this breaks compatibility with Windows would be nice. Of course, the cross-platform thing was not my decision. :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文