Rack Bug Installation issue. Server does not start - ruby-on-rails

I just installed the Rack-Bug and created the middleware file that it needs in the config folder. But I am unable to start my server.
Im using Rails 2.3.4 with Ruby 1.8.7.
/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:443:in `load_missing_constant': uninitialized constant IPAddr (NameError)
from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:80:in const_missing'
from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:92:inconst_missing'
from /home/xxxxx/xxxx/trunk/config/initializers/middleware.rb:6
I can't figure out what I am doing wrong. Any help would be great.

I had the same problem.
The solution is to put the following line at the top of your environment.rb (requirement of a ruby core class: http://ruby-doc.org/core/classes/IPAddr.html):
require 'ipaddr'

Related

Rails 6 - Phusion error for uninitialized constant URI::Generic

I'm using rails 6.0.3.4, ruby 2.5.0 with nginx/1.18.0 (Ubuntu). Everything was fine until I did a new deploy (using capistrano) and suddenly I'm getting Could not spawn process for application /home/deploy/appname/current: The application encountered the following error: uninitialized constant URI::Generic (NameError).
I have required these in application.rb (also tested requiring in the model) with no luck:
require 'uri'
require "uri/generic"
At this point, I'm not sure what could be wrong.
Thanks in advance if anyone has any suggestions.
It seemed it was a bug between Rails and Ruby, so I upgraded my Rails to the current stable version as well as upgraded my ruby version.

Rails 3.2 - Unable to load modules of initializers files

Environment
Ruby [1.9.3p547]
Rails [3.2.22.5]
Devise [3.0.4]
When i run any rails or rake command for this application it is giving me below error
/config/initializers/devise.rb:3:in <top (required)>': undefined
methodsetup' for Devise:Module (NoMethodError)
If i comment file devise.rb and run rails command again.
/config/initializers/doorkeeper.rb:1:in `':
uninitialized constant Doorkeeper (NameError)
And so on if i comment doorkeeper.rb file it is giving me error for
/config/initializers/kaminari_config.rb:1:in `':
uninitialized constant Kaminari (NameError)
i can't get what is issue with my application i am unable to perform any rake or rails. its directly giving me error of uninitialized constant .
The ruby and rails version is very old. I don't want to upgrade it. Earlier i though it was issue of devise gem. but it must not be issue of devise gem.
Please help me if any one has idea about this type of error.
Thanks in advance
I think you have some installation issues. Please try to install from scratch.
Follow these steps.
Find version of bundler from Gemfile.lock
Install bundler with that version and continue with bundle install
Check for API_KEY and values in your initializers.
Check for Gem support for your Ruby version (as it is too old)

Deploying Rails App, NameError: uninitialized constant Foundation::Rails::Generators

I'm trying to deploy my first Rails app to my test server. Using Ubuntu, Capistrano, Passenger, Apache. Rails 4.1.9, Ruby 2.0.0.
Everything seems to pull from Github to my production server okay, but rack returns: NameError: uninitialized constant Foundation::Rails::Generators when
try to run rake.
Sorry to be such a N00b but I haven't been able to find the problem.
Error generates from Bundler.require(*Rails.groups) in application.rb
Can anyone point me in the right direction?
Thanks.
Your deployment probably does not run bundle install to install the gems your app needs.
Try adding require 'bundler/capistrano' to the top of your deploy.rb to automatically install the gems in your Gemfile.
Capo.io is a good source when you want to get started with good capistrano recepies btw.

Running RSPEC in Ruby + Rails

I am trying to run rspec in my rails app using the spec command- but I get the following error:
`require': cannot load such file -- spec/rails/example/helper_example_group_helper (LoadError)
I have had to deal already with missing 'helper' files, but it seems this one is not even in my app but in rails itself..
If I go ahead and create a helper_example_group_helper.rb file, then the error will appear regarding some other missing helper file inside Rails, ad infinitum.
The full log trace: http://pastie.org/pastes/3295692/text
The full gem list: http://pastie.org/pastes/3296070/text
I am running:
Ruby 1.9.3-p0
Rails 2.3.14
rspec 1.2.9 (gem)
rspec-rails 1.2.9 (gem)
Any help would be greatly appreciated!
Thanks
An old question but it's an issue I hit recently while upgrading a rails app. This issue is specific to Rails 2.3.x and ruby 1.9.3. There's a google groups thread about it here:
https://groups.google.com/forum/#!msg/rubyonrails-core/gb5woRkmDlk/iQ2G7jjNWKkJ%5B1-25%5D
The workaround is to add a file to config/initializers with the following:
MissingSourceFile::REGEXPS.push([/^cannot load such file -- (.+)$/i, 1])

Rails 3 error: no such file to load -- initializer (LoadError)

I'm on Ubuntu and my app is written for Rails 2.3.5 and I got it to run on 2.3.10 but when I upgraded to Rails 3.0.3 and tried to run it using "ruby script/server", it throws this error.
/usr/local/lib/site_ruby/1.8/rubygems.rb:230:in `activate': can't activate rails (= 2.3.10, runtime) for [], already activated rails-3.0.3 for [] (Gem::LoadError)
from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:35:in `require'
from /home/bob/savage/config/boot.rb:55:in `load_initializer'
from /home/bob/savage/config/boot.rb:38:in `run'
from /home/bob/savage/config/boot.rb:11:in `boot!'
from /home/bob/savage/config/boot.rb:110
from script/server:2:in `require'
from script/server:2
When I uninstalled Rails 2.3.10, it throws this error instead
bob#ubuntu:~/test.2.3.10$ ruby script/server
/usr/local/lib/site_ruby/1.8/rubygems.rb:777:in `report_activate_error': RubyGem version error: rails(3.0.3 not = 2.3.10) (Gem::LoadError)
from /usr/local/lib/site_ruby/1.8/rubygems.rb:211:in `activate'
from /usr/local/lib/site_ruby/1.8/rubygems.rb:1056:in `gem'
from /home/bob/test.2.3.10/config/boot.rb:60:in `load_rails_gem'
from /home/bob/test.2.3.10/config/boot.rb:54:in `load_initializer'
from /home/bob/test.2.3.10/config/boot.rb:38:in `run'
from /home/bob/test.2.3.10/config/boot.rb:11:in `boot!'
from /home/bob/test.2.3.10/config/boot.rb:114
from script/server:2:in `require'
from script/server:2
Ideas? Thanks in advance for your help.
I was getting the same error until I realized that I was still using the same old config/boot.rb from the 2.3.10 version of my app. I went into a clean directory and generated a new Rails 3.0.3 app and used the boot.rb it created. The file is totally different, and it got me past this error.
I have the same problem.
After reading the comments above, I tried creating a new, empty application in another directory:
rails new foo
cd foo
rails s
WEBrick starts up just fine. Perhaps Bob can duplicate this? This rules out problems with Rails and Ruby versions (3.0.3, 187p302 respectively for me). And it really points to problems with running Rails 3 utilities in directories with old versions of boot.rb or environment.rb, and running Rails 2 script files (plugin, server) once 3.0.3 is the active version of Rails.
This is the default Rails 3.0.0 config/boot.rb file. I would use all or parts of this instead of your config/boot.rb
require 'rubygems'
# Set up gems listed in the Gemfile.
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
Noticed 1.8 in your path - I believe you'll need to be on 1.9.2 for Rails 3 to work. Use RVM to get this up and running right away.
Additionally - you typically start Rails 3 with 'rails server' or 'rails s' - you don't need to fire off script/server anymore. Give that a go and see how it works.

Resources