I'm running the run rake db:migration command and terminal is telling me that rake is not a command
$ heroku run rake db:migrate --app"glacial-lake-5597"
Running `rake db:migrate --appglacial-lake-5597` attached to terminal... up, run.1930
bash: rake: command not found
$ heroku run rake db:migrate
Running `rake db:migrate` attached to terminal... up, run.4588
bash: rake: command not found
i've already bundle installed and committed changes to git.
I've looked all over StackOverflow and I cannot find the answer
Can someone point me in the right direction
I had the same problem,
The cause was that I hadn't specified a remote branch when first pushing to Heroku, Heroku apps start with a blank repository – they have no branches and no code. So the first time you deploy, you need to specify a remote branch.
git push heroku master
I hadn't done this initially and in doing so this fixed my rake problem.
See if the gem sqlite is in development only.
like this
group :development do
gem 'sqlite3'
gem 'web-console'
gem 'listen', '~> 3.0.5'
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
end
To check to see if your app deployed correctly just look at the trace in your shell after you attempt to push to Heroku. I had been running mine in Cloud 9 and not really looking at the results because they were so small, I'm new to this, and, heck, it had always deployed perfectly before....
When I scrolled through I found two errors mentioned; I corrected these errors, then the heroku db migration ran fine. One error was a missing line of code, the other I found on SO (which I can't refind the link to, sorry), and it had to do with the file extensions for my css files, which I changed from .css to .css.scss.
Related
I've been trying to migrate my database to heroku, without success. I have added a few more users to my database and when trying to log them in with email address and password on my heroku app, I get invalid email/password error, even though this works perfectly fine on my local server. NO errors at all when doing all the steps described below.
As suggested in a previous post, I've tried the following:
Made changes to local code
Ran any migrations LOCALLY - I used bundle exec rake db:migrate
Added all changed files to Git git add -A
Commit all added files to git git commit -m "Adding features"
Pushed the changes to Heroku git push heroku master
Ran heroku run rake db:migrate
After I run this I get:
astelvida:~/workspace/sample_app (master) $ heroku run rake db:migrate
Running rake db:migrate on ⬢ shrouded-ravine-80000... up, run.2794
ActiveRecord::SchemaMigration Load (0.8ms)
SELECT "schema_migrations".* FROM "schema_migrations"
Following migrations do heroku restart
I've also checked my .sqlite3 file to check that the new users actually exist in the database.
I've also tried this: $ bundle exec rake db:migrate RAILS_ENV=production
I've also updated my gemfile.lock.
My gems in dev & production:
group :development, :test do
gem 'sqlite3', '1.3.9'
gem 'byebug', '3.4.0'
gem 'web-console', '2.0.0.beta3'
gem 'spring', '1.1.3'
end
group :production do
gem 'pg', '0.17.1'
gem 'rails_12factor', '0.0.2'
gem 'puma', '3.1.0'
end
Note: I run bundle install --without production, however this is how I've always been using it, and the login data works for some of the users i've created in the past. Also I'm using rails 4.2.2.
Ok... let's get something clear here.
Rake db:migrate doesn't migrate the data of the database. It runs all migrations (Table creations, updates, etc) so that the database structure is the same, however the data isn't! It's a fresh new database with the same structure.
What you're doing is making sure your PG database has the same structure as your sqlite3 database and it does. But if you want to pass the data from one to another It's gonna be hard i would say. You have to create a dump file from your sqlite 3 database, change it to pg and run in your heroku app.
Here is a question about it.
Convert SQLITE SQL dump file to POSTGRESQL
I am trying to git push heroku master my app into production for heroku, and despite the fact that my gemfile looks like this:
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug'
# Access an IRB console on exception pages or by using <%= console %> in views
gem 'web-console', '~> 2.0'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
end
group :production do
gem 'pg', '0.18.3'
gem 'rails_12factor'
end
and I do :
bundle install --without production
and
git commit -a -m
and finally
git push heroku master
it will reject the transfer saying that pg is not installed in gemfile
Preparing app for Rails asset pipeline
remote: Running: rake assets:precompile
remote: rake aborted!
remote: Gem::LoadError: Specified 'postgresql' for database adapter, but the gem is not loaded. Add `gem 'pg'` to your Gemfile (and ensure its version is at the minimum required by ActiveRecord).
So, when I do heroku open
I get this
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.
I dont know if the two errors are related. Heroku did upload my id_rsa.pub key and I did log in via command line through emails and pwd.
So this is where I think the error was, in case someone goes through the same.
1) when I tried to create a ssh key through
cat ~/.ssh/id_rsa.pub
despite the fact that I do have ssh installed by default on my linux it that command did not work at first, so I ended up generating in through a ssh keygene command. I copied it and pasted it (the public one) in my bitbucket ssh keys, but the private one which had been generated did not match with the original one. and the error was due to this mismatch of keys between the private local and public.
I think I also messed up as I was using two different computers and if you do that you have to go on to another schema of different keys for the same account etc.
I restarted from scratch, I deleted my git directory, i deleted my repository at bitbucket and the app at heroku and tried that command again.
For some reason this time the command worked (no, it was not misspelled the first time), so now the synchronization of keys was correct. This time I copied it and pasted it straightway in the ssh keys of bitbucket.
and I went trough the same stuff again like this:
This follows the instructions from the great book by Michael Hartl (The Ruby on Rails Tutorial)
cat ~/.ssh/id_rsa.pub
$ git remote add origin git#bitbucket.org:<username>/hello_app.git
$ git push -u origin --all # pushes up the repo and its refs for the first time
$ git remote add origin git#bitbucket.org:myname/hello_app.git
now for the gemfile
group :production do
gem 'pg', '0.18.3'
gem 'rails_12factor', '0.0.2'
end
$ bundle install --without production
curiously now it did not complain about the pg but about mysql2, so this really does not matter much appearingly
$ git commit -a -m "Update Gemfile.lock for Heroku"
$ heroku version
$ heroku login
$ heroku keys:add
(this time the keys were added or fetched correctly)
$ heroku create
Creating damp-fortress-5769... done, stack is cedar
http://damp-fortress-5769.herokuapp.com/ | git#heroku.com:damp-fortress-5769.git
Git remote heroku added
$ git push heroku master
heroku open
I have this configuration in my Gemfile:
group :test do
# ...
gem "shoulda-matchers", :git => "git://github.com/watu/shoulda-matchers.git", :branch => "do_not_load_minitest"
end
which works fine locally, but when I push to Heroku, when I try to run rake db:migrate, I get this error:
git://github.com/watu/shoulda-matchers.git (at do_not_load_minitest) is not checked out. Please run bundle install
Indeed I don't see it in the output of bundle install being run on Heroku, maybe because it's on the test group and Heroku is not installing the test group. But then, why is it complaining when I run rake db:migrate? should it run in staging env?
I tried switching to the http url and all I got is the same error with another URL:
https://github.com/watu/shoulda-matchers.git (at do_not_load_minitest) is not checked out. Please run bundle install
Moving the line outside the :test group workarounded the problem. What's the proper solution?
If you don't really need that gem (since it is in :test group), you can add this configuration to your app:
heroku config:add BUNDLE_WITHOUT="development:test" --app <your_app>
I've got a basic app that I'm trying to deploy to Heroku. I can push it to Heroku with git and it shows the default Rails welcome page, but when I try to access any subpages, (pages that work when I deploy on a local server with rails server) I get "something went wrong" messages.
I pulled up the log and I'm get 500 responses from the server and lots of ActiveRecord::ConnectionNotEstablished messages which seems to be an issue connecting to the database.
Further, when I tried to run heroku rake db:migrate, I get the following errors
rake aborted!
Please install the postgresql adapter: `gem install activerecord-postgresql-adap
ter` (pg is not part of the bundle. Add it to Gemfile.)
Tasks: TOP => db:migrate => db:load_config
(See full trace by running task with --trace)
Per the suggestion above, I did add gem 'pg' to the Gemfile After running gem install pg and then bundle install. Also, I tried gem install activerecord-postgresql-adapter (on Windows) and get
ERROR: Could not find a valid gem 'activerecord-postgresql-adapter' (>= 0) in a
ny repository
ERROR: Possible alternatives: activerecord-jdbcpostgresql-adapter, activerecord
-postgis-adapter, activerecord-jdbcmssql-adapter, activerecord-jdbcmysql-adapter
, activerecord-postgresql-cursors
From the suggestion of the book that I'm reading, I ran heroku db:push and it competed without error, but it didn't solve the problem of the pages not rendering once the app is push to Heroku.
update: I've tried installing the activerecord-jdbcpostgresql-adapter as suggested as a possible alternative. I updated the Gemfile with
group :production, :staging do
gem 'pg'
end
and the database.yml file with
production:
adapter: jdbcpostgresql
and when I heroku rake db:migrate, it still gives me the message telling me to install postgresql adapter
If heroku rake db:migrate runs without error, then your database connection info is correct. It's likely that there's another error preventing the page from rendering correctly. If you tail your heroku logs while making a request, are you still getting the same database error? I suspect that you'll find it's a different error that you'll need to fix.
I am currently making my way through the Ruby on Rails tutorial over at http://ruby.railstutorial.org/ and I am trying to migrate the demo_app database to heroku.
heroku rake db:migrate
rake aborted!
unable to open database file
I have read on other stackoverflow posts that some people fixed this by entering
group :production, :staging do
gem "pg"
end
group :development, :test do
gem "sqlite3-ruby", "~> 1.3.0", :require => "sqlite3"
end
in the gemfile. I also entered it into my gemfile and then deleted my old gemfile.lock and redid my bundle install AND rake db:migrate command. I am still receiving the same error.
I am obviously brand new to ruby, rails and heroku but I understand that the problem seems to be that I am using sqlite locally and postgresql in production (on heroku). Do I now have to install this postgresql onto my machine and then RE-migrate the DB? I am afraid I will not be able to get much more out of the tutorials (or ruby on rails itself) if I cannot use heroku.
Kill it!
I was having the same problem and found no solutions. I think something we are doing in those tutorials is leading us to mangle the database.yml file that heroku generates.
I ended up destroying my heroku app
heroku destroy
and then creating a new one, pushing a fresh copy, and running
heroku create
git push heroku master
heroku rakedb:migrate
This time everything worked fine! Just make sure you have the pg gem in your gemfile for production
group :production do
gem "pg"
end
and add config/database.yml to your .gitignore file too for good measure.
or if it's working ok locally do a heroku db:push to magically put your local sqlite DB into Heroku's postgresql db.
I always work with the same DB platform locally just so I don't run into any differences (usually only when you start doing DB specific SQL) so I run Postgresql locally too.
Had the same problem... with Heroku interface... ran:
heroku rake db:migrate --trace
and found the problem to be with faker, not being found...Since 'faker' in our Gemfile is loaded in the development group, I loaded it in the production group as well.
saved Gemfile
bundle install
git add .
git commit -m "fixed faker"
git push
git heroku push
heroku rake db:migrate
heroku rake db:populate
now everything works...the QUESTION, now is what to do with 100 users on my production site?
At least I can continue with Hartl's tutorial!!