Unable to push git repo from cloud9 to Heroku [duplicate] - ruby-on-rails

I'm trying to deploy my first app to Heroku. I'm using SQLite as the database. As far as I know Heroku doesn't use SQLite - it switches to Postgres in the backend.
When I'm deploying I get the following error:
/usr/ruby1.8.7/lib/ruby/gems/1.8/gems/bundler-1.0.0/lib/bundler/runtime.rb:64:in
`require': no such file to load --
sqlite3 (LoadError)
My Gemfile (which is what I assume is causing this problem) looks as follows:
source 'http://rubygems.org'
gem 'rails', '3.0.0'
gem 'sqlite3-ruby', '1.2.5', :require => 'sqlite3'
What am I doing wrong?

Heroku doesn't support SQLite databases. You need to use PostgreSQL on production, as I also explained in this post.
group :production do
gem "pg"
end
group :development, :test do
gem "sqlite3", "~> 1.3.0"
end
Actually, it's recommended to use in development/test an environment as close as possible to production. Therefore, I suggest you to switch all your environments to PostgreSQL.
# replace gem "sqlite3" with
gem "pg"

Simone Carletti is correct and so is Joost. You only need to group the sqlite3 gem or remove it entirely from your Gemfile. Heroku just needs to know that you don't want to use sqlite3 for production
So this:
...
group :development, :test do
gem "sqlite3-ruby", "~> 1.3.0", :require => "sqlite3"
end
...
Or this:
...
#No reference to sqlite3-ruby
...
If you remove the reference entirely you will probably mess up your local db though

After banging my head against this problem, I realized I was pushing the master branch of my repo to heroku, while I was making all of my postgres changes in my deploy-postgres branch of my repo!
I merged my deploy-postgres branch with my local master [git checkout master; git merge deploy-postgres] and then could run git push heroku master as per the heroku documentation.

I was stuck on this for hours looking at every answer here, but I couldn't get enough details to make it come together. This paged walked me through everything. http://railsapps.github.io/rails-heroku-tutorial.html
Good luck.

i was facing similar issue, but I realized that I was on a different branch - new_layout and was pushing master.
So I pushed my desired branch to heroku using following command and everything worked fine.
git push heroku new_layout:master

You can use clearDB addon
and gem 'mysql2' instead of gem 'sqlite3'

I'm using sqlite3 and deploy to Heroku no problem. Here is my database.yml
# SQLite version 3.x
# gem install sqlite3-ruby (not necessary on OS X Leopard)
development:
adapter: sqlite3
database: db/development.sqlite3
pool: 5
timeout: 5000
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
adapter: sqlite3
database: db/test.sqlite3
pool: 5
timeout: 5000
production:
adapter: sqlite3
database: db/production.sqlite3
pool: 5
timeout: 5000

Related

cannot deploy Rails 4.1.0 application to Heroku

I just tried to deploy my Rails 4.1.0 app to Heroku, but I get this error:
Gem::LoadError: Specified 'sqlite3' for database adapter, but the gem is not loaded.
...
error: failed to push some refs to 'git#heroku.com:somedomain.git'
For the moment I don't use any database in production.
In my Gemfile, I made the sqlite3 gem only work for development mode like this:
gem 'sqlite3', group: :development
But this doesn't solve the issue.
Does anybody know how I can deploy my Rails 4.1.0 app to Heroku without specifying a database for production?
Thanks for your help,
Anthony
Its better to use pg gem for heroku.
Your config/database.yml should look this way
production:
adapter: postgresql
encoding: unicode
database: appname_production
pool: 5
username: user
password:
Gemfile
gem 'pg'
This works for heroku in a some of my apps.

Unable to connect to PostgreSQL when using SQLite?

The error I get is:
Could not load 'active_record/connection_adapters/postgresql_adapter'. Make sure that the adapter in config/database.yml is valid.
Here's my database.yml:
development:
adapter: sqlite3
database: db/development.sqlite3
pool: 5
timeout: 5000
production:
adapter: postgresql
user: test-app
encoding: unicode
And my Gemfile:
# Use sqlite3 as the database for Active Record
gem 'sqlite3', :group => :development
group :production do
# For Heroku
gem 'rails_12factor'
gem 'pg'
end
This identical setup works fine with another app, but for some reason refuses to here. Why is it even looking for PostgreSQL in development?
I figured out what the problem was.
I am using the gem dotenv to load my Heroku ENV vars from the .env file into Rails, one of which is a Heroku Postgres URL in the variable ENV['DATABASE_URL'] that was messing with Rails in development.
I removed it and Rails started working properly again.
In the database.yml file, the adapter in production should be 'postgresql' not 'pg'.

Deploying App to Heroku

When I want to deploy my app to heroku (using git push heroku master), it gives me an error and told me to install sqlite3 -v '1.3.6'. So after successfully installing that gem, I tried deploying it again to heroku and it still give me the same error!! However, I've already installed it. And now I can't even run my rails project locally (rails server). May I know what could be the cause of this?
Here's my content in database.yml file:
# SQLite version 3.x
# gem install sqlite3
#
# Ensure the SQLite 3 gem is defined in your Gemfile
# gem 'sqlite3'
development:
adapter: sqlite3
database: db/development.sqlite3
pool: 5
timeout: 5000
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
adapter: sqlite3
database: db/test.sqlite3
pool: 5
timeout: 5000
production:
adapter: sqlite3
database: db/production.sqlite3
pool: 5
timeout: 5000
Heroku does not work with SQLite3
Open your Gemfile and replace the line:
gem 'sqlite3'
for
group :production do
gem 'pg'
end
group :development, :test do
gem 'sqlite3'
end
I also suggest you to read the heroku instructions: https://devcenter.heroku.com/articles/rails3
Make your gemfile look like this
group :production do
gem 'pg'
end
group :development, :test do
gem 'sqlite3-ruby', :require => 'sqlite3'
end

Redeploying Rails app results in new bundling error with Passenger

I deployed my first rails app to a production server a few days ago. Since then, I've been working on some fixes on my development machine and I pushed those over to the production server via git. I touched the restart.txt file and then restarted Apache, and now I'm getting a Passenger error that I think is related to gems and bundle.
When I first started development I ran into an issue (here) and I removed the .bundle directory. I then ran bundle install again on my development machine, and all seemed well while I fixed some bugs.
Now I'm ready to redeploy the next version of the app, and after these errors, I checked and noticed that I don't even have a .bundle directory anymore. bundle install doesn't create a new one. I assume nothing's going to work without that? Should I just manually create the requisite files or is there a command to regenerate those?
EDIT to add error: syntax error on line 3, col 2: adapter:sqlite3'
database.yml:
# SQLite version 3.x
gem install sqlite3
development:
adapter: sqlite3
database: db/development.sqlite3
pool: 5
timeout: 5000
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
adapter: sqlite3
database: db/test.sqlite3
pool: 5
timeout: 5000
production:
adapter: sqlite3
database: db/production.sqlite3
pool: 5
timeout: 5000
Is the gem install sqlite3 in your listing of database.yml actually present in that file? If that is the case than that is the cause of the error as it is invalid YAML. Also, the statement doesn't make sense here, as the file isn't interpreted by neither bundler nor ruby.
At best, just remove (or comment) that statement there and try gain.
Edit: Generally, whitespace (especially leading whitespace) is rather important in YAML. Don't mix spaces and tabs here. It would confuse the parser. Also there need to be a space between the key and the value in a hash like so
key: value
# ^ this space is important!
Please refer to YAML's Wikipedia article for more info about YAML syntax.
#Paul, can you try updating your gemfile as follows
group :production do
# gem 'mysql2' # disabled to debug Paul's issue.
gem 'sqlite3-ruby', :require => 'sqlite3'
end
group :development do
gem 'sqlite3-ruby', :require => 'sqlite3'
end
Let me know how this pans out.

Deploying RoR app to Heroku with SQLite 3 fails

I'm trying to deploy my first app to Heroku. I'm using SQLite as the database. As far as I know Heroku doesn't use SQLite - it switches to Postgres in the backend.
When I'm deploying I get the following error:
/usr/ruby1.8.7/lib/ruby/gems/1.8/gems/bundler-1.0.0/lib/bundler/runtime.rb:64:in
`require': no such file to load --
sqlite3 (LoadError)
My Gemfile (which is what I assume is causing this problem) looks as follows:
source 'http://rubygems.org'
gem 'rails', '3.0.0'
gem 'sqlite3-ruby', '1.2.5', :require => 'sqlite3'
What am I doing wrong?
Heroku doesn't support SQLite databases. You need to use PostgreSQL on production, as I also explained in this post.
group :production do
gem "pg"
end
group :development, :test do
gem "sqlite3", "~> 1.3.0"
end
Actually, it's recommended to use in development/test an environment as close as possible to production. Therefore, I suggest you to switch all your environments to PostgreSQL.
# replace gem "sqlite3" with
gem "pg"
Simone Carletti is correct and so is Joost. You only need to group the sqlite3 gem or remove it entirely from your Gemfile. Heroku just needs to know that you don't want to use sqlite3 for production
So this:
...
group :development, :test do
gem "sqlite3-ruby", "~> 1.3.0", :require => "sqlite3"
end
...
Or this:
...
#No reference to sqlite3-ruby
...
If you remove the reference entirely you will probably mess up your local db though
After banging my head against this problem, I realized I was pushing the master branch of my repo to heroku, while I was making all of my postgres changes in my deploy-postgres branch of my repo!
I merged my deploy-postgres branch with my local master [git checkout master; git merge deploy-postgres] and then could run git push heroku master as per the heroku documentation.
I was stuck on this for hours looking at every answer here, but I couldn't get enough details to make it come together. This paged walked me through everything. http://railsapps.github.io/rails-heroku-tutorial.html
Good luck.
i was facing similar issue, but I realized that I was on a different branch - new_layout and was pushing master.
So I pushed my desired branch to heroku using following command and everything worked fine.
git push heroku new_layout:master
You can use clearDB addon
and gem 'mysql2' instead of gem 'sqlite3'
I'm using sqlite3 and deploy to Heroku no problem. Here is my database.yml
# SQLite version 3.x
# gem install sqlite3-ruby (not necessary on OS X Leopard)
development:
adapter: sqlite3
database: db/development.sqlite3
pool: 5
timeout: 5000
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
adapter: sqlite3
database: db/test.sqlite3
pool: 5
timeout: 5000
production:
adapter: sqlite3
database: db/production.sqlite3
pool: 5
timeout: 5000

Resources