I am really bugged with a problem with Heroku. I am a total newbie and I have already tried out a few solutions and they don't seem to help me. Here is the error i get on using
group :development, :test do
gem 'sqlite3'
end
in the gem file this is the entry i have for sqlite 3
Gem files will remain installed in /tmp/build_2i8tok6rv3gyk/vendor/bundle/ruby/2.0.0/gems/sqlite3-1.3.7 for inspection.
Results logged to /tmp/build_2i8tok6rv3gyk/vendor/bundle/ruby/2.0.0/gems/sqlite3-1.3.7/ext/sqlite3/gem_make.out
An error occurred while installing sqlite3 (1.3.7), and Bundler cannot continue.
Make sure that `gem install sqlite3 -v '1.3.7'` succeeds before bundling.
!
! Failed to install gems via Bundler.
!
! Detected sqlite3 gem which is not supported on Heroku.
! https://devcenter.heroku.com/articles/sqlite3
!
! Push rejected, failed to compile Ruby/Rails app
To git#heroku.com:glacial-wildwood-5205.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'git#heroku.com:glacial-wildwood-5205.git'
heroku does not support sqlite3 , use Postgresql instead.
group :development do
gem 'sqlite3'
end
group :test, :production do
gem 'pg'
end
In this way sqlite will be your local db , and postgres will be for test and production
You'll want to change your Gemfile
add gem 'pg' to your production group
group :production do
gem "pg"
end
Then be sure to run bundle install before you commit to heroku
This whole guide should help get you started: https://devcenter.heroku.com/articles/ruby#using-a-sql-database
Related
I've been trying to deploy my first Ruby on Rails application to Heroku to test it out and I receive the following error when using the manual deploy option. Just for some background notes I created the rails application using the operating system 'Windows 10', Ruby version 2.1.8p440 & Rails 4.2.5.1. If anymore information I will be happy to provide, thank you. I also have 'coffee-script-source' installed as a gem and its to make the project run correctly.
----- HEROKU MANUAL DEPLOY LOG START -----
An error occurred while installing sqlite3 (1.3.11), and Bundler cannot
continue.
Make sure that `gem install sqlite3 -v '1.3.11'` succeeds before bundling.
!
! Failed to install gems via Bundler.
!
! Detected sqlite3 gem which is not supported on Heroku.
! https://devcenter.heroku.com/articles/sqlite3
!
! Push rejected, failed to compile Ruby app
----- HEROKU MANUEL DEPLOY LOG END -----
Move your sqlite3 gem under development group
group :development, :test do
gem 'sqlite3'
end
Add pg gem under production group
group :production do
gem 'pg'
end
run bundle and try to push code to Heroku.
I receive the following error when I run heroku run rake db:create:
Running `rake db:create` attached to terminal... up, run.6027
Could not find gem 'pg (>= 0.11.0) ruby' in the gems available on this machine.
Run `bundle install` to install missing gems.
In the config/database.yml I'm using the default mysql2 database:
production:
adapter: mysql2
database: redmine
host: localhost
...
development:
adapter: mysql2
...
test:
adapter: mysql2
...
So I guess 'pg (>= 0.11.0) ruby' does not need to be installed. Am I wrong?
I'm using Windows XP. It is the first time I use Ruby.
UPDATE 1
I forgot to say bundle install finished correctly without errors.
On the other hand, Gemfile has the following code:
adapters.each do |adapter|
case adapter
when 'mysql2'
gem "mysql2", "~> 0.3.11", :platforms => [:mri, :mingw]
gem "activerecord-jdbcmysql-adapter", :platforms => :jruby
...
when /postgresql/
gem "pg", ">= 0.11.0", :platforms => [:mri, :mingw]
gem "activerecord-jdbcpostgresql-adapter", :platforms => :jruby
...
So again, I guess it should never enter in when /postgresql/ when the command heroku run rake db:create is executed. Am I right?
See the discussion above... This is a Heroku application and it needs a database configured or it is going to try and force Postgres as a dependency to help you out.
You need to do bundle install before running the rake task for db creation and fulfill all gem dependencies. This is required even though you are using mysql and not postgres because the 'pg gem' is specified in the Gemfile and you have to make sure that all gem dependencies in your Gemfile are made available to your application by running the bundle install commmand.
As in your case you are using mysql, you do not require the 'pg gem' and can remove or comment it in the Gemfile.
I go to redeploy my heroku apps with a new gem in Gemfile and it crashes on startup
/app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:251:in `require': libruby.so.1.9: cannot open shared object file: No such file or directory - /app/vendor/bundle/ruby/1.9.1/gems/bcrypt-ruby-3.0.1/lib/bcrypt_ext.so (LoadError)
This is happening no matter what branch I deploy (old stable ones...) and only fixes by doing a heroku rollback.
I believe this is caused by heroku recently updating their ruby 1.9.3 because I was having this issue Heroku app crashes with 'libruby.so.1.9: cannot open shared object file' . Removing the nokogiri gem stopped the exception I was getting but then there's still this. More similar errors occur when I add new gems.
The whole problem was solved by deploying to a new heroku app but that's not something I can just do on my production server.
Any ideas on fixing the issue or somehow "refreshing" my app?
my gemfile:
source "https://rubygems.org"
ruby "1.9.3"
gem "rails", "3.2.3"
gem "thin"
# Bundle edge Rails instead:
# gem "rails", :git => "git://github.com/rails/rails.git"
gem "mongoid"
gem "devise"
gem "haml"
gem "sass"
gem "exceptional"
gem "kaminari"
gem "mongoid_search"
#gem "nokogiri"
gem "bson_ext"
gem "heroku-mongo-backup"
gem "aws-s3"
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem "haml-rails", "~> 0.3.4"
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", :platform => :ruby
gem "uglifier", ">= 1.0.3"
end
gem "jquery-rails"
group :test do
gem "mongoid-rspec"
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-debug19", :require => "ruby-debug"
#
group :development do
gem "letter_opener"
end
Just FYI,
After contacting the Heroku support about this issue, you should follow these 3 simple steps:
Install this heroku-repo plugin: heroku plugins:install https://github.com/lstoll/heroku-repo.git
Run the following command: heroku repo:purge_cache
Deploy your app again.
Hope that helps!
This happened to me yesterday as well, was definitely something to do with Heroku.
I found fix and discussion on Twitter: https://twitter.com/bcardarella/status/256822171979100161
Just force-clear the gem file cache(clear gemfile, deploy, restore and deploy) and the app would start smoothly again.
For some reason, heroku tries to require dm-sqlite-adapter, even though it should use Postgres here. Note, that this happens when I open any URL - not during the git push itself.
I built a default facebook app.
The 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")
Relevant log fragment, when any URL is opened:
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 with no help so far.
BTW: bundle install says Using do_postgres and Using dm-postgres-adapter. Am I missing something about Datamapper setup?
Well, too many Rails apps on Heroku, I took the shared db presence for granted. heroku config showed neither DATABASE_URL or SHARED_DATABASE_URL set.
Issuing heroku addons:add shared-database:5mb solved the problem.
Strange, that the db wasn't automatically added, despite having 'pg' gem in Gemfile.
Quote from http://devcenter.heroku.com/articles/cedar:
A Heroku shared PostgreSQL database (shared-database:5mb) will be
automatically added to your app in any of the following cases:
The app is a Rails application
The pg gem is specified in the Gemfile
Try doing DataMapper.setup(:default, ENV['DATABASE_URL'] || 'postgres://user:password#hostname/data/mydatabase.db') instead. Heroku is probably looking at the protocol, and therefore requiring SQLite’s dependencies.
I try to push my rails application to heroku but encountered the following error
Application Error
An error occurred in the application and your page could not be served. Please try again in a few moments.
If you are the application owner, check your logs for details.
Because I am using sqlite3
A search on the web show I should do the following
heroku rake db:create
heroku rake db:migrate
the heroku rake db:create failed by complaining
Please install the postgresql adapter: `gem install activerecord-postgresql-adapter` (pg is not part of the bundle. Add it to Gemfile.)
The command gem install activerecord-postgresql-adapter failed and complains
ERROR: Could not find a valid gem 'activerecord-postgresql-adapter' (>= 0) in any repository
ERROR: Possible alternatives: activerecord-postgis-adapter, activerecord-jdbcpostgresql-adapter, activerecord-postgresql-cursors, activerecord-jdbcmysql-adapter, activerecord-jdbcmssql-adapter
Then I searched the web again and followed the http://devcenter.heroku.com/articles/how-do-i-use-sqlite3-for-development suggestion to change
gem 'sqlite3'
to
group :production do
gem 'pg'
end
group :development, :test do
gem 'sqlite3'
end
and run
bundle install --without production
however this did not solve the problem
another source say I need to do like
group :production do
gem 'therubyracer-heroku', '0.8.1.pre3'
gem "pg"
end
This also failed to solve the issue
I have postresql installed on my system.
So what hell is the problem?
The key thing here is that the pg gem is required to run against the Postgres database that you end up using when you deploy to heroku (http://devcenter.heroku.com/articles/database)
Ideally, you want to be running Postgres locally so that you're not seeing any differences between development and production from a database standpoint.
If you want to stick with things how you have them simply adding gem "pg" to your Gemfile should fix this.
Once added, run:
bundle install
git add .
git commit -am "Added PG to Gemfile"
git push heroku master
heroku rake db:migrate
Please following steps for deploy on heroku server
First please remove the gem ='sqlite3' from Gemfile and add gem = 'pg'
Run this command on Project path: bundle install
git add .
git commit -am "add pg on gem file"
git push heroku master