I'm a novie in heroku. When I was performing my CS169.1x homework2 (deploying an application) I ran into a problem with database filling using the following command: heroku run rake db:migrate. Here is terminal dump:
saasbook#saasbook:~/Documents/hw2_rottenpotatoes$ git pull heroku master
From heroku.com:afternoon-cove-7289
* branch master -> FETCH_HEAD
Already up-to-date.
saasbook#saasbook:~/Documents/hw2_rottenpotatoes$ git push heroku master
Everything up-to-date
saasbook#saasbook:~/Documents/hw2_rottenpotatoes$ heroku run rake db:migrate
heroku run rake db:migrate: command not found
saasbook#saasbook:~/Documents/hw2_rottenpotatoes$
What may be wrong? If there is error dump on heroku to check?
Have you installed the heroku gem? If you have heroku in the gemfile, you may need to do
bundle exec heroku run...
just to make sure you have heroku installed, what happens when you run:
$heroku help
Related
I am trying to get into my rails heroku database. Usually I just run:
heroku run rails console
but it's giving me an error: bash: rails: command not found
I have no idea what caused this. Haven't updated my project code.
heroku --version
heroku-toolbelt/3.36.5 (x86_64-darwin15) ruby/2.2.4
heroku-cli/5.6.14-b0cc983 (darwin-amd64) go1.7.4
=== Installed Plugins
heroku-redis#1.2.8
The same happened to me. My problem was that I didn't commit my changes before the first push, so I didn't have the project up. I did:
git add .
git commit -m "first commit"
git push origin heroku
then, before trying rails c, you need to setup the database.
heroku run rake db:migrate
I followed this devcenter.heroku: getting started with rails4
I am developing my first Rails app, and I have made some database entries that are showing up in the development environment, but not in the production environment (Heroku). I have run
git add
git commit
git push origin master
git push heroku master
rake db:migrate
in the terminal.
$ heroku create
$ git push heroku master
After running these commands, to get the application’s database to work, you’ll also have to migrate the production database:
$ heroku run rake db:migrate
$ heroku open
if this doesn't work please show your logs.
you just need to run
heroku run rake db:migrate
I recently started collaborating in a project on Heroku using Ruby on Rails. I was added as a collaborator and added the remote to my environment. After some development, I pushed some changes and had no problems:
$ git push staging
Where staging is the name of my remote.
Later, when trying to run "rake test" on Heroku, I recieved an error:
$heroku run rake test --app staging
Running `rake test` attached to terminal... failed
! You do not have access to the app staging.
Which is odd, as I was perfectly able to push my own changes. I checked the Heroku dashboard and saw that my push was logged there. I then tried to view the logs using the console, and the same problem occured.
$ heroku logs --app staging
! You do not have access to the app staging.
Finally, I tried to access the console, but it failed as well.
$ heroku run rails console --app staging
Running `rails console` attached to terminal... failed
! You do not have access to the app staging.
At this point I updated my Heroku toolbelt installation, and used "heroku auth" to verify that my email was showing up, but the error persists. I'm currently contacting Heroku support but I'm hoping someone with a similar issue could aid me in parallel.
Thanks!
So just in case anyone is having a similar problem, this occurs because I was mixing the name of my Heroku Apps with the name of my git remotes. So when I was calling --app staging (the name of my remote), I should have been using the actual name of the app, as found in Heroku.
Be sure to run heroku login before using Heroku toolbelt commands for the first time. It will not tell you that you have not signed in before.
This happen also when you haven't added heroku git remote repository.
You can add it with this command:
git remote add heroku https://git.heroku.com/<your project>.git
You can also type
heroku git:remote -a AppName
I had the same problem because I had created multiple remotes on heroku (e.g. a remote called "staging" for staging, and the default remote "heroku" for prod).
Solution
Use these two options to let heroku know which app and remote you're referring to:
-a your_app_name, and
--remote name_of_remote
Examples
For example, for the remote called staging:
heroku run env -a your_app_name --remote staging
or like this for the production remote:
heroku run env -a your_app_name --remote heroku
Extra Info
The above code runs the simple command env, but you can replace that with whatever commands you want to run on heroku.
Replace the name of the remote. By default, heroku creates one remote called heroku, which is typically the production remote. You can get your remotes with the command: git remote.
This was caused of your ssh key is no more permited to access. Make sure your ssh key is same. You can also regenarate your ssh key and add this to heroku.
You can also run:
heroku run rake test --remote staging
Not sure what happens under the hood, but locally the CLI tool figures out which app you mean based on your git remote.
I had the same problem in my case I was not pushing from master so I had to use this:
git push heroku :main
I had the same problem. It was cause I was not login in Heroku.
First I type:
heroku login
then i type:
heroku git:remote -a restserver-node-jngs
and it works.
I hope it be helpfull for someone.
This is a basic, stupid question, but I configured my Rails app to deploy on Heroku, and I'm able to open the application from my Heroku account, etc. But when I want to change my code, do I need to re-deploy the whole application? I tried just committing/pushing to heroku master, but I get the error "fatal: remote end hung up unexpectedly." What should I do instead?
Also: am I supposed to run db:migrate BEFORE deploying/pushing?
There is nothing stupid about a basic question, as everyone has to start somewhere.
The basic process with deploying a Rails app to Heroku is to:
Make changes
Add and Commit your changes ($ git add files_changed.rb & $ git commit -m "make changes")
Push your changes to Heroku ($ git push heroku master)
This then pushes your code to the remote Heroku repository and redeploys your Rails application. If you have made any database migrations, you need to run:
$ heroku run rake db:migrate
This runs db:migrate on your heroku app - see how that works? :)
Running rake db:migrate locally simply migrates your local development database.
I'm trying to run the chapter two demo_app from the Ruby on Rails 3 Tutorial book on Heroku and it is not working. gws-demp-app.heroku.com gives the default Rails page, but gws-demo-app.heroku.com/users gives a web page that says "We're sorry, but something went wrong." On my desktop it works fine. I'm using the tools from RailsInstaller.org.
I had problems with heroku rake db:migrate at the end of the chapter not finding the activerecord-postgresql-adapter so I did install gem pg, bundle install, and updated the Gemfile and repositories. Everything is on github at https://github.com/gwshaw/demo_app.
What looks like the same problem appears at https://stackoverflow.com/questions/7619551/heroku-rake-dbmigrate-success-but-not-showing-in-app
I tried heroku restart recommended there, but that causes: Restarting processes... C:/RailsInstaller/Ruby1.9.2/lib/ruby/1.9.1/net/http.rb:6
44:in `initialize': getaddrinfo: No such host is known. (SocketError)
I tried what is claimed to work, precompiling assets with bundle exec rake assets:precompile, but that generates an error: C:/RailsInstaller/Ruby1.9.2/bin/ruby.exe C:/RailsInstaller/Ruby1.9.2/bin/rake as
sets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets
rake aborted!
TypeError: Object doesn't support this property or method
(in C:/Sites/rails_projects/demo_app/app/assets/javascripts/application.js)
I'm new to ruby and rails so I'm at a loss. Any ideas?
Solved below.
Yes , this worked for me too after installing the pg gem, I ran the following:
bundle exec rake assets:precompile
git add .
git commit -am "add a note reflecting changes made"
git push
heroku create
git push heroku master
heroku rake db:migrate
heroku db:push
after invoking these commands, I was able to successfully open the demo_app on heroku.
Thanks for your post — I'm new to Rails, but reading your post helped me with a very similar issue.
Here's what worked for me:
Install pg gem to use postgreSQL on Heroku: (related article)
sudo gem install pg
Install taps gem to allow push of your local database to Heroku: (related article)
gem install taps
then the following sequence…
bundle exec rake assets:precompile
git add .
git commit -am "add a note reflecting changes made"
git push
heroku create
git push heroku master
heroku rake db:migrate
heroku db:push
If you're still having trouble, these articles are helpful too:
Stack Overflow - Heroku command: Heroku Rake db:migrate fails
Heroku - Getting Started with Rails 3.0 on Heroku/Cedar
The problem with bundle exec rake assets:precompile was the key and is solved here RoR Precompiling Assets fail while rake assets:precompile - on basically empty application.js
Oddly, Heroku wouldn't automatically precompile the assets on a git push heroku and thus would not find them. I don't think this little demo_app even uses assets, so that may be why it didn't precompile, but it still could not find applicaiton.css and failed. Once I set config.log_level = :debug in production.rb, I could see the problem in the logs. With the precompile working due to the above fix, everything worked.