"bash: rails: command not found" on heroku even though rails is installed - ruby-on-rails

I created a new heroku app, pushed the code, it was recognized as a rails app, and heroku started running the migrations. This lead to an error, and so I tried to run:
heroku run rails db:reset --remote staging
However, even though rails was obviously installed, I got this error:
bash: rails: command not found
I also tried replacing rails with /app/bin/rails, which didn't work either.

Related

Rails Heroku pg_ext.so

I'm trying to deploy my Rails app with Heroku. The app works fine in a local environment, and git push heroku master works fine, but an application error page is displayed when I try to view the deployed app. I'm getting similar errors from the logs and whenever I try to run a heroku run rake db:migrate command:
/app/vendor/bundle/ruby/2.3.0/gems/pg-0.21.0/lib/pg.rb:4:in `require': libruby.so.2.3: cannot open shared object file: No such file or directory - /app/vendor/bundle/ruby/2.3.0/gems/pg-0.21.0/lib/pg_ext.so (LoadError)
Windows 10 Bash with Ubuntu
Ruby 2.3.4p301
Rails 5.0.3
PostgreSQL 9.3.16
pg Gem 0.21.0
I've checked multiple posts that had the same error, but none of them helped.

Unable to deploy rails test app to Heroku

I'm working through the odin project's web development course and I'm getting tripped up on the last part of the installations project where you are tasked with deploying a rails app to Heroku. I've been working on this for about a week but I refuse to give up but I realize that I need some help.
Here's the link to the tutorial I'm trying to work through (on a mac):
http://installfest.railsbridge.org/installfest/deploy_a_rails_app
I have a Heroku account set up, and am running Ruby 2.3.0 and rails 4.2.5.1. Rubygems are at 2.6.1 (but I tried them at 2.5.1 too).
Everything works fine but when I get to heroku run rake db:migrate I always get the time out error:
[~/railsbridge/test_app] ruby-2.3.0 $ git push heroku master
Everything up-to-date
[~/railsbridge/test_app] ruby-2.3.0 $ heroku run rake db:migrate
Running rake db:migrate on powerful-journey-35824... up, run.9421
▸ ETIMEDOUT: connect ETIMEDOUT 50.19.103.36:5000
I saw another post suggesting that the problem is a result of the connection I'm using blocking port 5000 (I'm at a library). I checked port 5000 on canyouseeme.org as well but it also timed out.
I then tried deploying the app detached using heroku run:detached rake db:migrate and it seems to work until I open heroku again and it shows that the page I'm looking for doesn't exist.
Basically what I'm asking is, does anyone have any idea why this test app isn't getting pushed from my terminal to the heroku deployment page?
I'm a python/django guy, but taking a guess the "everything up to date" message is likely because you have not commited your changes to git. Try:
git commit -a
git push heroku master
Now run your rake command.

rake db:migrate bundle: command not found

I'm using Heroku and cloud9.io for my app.
I get the Error:
bash: bundle: command not found
When i try run the command:
heroku run rake db:migrate
Localy my app works fine without any error but i'm not able to migrate and i get the Application on herokuapp.com path.
Your problem may be due to the version of Ruby you are running.
I had a similar issue before, I tried everything possible(installing bundler, etc.), but one thing that worked for me was to manually set the config using following command:
heroku config:add GEM_PATH=vendor/bundle/1.8
Please note that you should change 1.8 to the version of Ruby you are currently running.

Heroku rake command

I'm trying to push my Rails app to Heroku, and I'm at the point where I'm trying to create/migrate the database, but I cannot get the rake command to run. Here's the message I'm getting:
$ heroku run rake db:migrate
Running `rake db:migrate` attached to terminal... up, run.2439
bash: rake: command not found
I spent a lot of time getting Postgres set up on my local machine, and it's working fine (was able to run rake commands without issue, and the app is running locally), but I don't know why I'm getting this error when I try to migrate the heroku database.
Figured it out. Turns out I had an error when I tried to deploy the app to Heroku, so it was never deployed. I didn't realize this because I was trying to push a branch that was not the "master" branch to heroku, thinking it would be fine. I wasn't getting any errors on that push, but that's because heroku won't try to deploy anything other than the "master" branch. Once I pushed the "master" branch, I got a bunch of pre-compile errors. Once those were cleaned up, I the app was deployed properly and I was able to run the rake commands.
Long story short, make sure your app successfully deployed before trying to run rake commands.

Heroku rails error trying to bring up console - sh: rails: not found

Trying to run the Heroku console but I am getting this following:
heroku run console
Running console attached to terminal... up, run.1
sh: console: not found
$ heroku run bash works but I seem to get a (green) bash prompt - "~ $" not a rails console! Can I get into the console from here?
fyi
git push heroku v311
Everything up-to-date
The first error is thrown simply because the console command doesn't exist. I personally have never meet a command called console in my life.
The syntax is heroku run the_command_i_want_to_run. For example: heroku run irb or heroku run bash.
The second error: There's no Rakefile in your project root. Since heroku run rails console say that Rails wasn't found, my guess is that your project wasn't (well) deployed.
Make sure you've done git push heroku.
You may also need to check the logs: heroku logs.
a guess:
heroku run rails console
If you're on the Bamboo stack (older stack than Cedar), try:
heroku run script/rails console
This works for me and is the command recommended in Heroku docs.
I got confused by this too.
It's just
$ heroku run console
Do this
heroku run -a my-app script/rails console
Reference: https://devcenter.heroku.com/articles/console-bamboo

Resources