Sinatra + Heroku + Datamapper deploys problems with dm-sqlite adapter

For some reason, heroku is trying to use dm-sqlite-adapter, although it should use Postgres here. Note that this happens when I open any url, and not during git itself.

I built the default facebook application.

Gemfile:

source :gemcutter gem "foreman" gem "sinatra" gem "mogli" gem "json" gem "httparty" gem "thin" gem "data_mapper" gem "heroku" group :production do gem "pg" gem "dm-postgres-adapter" end group :development, :test do gem "sqlite3" gem "dm-sqlite-adapter" end 

Datamapper setup:

 # Setting up the database DataMapper.setup(:default, ENV['DATABASE_URL'] || "sqlite3://#{Dir.pwd}/data/mydatabase.db") 

Corresponding log fragment when any URL is open:

 Starting process with command `bundle exec thin -R config.ru start -p 34984` 2012-01-18T15:11:55+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/dm-core-1.2.0/lib/dm-core/adapters.rb:163:in `require': no such file to load -- dm-sqlite-adapter (LoadError) 2012-01-18T15:11:55+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/dm-core-1.2.0/lib/dm-core/adapters.rb:163:in `load_adapter' 

Tried related solutions, but without help so far.

BTW: bundle install says Using do_postgres and Using dm-postgres-adapter . Am I missing something in setting up Datamapper?

+5
source share
2 answers

Well, too many Rails apps on Heroku, I took the general presence of db for granted. heroku config showed neither DATABASE_URL nor SHARED_DATABASE_URL .

Issuing heroku addons:add shared-database:5mb solved the problem.

It is strange that db was not added automatically, despite the presence of a "pg" gem in the Gemfile.

Quote from http://devcenter.heroku.com/articles/cedar :

A PostgreSQL shared-database:5mb containing Heroku ( shared-database:5mb ) will automatically be added to your application in any of the following cases:

  • Application is a Rails Application
  • pg gem specified in Gemfile
+9
source

Try making DataMapper.setup(:default, ENV['DATABASE_URL'] || 'postgres://user: password@hostname /data/mydatabase.db') instead. Heroku probably looks at the protocol and therefore requires SQLites dependencies.

+3
source

All Articles