mercredi 23 septembre 2015

How can we use ActiveRecord and deploy to Heroku without using sqlite3?

I'm using the ActiveRecord class and was using "sqlite3" as the default. Then I wanted to deploy it on Heroku (which uses PostgreSQL). So I just added that in the Gemfile and installed the dependencies.

When I try to push to Heroku, it throws errors such as:

remote: Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension. remote:
remote: /tmp/build_12cfde1548d0f1ff19f95340a86aab63/vendor/ruby-2.0.0/bin/ruby extconf.rb remote: checking for sqlite3.h... no remote: sqlite3.h is missing. Try 'port install sqlite3 +universal', remote: 'yum install sqlite-devel' or 'apt-get install libsqlite3-dev' remote: and check your shared library search path (the remote: location where your sqlite3 shared library is located). remote: *** extconf.rb failed ***

So then I tried removing the sqlite3 gem and I get this error from the application when I try to run it (I haven't tried deploying on Heroku yet):

Error:[rake --tasks] /Users/adeesh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/activerecord-4.2.4/lib/active_record/connection_adapters/connection_specification.rb:177:in `rescue in spec': Specified 'sqlite3' for database adapter, but the gem is not loaded. Add `gem 'sqlite3'` to your Gemfile (and ensure its version is at the minimum required by ActiveRecord). (Gem::LoadError) from /Users/adeesh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/activerecord-4.2.4/lib/active_record/connection_adapters/connection_specification.rb:174:in `spec' from /Users/adeesh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/activerecord-4.2.4/lib/active_record/connection_handling.rb:50:in `establish_connection' from /Users/adeesh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/activerecord-4.2.4/lib/active_record/railtie.rb:120:in `block (2 levels) in <class:Railtie>' from /Users/adeesh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/activesupport-4.2.4/lib/active_support/lazy_load_hooks.rb:38:in `instance_eval' from /Users/adeesh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/activesupport-4.2.4/lib/active_support/lazy_load_hooks.rb:38:in `execute_hook' from /Users/adeesh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/activesupport-4.2.4/lib/active_support/lazy_load_hooks.rb:45:in `block in run_load_hooks' from /Users/adeesh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/activesupport-4.2.4/lib/active_support/lazy_load_hooks.rb:44:in `each' from /Users/adeesh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/activesupport-4.2.4/lib/active_support/lazy_load_hooks.rb:44:in `run_load_hooks' from /Users/adeesh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/activerecord-4.2.4/lib/active_record/base.rb:315:in `<module:ActiveRecord>' from /Users/adeesh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/activerecord-4.2.4/lib/active_record/base.rb:26:in `<top (required)>' from /Users/adeesh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/spring-1.4.0/lib/spring/application.rb:319:in `active_record_configured?' from /Users/adeesh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/spring-1.4.0/lib/spring/application.rb:251:in `disconnect_database' from /Users/adeesh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/spring-1.4.0/lib/spring/application.rb:97:in `preload' from /Users/adeesh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/spring-1.4.0/lib/spring/application.rb:143:in `serve' from /Users/adeesh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/spring-1.4.0/lib/spring/application.rb:131:in `block in run' from /Users/adeesh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/spring-1.4.0/lib/spring/application.rb:125:in `loop' from /Users/adeesh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/spring-1.4.0/lib/spring/application.rb:125:in `run' from /Users/adeesh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/spring-1.4.0/lib/spring/application/boot.rb:18:in `<top (required)>' from /Users/adeesh/.rbenv/versions/2.2.3/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require' from /Users/adeesh/.rbenv/versions/2.2.3/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require' from -e:1:in `<main>'

I have run out of ideas and am very new to ruby or rails for that matter. Any help is appreciated!

Aucun commentaire:

Enregistrer un commentaire