I am just diving into Heroku and have hit a bit of a snag. Whenever I attempt to create my database I am getting the following error.
$ heroku rake db:migrate
rake aborted!
no such file to load -- tasks/rails
/disk1/home/slugs/274236_54c3556_0822-55414a07-d565-459a-9412-67cc0e995790/mnt/Rakefile:10:in `require'
(See full trace by running task with --trace)
(in /disk1/home/slugs/274236_54c3556_0822-55414a07-d565-459a-9412-67cc0e995790/mnt)
I am a little confused about what, exactly, the error message is trying to tell me. I can verify that no file exists called 'rails' or 'rails.rb' in my lib/tasks folder. But just for sanity sake I also used scaffold to create a new RoR app in a clean dirty and verified it's not present their either.
This application was previously running under Rails 2 before I upgraded it to Rails 3. So there is a distinct chance I foo bared something up when I upgraded.
Also, in case it helps, here is the same command as above with tracing enabled:
$ heroku rake db:migrate --trace
rake aborted!
no such file to load -- tasks/rails
/disk1/home/slugs/274236_54c3556_0822-d0995817-4e57-4415-9e95-18e86d90348d/mnt/Rakefile:10:in `require'
/disk1/home/slugs/274236_54c3556_0822-d0995817-4e57-4415-9e95-18e86d90348d/mnt/Rakefile:10
/home/slugs/274236_54c3556_0822-d0995817-4e57-4415-9e95-18e86d90348d/mnt/.bundle/gems/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:2383:in `load'
/home/slugs/274236_54c3556_0822-d0995817-4e57-4415-9e95-18e86d90348d/mnt/.bundle/gems/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:2383:in `raw_load_rakefile'
/home/slugs/274236_54c3556_0822-d0995817-4e57-4415-9e95-18e86d90348d/mnt/.bundle/gems/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:2017:in `load_rakefile'
/home/slugs/274236_54c3556_0822-d0995817-4e57-4415-9e95-18e86d90348d/mnt/.bundle/gems/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/home/slugs/274236_54c3556_0822-d0995817-4e57-4415-9e95-18e86d90348d/mnt/.bundle/gems/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:2016:in `load_rakefile'
/home/slugs/274236_54c3556_0822-d0995817-4e57-4415-9e95-18e86d90348d/mnt/.bundle/gems/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:2000:in `run'
/home/slugs/274236_54c3556_0822-d0995817-4e57-4415-9e95-18e86d90348d/mnt/.bundle/gems/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/home/slugs/274236_54c3556_0822-d0995817-4e57-4415-9e95-18e86d90348d/mnt/.bundle/gems/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:1998:in `run'
/home/slugs/274236_54c3556_0822-d0995817-4e57-4415-9e95-18e86d90348d/mnt/.bundle/gems/ruby/1.8/gems/rake-0.8.7/bin/rake:31
/usr/ruby1.8.7/bin/rake:19:in `load'
/usr/ruby1.8.7/bin/rake:19
(in /disk1/home/slugs/274236_54c3556_0822-d0995817-4e57-4415-9e95-18e86d90348d/mnt)
Any clues as to which direction to investigate would be highly appreciated.
Thanks!
EDIT
I am starting to think that Heroku is a red herring. I can attempt to run db:migrate locally and it produces the same errors (obviously with local paths instead of Heroku's paths).
This is a basic application with no special gem dependencies. Here is my Gemfile:
source :gemcutter
gem 'mysql', '2.7'
gem 'rails', '3.0.1'
#gem 'rfacebook'
gem 'sqlite3-ruby', :require => 'sqlite3'
Here is also 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
Looks like maybe your Rakefile has some Rails 2 artifacts in it or something. I'd start there, maybe comparing the default Rails 2 and Rails 3 Rakefiles.
Related
I'm deploying small app from C9 to github then to Heroku!
In heroku deploy dashboard, it says it's been deployed, but when I open the app, it just gives me error msg.
So I searched a lot of Stackoverflow answers and was following the direction from Heroku website(https://devcenter.heroku.com/articles/sqlite3) to remove sqlite3 and install the gem pg.
I did replace gem 'sqlite3' to gem 'pg' and did 'bundle install', and then
It says I need to convert my config/database.yml file, So I replaced it like this:
development:
adapter: postgresql
database: my_database_development
pool: 5
timeout: 5000
test:
adapter: postgresql
database: my_database_test
pool: 5
timeout: 5000
production:
adapter: postgresql
database: my_database_production
pool: 5
timeout: 5000
and then when I come back to c9 bash and type 'rake db:create',
it shows me
**rake aborted!
ActiveRecord::NoDatabaseError: FATAL: database "my_database_development" does not exist**
this error.
someone said 'bundle exec rake db:setup' would work, so I did, and then it shows
**Couldn't create database for {"adapter"=>"postgresql", "database"=>"my_database_test", "pool"=>5, "timeout"=>5000}
/home/ubuntu/workspace/db/schema.rb doesn't exist yet. Run `rake db:migrate` to create it, then try again. If you do not intend to use a database, you should instead alter /home/ubuntu/workspace/config/application.rb to limit the frameworks that will be loaded.**
I don't know how to react to this msg.... when I type 'rake db:migrate' and it shows this again.
rake aborted!
ActiveRecord::NoDatabaseError: FATAL: database "my_database_development" does not exist
I'm not using database, so maybe I can try something on 'config/application.rb' file, but how should I do??
It wasn't necessary to change your development and test databases, those could still have used sqlite3 and so your C9 instance would have continued to work.
(Although there are some advantages to using a consistent adapter across all environments)
If this is just a hobby exercise I would be tempted to keep sqlite3 for development and test.
Also, Heroku replaces the database.yml with its own version so you don't need a production stanza in database.yml
You do need the pg gem, but you can specify it is only loaded in production and you can specify the sqlite3 gem is only loaded in development and test. Do that in your Gemfile and then bundle.
group :development, :test do
gem 'sqlite3'
end
group :production do
gem 'pg'
end
If you want to use PostgreSQL in your C9 instance, you have to install PostgreSQL (the database, not just the adapter). It's not a simple process.
This wiki explains how you would install it.
https://wiki.postgresql.org/wiki/Detailed_installation_guides
one of the solution that you can create database manually this is easily solut
I am trying to deploy an app (just a simple app from a Rails tutorial) to heroku but it keeps giving me the same error message. I use the command:
git push heroku master
It starts well, and then suddenly appears this error:
-----> Preparing app for Rails asset pipeline
Running: rake assets:precompile
rake aborted!
Gem::LoadError: Specified 'sqlite3' for database adapter, but the gem is not loaded. Add `gem 'sqlite3'` to your Gemfile.
I did bundle install already, everything went smooth there.
Here is my Gemfile:
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
Maybe something I am missing something on databse.yml file?
# 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
By the way, I don't know if it helps, but I am using Rails 4.0.4, Ruby 2.1.1 and the version of SQLite which comes already installed on Mac, which is 3.7.13
Kirti is right in saying that Heroku does not support sqlite as adapter,
do the following
in the Gemfile:
group :production, :staging do
gem 'pg'
end
group :development, :test do
gem 'sqlite3'
end
in database.yml
production:
adapter: postgresql
database: name_of_your_db
pool: 5
timeout: 5000
SQLite is not intended as a production grade database. Instead Heroku provides production grade PostgreSQL databases as a service.
Read the details SQLite on Heroku
Getting this error while learning tutorial from this site.
http://ruby.railstutorial.org/chapters/a-demo-app#sec-demo_users_resource
tried to run this rails command on windows
rails generate scaffold User name:string email:string
and getting such error as:
> .../lib/sqlite3.rb:6:in 'require':cannot load such file -- sqlite3/sqlite3_native(LoadError)
>../lib/sqlite3.rb:2:in rescue in <top(required) >
>../bundler/runtime.rb:72:in 'require'
>.../bundler/runtime.rb:72:in block (2 level)
>from bin/rails:4: in 'require'
>from bin/rails:4: in <main>
I have already tried other answers like adding directory of sqlite to PATH..(its already there C:\RailsInstaller\Ruby2.0.0\lib\ruby\gems\2.0.0\gems\sqlite3-1.3.7-x86-mingw32)..
sqlite3(1.3.7-x86-mingw32 )is there in my gem list but still getting this error.
I have also tried to put sqlite3ext.h and sqlite3.h into /ext folder but its not working
tried this command
gem install sqlite3 --platform=ruby -- --with-sqlite3-dir=C:/path/to/sqlite3
no results
here is the Content of my database.yml
here is the database.yml file contents
# 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
UPDATE:
As adviced by one the user which really help me " you'll run into several problems that will be frustrating purely because on Windows. If you can't remove Windows, download Virtual Box and use a Linux Distro on it. It will make life much easier for you." Switching to Linux resolved everything. thanks https://stackoverflow.com/users/1092260/althaf-hameez for this advice.
See https://stackoverflow.com/a/16748607/2466276.
My actions:
1. Download http://packages.openknapsack.org/sqlite/sqlite-3.7.15.2-x86-windows.tar.lzma
2. Unpack to C:\Knapsack\x86
3. gem uninstall sqlite3
4. gem install sqlite3 --platform=ruby -- --with-opt-dir=C:/Knapsack/x86
I've created my stack on heroku and everything has been deployed but when I try to actually visit it via URL it just defaults to the 500.html error page. The app ran fine on my localhost, but I developed it in sqlite3. I've since changed my Gemfile to look like the following and ran bundle install.
#gem 'sqlite3'
gem 'thin'
group :production do
gem 'pg'
end
group :development, :test do
gem 'sqlite3'
end
When you visit the url it should be pointing to my login page.
This is what my database.yml file looks like...does this have anything to do with my problem.
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
Thanks for any advice
Use heroku logs to see the log file showing the 500 error's cause. If you haven't run your migrations that might be the cause. Be sure to run:
heroku run rake db:migrate
before you use your app.
Your database.yml file points to SQLite still. You'll need to change that to point to the PostgreSQL DB on heroku.
I can see from the comment that you are using sqlite for production into heroku. Which is not possible since heroku doesnt support sqlite. You can either use pg or mysql2 for your production environment. You can check here for solution :
How to configure database.yml for deployment to Heroku
And once you are done with it run these commands
heroku run rake db:reset
heroku run rake db:drop db:create db:seed
heroku run rake db:migrate
The symptom of my problem is pretty simple:
$ rake db:create
(in /home/jason/projects/blog)
rake aborted!
no such file to load -- pg
(See full trace by running task with --trace)
I've already successfully run bundle install and gem install pg, so I don't know what else I might need to do.
Here's my `config/database.yml if it helps:
# SQLite version 3.x
# gem install sqlite3-ruby (not necessary on OS X Leopard)
development:
adapter: postgresql
encoding: unicode
database: blog_development
pool: 5
username: blog
password: foo
# 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: postgresql
encoding: unicode
database: blog_development
pool: 5
username: blog
password: foo
production:
adapter: sqlite3
database: db/production.sqlite3
pool: 5
timeout: 5000
I figured it out. If I use pg instead of postgresql in my config/database.yml, it works.
Go to console and type below:
vim Gemfile
Inside the file commend the below:
- #gem 'sqlite3-ruby', :require => 'sqlite3'
Inside the file add the below:
- gem 'pg', :require => 'pg'
Problem Solved!!! :-) Enjoy!
One possibility is that the rake binary that you are running is from another ruby/gem environment and that it doesn't have access to the gems that you've installed.
If you have more than one version of ruby installed, try running which gem and then which rake to see if they are being run from the same bin directory. For example, on my machine both binaries are executed from bin directories under the same Ruby install:
/Users/scott/.rvm/rubies/ruby-1.9.2-p136/bin/gem
/Users/scott/.rvm/gems/ruby-1.9.2-p136/bin/rake
If you only have one ruby version installed on your system, then this isn't the answer!