Application Error on heroku - ruby-on-rails

I'm follow an online railstutorial.
I'm a newbie, and now I finished just my second app.
It works ok on a local machine, but I have a problem with heroku.
I pushing my app successfully, and then I done heroku rake db:migrate
But I see this error on my page
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
And I see this warning in command line:
rake aborted! Please install the postgresql adapter: gem install
activerecord-postgresql-adap ter (pg is not part of the bundle. Add
it to Gemfile.)
I google this error and found that I need add this strings to my gemfile:
gem 'sqlite3', :group => :development
gem 'pg', :group => :production
Done it, and retried, but nothing changed, and I still have this in my command line
Please install the postgresql adapter: gem install
activerecord-postgresql-adap ter (pg is not part of the bundle. Add
it to Gemfile.)
I can't understand it, cause I defenitely had pg gem, and I can see his installation on my local machine
Using thor (0.14.6)
Using railties (3.2.1)
Using coffee-rails (3.2.2)
Using jquery-rails (2.0.2)
Using pg (0.13.2)
Using rails (3.2.1)
Using sass (3.1.16)
Using sass-rails (3.2.5)
Using sqlite3 (1.3.6)
Using uglifier (1.2.4)
but I can't see the same, when bundle installing on heroku server
Installing thor (0.14.6)
Installing railties (3.2.1)
Installing coffee-rails (3.2.2)
Installing jquery-rails (2.0.2)
Using bundler (1.0.7)
Installing rails (3.2.1)
Installing sass (3.1.16)
Installing sass-rails (3.2.5)
Installing uglifier (1.2.4)
How can I solve it? Really have no idea. Please help me.
btw, sorry for my english, I'm from russia)
update:
yeah, i see that it runs bundle install --without development, but my gemfile now looks like:
group :production do
gem 'pg'
end
group :development, :test do
gem 'sqlite3-ruby', :require => 'sqlite3'
end
as you can see, 'pg' is definitely out of development group, but heroku didn't install it

Looks like you added the pg gem to the development group in your Gemfile - when Heroku deploys, it runs bundle install --without development, meaning that it'll not install gems in that group. Move the gem outside of the development group.

If you've updated your Gemfile make sure you commit it and the Gemfile.lock to git and then repush your application to Heroku.

Related

Could not find 'ruby-debug-ide' in VS Code

I am trying to use VS Code for debugging a Ruby on Rails application. I have installed both the Ruby and Rubocop extension into VS Code. Then I have installed ruby-debug-ide -v 0.6.0 and debase -v 0.2.1 both via sudo gem install and rvmsudo gem install. However, when trying to debug the application using Rails server, I get the following exception:
/usr/lib/ruby/2.3.0/rubygems/dependency.rb:319:in `to_specs'
:
Could not find 'ruby-debug-ide' (>= 0.a) among 48 total gem(s)
(
Gem::LoadError
)
Checked in 'GEM_PATH=/home/myname/.rvm/gems/ruby-2.3.1:/home/myname/.rvm/gems/ruby-2.3.1#global', execute `gem env` for more information
from /usr/lib/ruby/2.3.0/rubygems/dependency.rb:328:in `to_spec'
from /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_gem.rb:65:in `gem'
from /usr/local/bin/rdebug-ide:22:in `<main>'
However, when I list all installed gems with rvm all do gem list, neither of the installed gems are there:
*** LOCAL GEMS ***
...
concurrent-ruby (1.0.2)
did_you_mean (1.0.0)
erubis (2.7.0)
...
rdoc (4.2.1)
rubygems-bundler (1.4.4)
rvm (1.11.3.9)
...
Does anybody know how to fix this?
In my case, the solution was quite simple. As a newbie in Ruby on Rails, I did not realize that instead of installing gems into Ruby root, I should specify them in my Gemfile. So, inside Gemfile I put only:
group :development do
gem 'ruby-debug-ide', '0.6.0'
gem 'debase', '0.2.1'
gem 'web-console', '~> 2.0'
gem 'spring'
end
and this solved the issue for me.
I also had this issue for a while, there doesn't seem to be a clear cut way of resolving this problem. All I had to do was run vs code through the terminal and I could debug my rails project, assuming you are using Linux. Just make sure you don't open vs code via a shortcut.

Rails console doesn't work (openshift)

I have been using openshift for a week now, and everything works fine. Unfortunately, neither with Ruby2.0 or Ruby1.9.3 can I access the Rails4 console online, which is a real problem.
bundle exec rails console RAILS_ENV="production"
fails, asking me to run bundle install, and bundle install fails, telling me it can't install active support 4.1.4, even though during deployment openshift says it is installed in .vendor/bundle. I tried deleted my app several times, recreating, starting with a clean version of the railsapp example on github... nothing works.
I hope you can help me, thanks in advance
[app-root/repo]$ bundle exec rails console RAILS_ENV="production"
bundler: command not found: rails
Install missing gem executables with `bundle install`
[app-root/repo]$ bundle install
Fetching gem metadata from https://rubygems.org/.........
Using rake (0.9.6)
Using i18n (0.6.11)
Using json (1.8.1)
Using minitest (5.4.0)
Using thread_safe (0.3.4)
Using tzinfo (1.2.1)
Installing activesupport (4.1.4)
Gem::InstallError: activesupport requires Ruby version >= 1.9.3.
An error occurred while installing activesupport (4.1.4), and Bundler
cannot continue.
Make sure that `gem install activesupport -v '4.1.4'` succeeds before
bundling.
[app-root/repo]$ gem install activesupport -v '4.1.4'
Fetching: i18n-0.6.11.gem (100%)
Successfully installed i18n-0.6.11
Fetching: thread_safe-0.3.4.gem (100%)
Successfully installed thread_safe-0.3.4
Fetching: tzinfo-1.2.2.gem (100%)
Successfully installed tzinfo-1.2.2
Fetching: activesupport-4.1.4.gem (100%)
Successfully installed activesupport-4.1.4
4 gems installed
[app-root/repo]$ bundle install
Fetching gem metadata from https://rubygems.org/.........
Using rake (0.9.6)
Using i18n (0.6.11)
Using json (1.8.1)
Using minitest (5.4.0)
Using thread_safe (0.3.4)
Using tzinfo (1.2.1)
Installing activesupport (4.1.4)
Gem::InstallError: activesupport requires Ruby version >= 1.9.3.
An error occurred while installing activesupport (4.1.4), and Bundler
cannot continue.
Make sure that `gem install activesupport -v '4.1.4'` succeeds before
bundling.
I am using the Gemfile provided on Github, with minor changes. I had to modify the following lines a bit, or rails would complain:
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring', group: :development
had to be replaced by
group :development do
gem 'spring'
end
group :doc do
gem 'sdoc', '~> 0.4.0'
end
Just ask if you need more info.
I use
cd ~/app-root/repo && RAILS_ENV=production bundle exec rails console
And it works fine for me.
OpenShift is quite picky with the Gemfile format:
In my case it was:
gem 'guard-rspec', require: false
Has to be:
gem 'guard-rspec', :require => false
That fixed the first error, bundle was complaining about the file format, and then I had the problem of the gems not being there.
So again I connected to the console and did a gem install bundler in
app-deployment/current/repo
and
~/.gem/bin/bundle exec rails c
did work this time

Having trouble finding a solution for Rails/Heroku: "The page you were looking for doesn't exist"

I signed up for the One Month Rails program a while back and am just now getting around to it. I've installed Rails, set up GitHub and Heroku. Everything seems to be working fine, the Rails test app runs on my local server, and I'm not getting any errors when pushing to Heroku but I keep getting "The page you were looking for doesn't exist."
I tried adding a root route, installing the 'pg' gem, running rake db:migrate, etc. At this point I've decided to delete the entire Ruby project, start over and re-install the 'pg' gem.
My Gemfile looks like this:
source 'https://rubygems.org'
gem 'rails', '4.1.4'
group :production do
gem 'pg'
end
group :development, :test do
gem 'sqlite3'
end
gem 'sass-rails', '~> 4.0.3'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0', group: :doc
gem 'spring', group: :development
And my Heroku log looks like this:
-----> Ruby app detected
-----> Compiling Ruby/Rails
-----> Using Ruby version: ruby-2.0.0
-----> Installing dependencies using 1.6.3
Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment
Using json 1.8.1
Using minitest 5.3.5
Using thread_safe 0.3.4
Using builder 3.2.2
Using i18n 0.6.9
Using erubis 2.7.0
Using rake 10.3.2
Using rack 1.5.2
Using mime-types 1.25.1
Using polyglot 0.3.5
Using arel 5.0.1.20140414130214
Using coffee-script-source 1.7.0
Using execjs 2.2.1
Using thor 0.19.1
Using hike 1.2.3
Using pg 0.17.1
Using multi_json 1.10.1
Using bundler 1.6.3
Using tilt 1.4.1
Using sass 3.2.19
Using rdoc 4.1.1
Using tzinfo 1.2.1
Using treetop 1.4.15
Using rack-test 0.6.2
Using coffee-script 2.2.0
Using uglifier 2.5.1
Using sdoc 0.4.0
Using activesupport 4.1.4
Using mail 2.5.4
Using actionview 4.1.4
Using activemodel 4.1.4
Using jbuilder 2.1.1
Using actionpack 4.1.4
Using railties 4.1.4
Using actionmailer 4.1.4
Using activerecord 4.1.4
Using sprockets 2.11.0
Using coffee-rails 4.0.1
Using jquery-rails 3.1.1
Using sprockets-rails 2.1.3
Using turbolinks 2.2.2
Using rails 4.1.4
Using sass-rails 4.0.3
Your bundle is complete!
Gems in the groups development and test were not installed.
It was installed into ./vendor/bundle
Bundle completed (0.61s)
Cleaning up the bundler cache.
-----> Preparing app for Rails asset pipeline
Running: rake assets:precompile
Asset precompilation completed (2.01s)
Cleaning assets
Running: rake assets:clean
-----> WARNINGS:
Include 'rails_12factor' gem to enable all platform features
See https://devcenter.heroku.com/articles/rails-integration-gems for more information.
You have not declared a Ruby version in your Gemfile.
To set your Ruby version add this line to your Gemfile:
ruby '2.0.0'
# See https://devcenter.heroku.com/articles/ruby-versions for more information.
No Procfile detected, using the default web server (webrick)
https://devcenter.heroku.com/articles/ruby-default-web-server
-----> Discovering process types
Procfile declares types -> (none)
Default types for Ruby -> console, rake, web, worker
-----> Compressing... done, 21.2MB
-----> Launching... done, v7
http://immense-lake-7186.herokuapp.com/ deployed to Heroku
Any help would be super appreciated! Thanks!
Error
Firstly, having a Rails error of The Page You Were Looking For Doesn't Exist is a Rails error, not a Heroku one:
The difference is if you have a "Heroku" error, it's platform-level; meaning it will show when you have issues with your backend system (database, dependencies, OS, etc):
--
Since you're receiving the first (red) error, you'll want to look at what's happening to cause this.
If it happens when you first hit the application, it will probably mean you either don't have the root path declared or you don't have any controller#actions defined to handle the request.
I would try this:
#config/routes.rb
root to: "application#index"
#app/controllers/application_controller.rb
Class ApplicationController < ActionController::Base
def index
end
end
#app/views/application/index.html.erb
Test
When you push to Heroku again, you should try:
$ git add .
$ git commit -a -m "Heroku"
$ git push heroku master

jruby -S bundle does not run as it says jruby-openssl gem missing

I'm using Jruby 1.6.7 with ruby >1.9. when I run `jruby -S bundle, I see the following error
Fetching gem metadata from https://rubygems.org/.JRuby limited openssl loaded. http://jruby.org/openssl
gem install jruby-openssl for full support.
Unfortunately, a fatal error has occurred. Please see the Bundler
troubleshooting documentation at .... Thanks!
LoadError: OpenSSL::SSL requires the jruby-openssl gem
My Gemfile has this open-ssl already
source 'https://rubygems.org'
gem 'rails', '3.2.6'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'activerecord-jdbcsqlite3-adapter'
gem 'activerecord-oracle_enhanced-adapter', '~>1.4.1'
gem 'jruby-openssl'
and here is part of my Gemfile.lock
jdbc-sqlite3 (3.7.2)
journey (1.0.4)
jquery-rails (2.0.2)
railties (>= 3.2.0, < 5.0)
thor (~> 0.14)
jruby-jars (1.6.7.2)
jruby-openssl (0.7.7)
bouncy-castle-java (>= 1.5.0146.1)
jruby-pageant (1.1.1-java)
jruby-rack (1.1.7)
json (1.7.3-java)
Why am I still getting this error saying that open-ssl is missing?
This question is totally related to this one and my problem will be solved if I am able to execute jurby -S bundle here.
Update:
The error started after I ran bundle install --deployment.
So I ran bundle install --no-deployment then bundle install, jurby -S bundle..everything works fine. I'm not able to understand what is happening here.
Execute jruby -S gem install jruby-openssl before you run your bundle command.

Why is 'bundle update' installing ancient gems?

Everything was working just fine until, out of the blue, bundle update decided to 'update' to some very old versions of some gems. Any ideas? I'm baffled!
The Gemfile doesn't specify a version for the awry gems. eg.
gem 'rails'
I do...
bundle update
And(!)...
Using rails (0.9.5)
If I specify a version. eg.
gem 'rails', '~> 3.0'
Then it's ok.
Using rails (3.0.7)
Source 'http://rubygems.org'
Gem version 1.8.3, rvm version 1.6.14
Only some gems are wrong. mongoid is another. It's on 1.0.6. Thanks!
Problem solved. It was a gem conflict. I boiled it down to...
With just these two gems:
gem 'rails'
gem 'i18n'
You get i18n 0.6.0 (the latest) but rails is on 3.0.5 (3.0.7 is current latest).
And then with just these three:
gem 'rails'
gem 'i18n'
gem 'delayed_job'
You get:
Gems included by the bundle:
* actionmailer (0.6.1)
* actionpack (1.4.0)
* activerecord (1.6.0)
* activesupport (3.0.7)
* bundler (1.0.13)
* daemons (1.1.3)
* delayed_job (2.1.4)
* i18n (0.6.0)
* rails (0.9.5) <-- Yikes! that brings back memories!
* rake (0.9.0)
I've not looked deeper into how bundler's gem dependencies work yet, but that was what caused it. Interesting! And of course there's no need to include the i18n gem anyway, so removing that fixes things (or specifying gem versions).
Try this one.
Just update your bundler, May be of any-one of the older gem is conflicting with latest one, this type of issues arises.
'gem install bundler'
and then 'bundler install'
If you find again error, then delete GEM.lock file, then run bundler install. It may resolve the issue.

Resources