I am trying to upload RoR application to Heroku.
OS - Ubuntu, ruby version - 2.2.2p95, rails version - 4.2.1, database - PostgreSQL, installed RoR via BrightBox (Tutorial from treehouse), using git push heroku master to upload.
On the local server app works fine. When I push it to heroku, it gives out an error:
The page you were looking for doesn't exist.
You may have mistyped the address or the page may have moved.
If you are the application owner check the logs for more information.
Log files say:
/usr/bin/env: ruby2.2: No such file or directory
I've tried all the possible variants, I could find on the Internet:
rake rails:update:bin
Remove bin from ~/.gitignore (But there is no such file)
heroku config:set PATH=bin:vendor/bundle/ruby/2.2.2/bin:/usr/local/bin:/usr/bin:/bin
Adding this to the GemFile: ruby '2.2.2'
Changed #!/usr/bin/env ruby2.2(.2 (not sure about ".2")) to #!/usr/bin/env ruby (in bin/rake, bin/bundle and bin/rails)
heroku run rails db:migrate
rake rails:update:bin
ln -s /usr/bin/nodejs /usr/bin/node
To upload to heroku, I've configured git, after that logged in heroku, after that "heroku create", after that "git push heroku master", then "heroku open"
And many others... Any ideas how to solve that problem?
Do you have the gem rails12_factor installed and config.assets.compile = true ?
Not sure you mistyped or something else. but heroku run rails db:migrate will not work it should be heroku run rake db:migrate . It might be because you don't have root page. Precompile issue etc.
Run heroku logs -a app_name to see actual logs.
Related
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.
I've spent most of the last three days struggling with installing RefineryCMS on Heroku.
There are a lot of questions on SO and on various blogs, as well as documentation from Refinery and Heroku (and Rails) but none of the walkthroughs have helped 100%... Every page seems to be missing some vital piece of information.
I've tried to document all the necessary steps having gone through them three or four times, refining the procedure each time (working out what is and isn't necessary).
References included where they were obvious.
Run the refinery initialisation script, with Heroku option
refinerycms myapp --heroku
From http://refinerycms.com/guides/heroku
The output should give you a new heroku app and its name listed in the output:
"Creating Heroku app.. run heroku create --stack cedar from "."
Creating ... done, stack is cedar
http://[your heroku app].herokuapp.com/ | git#heroku.com:[your heroku app].git
Git remote heroku added"
Create bucket on Amazon AWS…
Should be self-explanatory.
Set connection info for Amazon in the Heroku environment
We need both sets of credentials.
AWS_* and FOG_* is for Heroku (and the rails precompile, I believe).
S3_* stuff is for Refinery to be able to upload images etc.
heroku config:add AWS_ACCESS_KEY_ID="<your key>" AWS_SECRET_ACCESS_KEY="<your secret>" FOG_DIRECTORY="<your bucket name>" FOG_PROVIDER="AWS" FOG_REGION="<your aws region>"
heroku config:add S3_BUCKET="<your bucket name>" S3_KEY="<your key>" S3_REGION="<your aws region>" S3_SECRET="<your secret>"
Add required gems to your Gemfile
gem 'globalize3', '0.3.0'
From refinerycms not working when adding page
gem 'unf'
(fixes some warnings)
gem 'rails_12factor'
From Why is the rails_12factor gem necessary on Heroku?
gem 'asset_sync'
From https://github.com/rumblelabs/asset_sync.
This gem seems the only way to get the assets pushed up to the cloud... Although perhaps you can make do without it; perhaps someone else can confirm.
ruby '2.0.0'
[ place this at the end of the Gemfile. (Needed to clear Heroku warnings) ]
Add asset_sync asset host path in config/environments/production.rb
config.action_controller.asset_host = "//#{ENV['FOG_DIRECTORY']}.s3.amazonaws.com"
From https://github.com/rumblelabs/asset_sync
Set the site name in config/initializers/refinery/core.rb
config.site_name = <your site name>
Set the s3_backend in the config/environments/production.rb
Refinery::Core.config.s3_backend = true
From https://github.com/refinery/refinerycms/issues/1879
Configure database details
Remove sqlite3 in config/database.yml and setting postgresql instead: this is optional but recommended by Heroku and others
For adapter:
sqlite3 => postgresql
For database name:
db/foo.sqlite3 => <sitename>_foo
Set user-env-precompile settings
heroku labs:enable user-env-compile -a myapp
From https://devcenter.heroku.com/articles/labs-user-env-compile
Run the Bundler
bundle install
Note: First of all, I had to run, as prompted:
1. rvm use 2.0.0 in order to match the version we're using in Gemfile
2. bundle update globalize3
From refinerycms not working when adding page
Create (local) production database
RAILS_ENV=production rake db:create
Set environment variables needed before asset precompile can work
(this is for *nix, do whatever you need to on your platform)
export FOG_DIRECTORY="<your bucket name>"
export FOG_PROVIDER="AWS"
export AWS_SECRET_ACCESS_KEY="<your secret>"
export AWS_ACCESS_KEY_ID="<your key>"
Precompile the assets (???)
NOTE: This MAY NOT be required... (I did do this step each time but cannot be sure whether it's required. The next steps suggest to me it's not necessary to manually precompile: we need to change the "initialize_on_precompile" to false, run a git push to heroku (i.e. without assets), then set the "initialize_on_precompile" back to true for future pushes. Not sure why we need to do this, and it may be an issue only with Rails 3.* (see: https://devcenter.heroku.com/articles/rails-asset-pipeline)
RAILS_ENV=production bundle exec rake assets:precompile
Set precompile false in config/application.rb
config.assets.initialize_on_precompile = false
From http://refinerycms.com/guides/heroku…
This setting is required the first time you git push to heroku, because otherwise the precompile step of git push heroku master always fails with:
Connecting to database specified by DATABASE_URL
rake aborted!
could not connect to server: Connection refused
Is the server running on host "127.0.0.1" and accepting
TCP/IP connections on port 5432?
NOTE: The reference is not clear on this (although setting intially to false then true is mentioned elsewhere).
Check in files to git and commit changes
Note: add the Gemfile.lock along with all the other changes.
Push to heroku
git push heroku master
Set precompile option back to true in config/application.rb
config.assets.initialize_on_precompile = true
From http://refinerycms.com/guides/heroku…
Add config/application.rb to git and commit (!!)
... if you don't, the next push will fail
Push to heroku (Demonstrates that this time it succeeds)
git push heroku master
Migrate and seed on the Heroku database
heroku run rake db:migrate
heroku run rake db:seed
From http://refinerycms.com/guides/heroku
Ready to go!
Hopefully from here you have access to your RefineryCMS page, with all the Refinery CSS and images displaying correctly (both on the admin screens and when 'viewing website' but still logged in.
If you add an image using the Refinery menu you should subsequently be able to see that image added to your AWS bucket. I don't have thumbnails working yet.
I have uploaded my app to heroku, its a simple app to test a login, it uses a gem named sorcery, but when I test it on heroku, I get Application Error
To upload to heroku I only have do this sequence:
git init
git add .
git commit -m "init"
heroku create
heroku push heroku master
heroku rake db:migrate
I get this error:
rake aborted!
undefined method `sorcery' for
#<Rails::Application::Configuration:0x0000000266e660>
)
Please help me, I think that the gem sorcery is causing this problem, but I dont know what to do.
You can see the website here
Does this work on you localhost?
I see form your list of commands that
bundle install
is not there.
Make sure you have
gem "sorcery"
in your gem file
Then do
heroku login
and
bundle install
You'll probably get other errors. Go to Getting Started with Rails 3.x on Heroku and follow the instructions.
After three evenings on this problem and reading all the posts about this, I have to ask this question finally!
I want to deploy the most simple Rails app to Heroku:
rails new test_appli
cd test_appli
git init
git add .
git commit -m "initial commit"
heroku create
git push heroku master
Everything's OK, the application works well on Heroku. After that, I'll create a SQLite3 database:
rails generate scaffold User name:string email:string
rake db:migrate
Everything's OK on the local machine. I can see localhost:3000/users well. Then I want to put the DB on Heroku. First I modify my Gemfile:
group :production do
gem 'pg'
end
group :development, :test do
gem 'sqlite3'
end
Then I send the whole thing to Heroku:
git init
git add .
git commit -m "with Database"
git push heroku master
heroku rake db:migrate
Then there are no errors in the batch, everything is OK, the DB is sent, but the page heroku.com/users gives the error
Rails 500, "We're sorry, but something went wrong"
I don't know more what to do. Can you help me?
I suspect you're trying to deploy a Rails 3.1 application to the bamboo stack (heroku create defaults to the 1.9.2 bamboo stack and doesn't run Rails 3.1 out of the box.). The Cedar stack is much better suited to Rails 3.1 sites -
try
heroku create --stack cedar
when creating your application on Heroku and repush it up. Also note your rake command on Heroku will become
heroku run rake db:migrate
Do:
heroku run rake db:schema:load
I had the same issue. It works for me after git push heroku master
Don't do the git init in the second set of commands - you only need to initialise your Git repo once.
Other than that this looks fine - are you seeing any errors anywhere?
Why would you use the pg gem in your production group, but the sqlite3 gem in your development group? Seems to me that your problem is likely due to the fact that you're developing with a different database then you're using in the production environment. If I were you, I would stick to one, which would make it much easier to debug.
If you really want/need to get the application running ASAP, then just run it in production with sqlite... Gemfile:
gem 'rails'
gem 'sqlite3'
Also, a quick way to figure out what the error is would be to run heroku logs from the unix console.
Which version of Rails?
Can you try creating the application running on the Cedar stack?
heroku create myapp --stack cedar
Given the application is running on cedar you need to modify the commands a bit, for example:
heroku run rake db:migrate
In any case you really need to checkout your logs, because your problem might not even be database related, but assets related.
Do you have the heroku shared 5mb database instance added?
When you create your heroku app (on cedar) it doesn't necessarily create the database automatically.
airlift:projects $ heroku create --stack cedar testapp9
Creating testapp9... done, stack is cedar
http://testapp9.herokuapp.com/ | git#heroku.com:testapp9.git
airlift:projects $ heroku addons --app testapp9
logging:basic
releases:basic
When you view your heroku config, you get nothing:
heroku config
airlift:projects $ heroku config --app testapp9
airlift:projects $
To add a database:
heroku addons:add shared-database:5mb
airlift:projects $ heroku addons:add shared-database:5mb --app testapp9
-----> Adding shared-database:5mb to testapp9... done, v3 (free)
airlift:projects $ heroku config
No app specified.
Run this command from an app folder or specify which app to use with --app <app name>
airlift:projects $ heroku config --app testapp9
DATABASE_URL => postgres://blah:blah#blah.compute-1.amazonaws.com/blah
SHARED_DATABASE_URL => postgres://blah:blah#blah.compute-1.amazonaws.com/blah
airlift:projects $
Then you should be able migrate your db.
Hey #redronin thanks for helping me find a way to connect to my postgres database on Heroku, however as a newbie to Heroku and postgresql I had to reverse engineer what "blah" was. So I figure I would break it down to help others as you helped me.
postgres://[user]:[password]#[servername].compute-1.amazonaws.com/[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.