Rails Uninitalized Constant Error on Startup - ruby-on-rails

I have a local development machine which has started to give me the following error on starting up the Rails server:
C:/Software/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/i
nflector.rb:404: uninitialized constant ActiveSupport::CoreExtensions::String (N
ameError)
from C:/Software/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:
31:in `gem_original_require'
from C:/Software/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:
31:in `require'
No Rails specific updates have been made on this machine, only automatic Windows updates.
Anyone have a clue on this? I cannot upgrade to Rails 2.3.5.
Thanks!
Vikram
gem list gives:
actionmailer (2.3.5, 2.3.4, 2.3.2, 2.2.2, 2.1.0)
actionpack (2.3.5, 2.3.4, 2.3.2, 2.2.2, 2.1.0)
activerecord (2.3.4, 2.3.2, 2.2.2, 2.1.0)
activeresource (2.3.5, 2.3.4, 2.3.2, 2.2.2, 2.1.0)
activesupport (2.3.5, 2.3.4, 2.3.2, 2.2.2, 2.1.0)
bullet (1.7.1)
capistrano (2.5.5, 2.5.0)
cgi_multipart_eof_fix (2.5.0)
echoe (3.1.1)
facebooker (1.0.54)
gem_plugin (0.2.3)
highline (1.5.0, 1.4.0)
json (1.1.9)
json_pure (1.2.0)
memcache-client (1.7.4)
mime-types (1.16)
mislav-will_paginate (2.3.11, 2.3.8, 2.3.4)
mongrel (1.1.5)
mysql (2.7.3)
net-scp (1.0.2, 1.0.1)
net-sftp (2.0.2, 2.0.1)
net-ssh (2.0.11, 2.0.4)
net-ssh-gateway (1.0.1, 1.0.0)
parseexcel (0.5.2)
rack (1.1.0, 1.0.1, 1.0.0)
rails (2.3.4, 2.3.2, 2.2.2)
rake (0.8.7, 0.8.4, 0.8.2)
rmagick (2.6.0)
rubyforge (2.0.3, 1.0.3)
rubyzip (0.9.1)
spreadsheet-excel (0.3.5.1)

Are you trying to upgrade to rails 2.3.5? If so you may want to upgrade your ActiveRecord to 2.3.5 as well (as well as install the 2.3.5 rails gems).
If not, you may want to uninstall your 2.3.5 versions of actionmailer, actionpack, activerecord, activeresource, activesupport and see if that helps.

Just to let everyone know. The error was due to a power outage that caused the computer to shut down incorrectly, and which corrupted some of the files on the machine.
Uninstalling every Rails version and dependencies, and reinstalling them fixed the issue (although uninstalling just the version that was being used could also have done the trick).
Vikram

Related

Cross-thread violation on rb_gc()

The codebase I'm working on was recently upgraded from Ruby 1.9.2 to Ruby 1.9.3 and from Rails 3.1 to Rails 3.2.2. Since I'm using RVM I simply did rvm install 1.9.3 which I would have expected to be all that was necessary.
When I run
rails s
I get the error
[BUG] cross-thread violation on rb_gc()
I've found a number of links relating to this problem. There is one on StackOverflow, but it doesn't really give an answer. The most promising answer is on the RVM site:
In every case of this I have seen thus far it has always ended up
being that a ruby gem/library with C extensions was compiled against a
different ruby and/or architecture than the one that is trying to load
it. Try uninstalling & reinstalling gems with C extensions that your
application uses to hunt this buggar down.
That's fairly helpful, but my Ruby-fu is not strong enough to know which gems have C extensions and which ones I should try to re-install. Quite a few of the other links on the topic seem to suggest that the json gem is at fault, so I tried following the suggested solution.
gem uninstall json
gem install --platform=ruby
This didn't really change anything for me—I still get the exact same error when trying to start the Rails environment.
How do I track down this problem?
If it helps, here is the output from gem list:
actionmailer (3.2.2)
actionpack (3.2.2)
activemodel (3.2.2)
activerecord (3.2.2)
activeresource (3.2.2)
activesupport (3.2.2)
addressable (2.2.7)
akami (1.0.0)
arel (3.0.2)
bcrypt-ruby (3.0.1)
bson (1.6.1)
bson_ext (1.6.1)
builder (3.0.0)
bundler (1.1.3, 1.0.21)
capybara (1.1.2)
carmen (0.2.13)
childprocess (0.3.1)
ci_reporter (1.7.0)
coderay (1.0.5)
coffee-rails (3.2.2)
coffee-script (2.2.0)
coffee-script-source (1.2.0)
commonjs (0.2.5)
cucumber (1.1.9)
cucumber-rails (1.3.0)
database_cleaner (0.7.2)
devise (2.0.4)
diff-lcs (1.1.3)
ejs (1.0.0)
email_spec (1.2.1)
engineyard (1.4.28)
engineyard-serverside-adapter (1.6.3)
erubis (2.7.0)
escape (0.0.4)
execjs (1.3.0)
factory_girl (3.0.0)
factory_girl_rails (3.0.0)
faker (1.0.1)
fakeweb (1.3.0)
ffi (1.0.11)
gherkin (2.9.3)
gyoku (0.4.4)
haml (3.1.4)
haml-rails (0.3.4)
hash-deep-merge (0.1.1)
highline (1.6.11)
hike (1.2.1)
httpi (0.9.6)
i18n (0.6.0)
jasmine (1.1.2)
jasmine-core (1.1.0)
jasminerice (0.0.8)
journey (1.0.3)
jquery-rails (2.0.1)
json (1.6.6)
json_pure (1.6.6)
kaminari (0.13.0)
kgio (2.7.4)
launchy (2.0.5)
less (2.1.0)
less-rails (2.2.0)
libv8 (3.3.10.4 x86_64-darwin-11)
log4r (1.1.10)
mail (2.4.4)
metaclass (0.0.1)
method_source (0.7.1)
mime-types (1.18)
mocha (0.10.5)
mongo (1.6.1)
mongoid (2.4.7)
mongoid-rspec (1.4.4)
multi_json (1.2.0)
net-ssh (2.2.2)
newrelic_rpm (3.3.3)
nokogiri (1.5.2)
nori (1.1.0)
open4 (1.3.0)
orm_adapter (0.0.7)
polyglot (0.3.3)
pr_geohash (1.0.0)
pry (0.9.8.4)
pry-highlight (0.0.1)
pry_debug (0.0.1)
rack (1.4.1)
rack-cache (1.2)
rack-ssl (1.3.2)
rack-test (0.6.1)
rails (3.2.2)
rails-footnotes (3.7.6)
railties (3.2.2)
raindrops (0.8.0)
rake (0.9.2.2)
rdoc (3.12)
recursive-open-struct (0.2.1)
rest-client (1.6.7)
rpm_contrib (2.1.8)
rsolr (1.0.7)
rspec (2.9.0)
rspec-core (2.9.0)
rspec-expectations (2.9.0)
rspec-mocks (2.9.0)
rspec-rails (2.9.0)
rubyzip (0.9.6.1)
sass (3.1.15)
sass-rails (3.2.5)
savon (0.9.9)
selenium-webdriver (2.20.0)
settings-tree (0.2.1)
simplecov (0.6.1)
simplecov-html (0.5.3)
simplecov-rcov (0.2.3)
slop (2.4.4)
spine-rails (0.1.0)
spork (1.0.0rc2)
sprockets (2.1.2)
sunspot (1.3.1)
sunspot_mongoid (0.4.1)
sunspot_rails (1.3.1)
sunspot_solr (1.3.1)
term-ansicolor (1.0.7)
therubyracer (0.10.1)
thor (0.14.6)
tilt (1.3.3)
treetop (1.4.10)
twitter-bootstrap-rails (2.0.6)
tzinfo (0.3.32)
uglifier (1.2.4)
unicorn (4.2.1)
warden (1.1.1)
wasabi (2.1.0)
xpath (0.1.4)
Here are various approaches you can try.
cleanup
To clean up old versions of your gems:
gem cleanup --dryrun
json
To temporarily see if the json gem is the issue, switch from json (native) to json (pure ruby) and change your Gemfile:
gem install json_pure
native gems
Your gem list has a few that pop out for me as native:
bcrypt
bson
erubis
ffi (enables lots of native connections)
gherkin
kgio
less
nokogiri
raindrops
therubyracer (many unpredictable issues IMHO)
unicorn
ffi
Your gem ffi is especially interesting -- do you happen to know what you're doing with it?
The ffi enables Ruby code to call native code, for example if some part of your Ruby app needs to connect to native libraries.
When you're diagnosing your issue, I'd look at this gem first.
makefiles
To find any of your gems that have Makefile files, which is a good indicator that they have native code:
find / | grep "/ruby/gems/" | grep Makefile
To find all your gems so you can delete them:
find / | grep "/ruby/gems/"
nuke RVM
To nuke RVM or its pieces, you can use rvm uninstall, rvm implode, or this script which nukes RVM and finds any lingering pieces:
https://raw.github.com/SixArm/sixarm_unix_shell_scripts/master/rvm-uninstall-danger
try rbenv + bundler
I changed from using rvm to using rbenv + bundler and it's working great for me.
The rbenv tool is a direct competitor to rvm for managing Ruby versions:
https://github.com/sstephenson/rbenv
Bundler is a great way to manage gemsets and gem dependencies:
http://gembundler.com/
brew
If you're on a Mac and using MacPorts, to change to Homebrew:
Link
Uninstall all verions of json gems by running:
gem uninstall json
Then run:
gem install json --platform=ruby
Run bundle again:bundle install
You should try nuking all of your gems and reinstall them for your app using the bundle command.
Quoting the RVM documentation for this error:
Try uninstalling & reinstalling gems with C extensions that your application uses to hunt this buggar down.
The command to remove gems with RVM is simply:
rvm uninstall
A clean reinstall of RVM latest is the best option.
rvm implode
rm -rf ~/.rvm
curl -L get.rvm.io | bash -s stable
Before going the clean ruby/rvm install route you should check if you have removed ruby 1.8.7 (which is installed by default on most distributions). I believe this was interfering with some of my gems compiled with 1.9.2 (I think it was one of the native ones). I removed 1.8.7 completely using apt-get then I made a new rvm profile (by changing the profile name in .rvmrc) and then ran bundle install to refresh all the gems completely.

RubyGem version error: rails(1.2.3 not >= 3.0)

I'm maintaining an ancient RoR site that we're in the process of rewriting in Django. The site was written by someone else when Rails was in its infancy, and no one kept it updated until I got to it. A night or two ago, the server went down, I suspect due to a MySQL update. In the process of trying to fix it, we broke it, and now mongrel won't start. I see this in the mongrel log:
/home/USER/rails/SITE/config/boot.rb:26:Warning: Gem::SourcUSERdex#search support for String patterns is deprecated, use #find_name
/usr/local/lib/site_ruby/1.8/rubygems.rb:812:in `report_activate_error': RubyGem version error: rails(1.2.3 not >= 3.0) (Gem::LoadError)
from /usr/local/lib/site_ruby/1.8/rubygems.rb:223:in `activate'
from /usr/local/lib/site_ruby/1.8/rubygems.rb:258:in `activate'
from /usr/local/lib/site_ruby/1.8/rubygems.rb:257:in `each'
from /usr/local/lib/site_ruby/1.8/rubygems.rb:257:in `activate'
from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:33:in `require'
from /home/USER/rails/SITE/config/environment.rb:24
from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:29:in `gem_original_require'
from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:29:in `require'
from /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/rails.rb:147:in `rails'
from /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:113:in `cloaker_'
from /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/configurator.rb:149:in `call'
from /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/configurator.rb:149:in `listener'
from /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:99:in `cloaker_'
from /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/configurator.rb:50:in `call'
from /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/configurator.rb:50:in `initialize'
from /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:84:in `new'
from /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:84:in `run'
from /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/command.rb:212:in `run'
from /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:281
from /usr/local/bin/mongrel_rails:19:in `load'
from /usr/local/bin/mongrel_rails:19
I searched around and have tried to diagnose the error. It looks like mongrel wants us to have rails 3+ which isn't possible because we're going to be replacing the site in just a few weeks and don't want to bother bringing it up to date (it just needs to work for now). How can I force mongrel to run with the current version of rails?
In config/environment.rb, we have RAILS_GEM_VERSION = '1.2.3' unless defined? RAILS_GEM_VERSION which I thought would force Rails 1.2.3. Also, here's the output of gem list:
*** LOCAL GEMS ***
abstract (1.0.0)
actionmailer (3.2.2, 3.0.3, 1.3.3)
actionpack (3.2.2, 3.0.3, 1.13.6, 1.13.3)
actionwebservice (1.2.6, 1.2.3)
activemodel (3.2.2, 3.0.3)
activerecord (3.2.2, 3.0.3, 1.15.6, 1.15.3)
activeresource (3.2.2, 3.0.3)
activesupport (3.2.2, 3.0.3, 1.4.4, 1.4.2)
acts_as_ferret (0.5.3, 0.4.3)
arel (3.0.2, 2.0.7)
builder (3.0.0, 2.1.2)
bundler (1.1.0, 1.0.9)
cgi_multipart_eof_fix (2.5.0)
daemons (1.1.8, 1.1.0)
erubis (2.7.0, 2.6.6)
fastthread (1.0.7)
ferret (0.11.6)
gem_plugin (0.2.3)
hike (1.2.1)
i18n (0.6.0, 0.5.0)
jk-ferret (0.11.8.3, 0.11.8.2)
journey (1.0.3)
json (1.6.5)
mail (2.4.3, 2.2.15)
mime-types (1.17.2, 1.16)
mongrel (1.1.5)
multi_json (1.1.0)
polyglot (0.3.3, 0.3.1)
rack (1.4.1, 1.2.1)
rack-cache (1.2)
rack-mount (0.8.3, 0.6.13)
rack-ssl (1.3.2)
rack-test (0.6.1, 0.5.7)
rails (1.2.3)
railties (3.2.2, 3.0.3)
rake (0.9.2.2, 0.8.7)
rdoc (3.12)
sprockets (2.1.2)
thor (0.14.6)
tilt (1.3.3)
treetop (1.4.10, 1.4.9)
tzinfo (0.3.32, 0.3.24)
Thanks for any and all help!
OK, I figured it out. It was incompatible gem(s). Luckily, we have a test server and a production server. We only messed with the test server last night (mongrel on the production server was working), so I did gem list on both servers, and it turned out the test server had quite a different list. I just installed and uninstalled gems on the test server until gem list produced identical lists on both servers.
Mongrel does require the latest rails version available, but your apps require rails 1.2.3, so there is a conflict.
The easiest way to avoid gems conflicts is by using different gemsets (with rvm or rbenv). Or remove the rails 3 gem if it isn't used...

Ruby on rails passenger apache problem

I did, gem install passenger, passenger-install-apache2-module
http://localhost/
I'm getting this error.
http://pastebin.com/YfrEsv3X
Update
*** LOCAL GEMS ***
abstract (1.0.0)
actionmailer (3.0.8)
actionpack (3.0.8)
activemodel (3.0.8)
activerecord (3.0.8)
activeresource (3.0.8)
activesupport (3.0.8)
arel (2.1.1, 2.0.10)
bcrypt-ruby (2.1.4)
builder (3.0.0, 2.1.2)
bundle (0.0.1)
bundler (1.0.15)
daemon_controller (0.2.6)
devise (1.3.4)
erubis (2.7.0, 2.6.6)
fastthread (1.0.7)
i18n (0.6.0, 0.5.0)
mail (2.3.0, 2.2.19)
mime-types (1.16)
mysql (2.8.1)
mysql2 (0.3.2)
orm_adapter (0.0.5)
passenger (3.0.7)
pg (0.11.0)
polyglot (0.3.1)
postgres-pr (0.6.3)
rack (1.3.0, 1.2.3)
rack-mount (0.8.1, 0.6.14)
rack-test (0.6.0, 0.5.7)
rails (3.0.8)
railties (3.0.8)
rake (0.9.2, 0.8.7)
rubygems-update (1.8.5)
thor (0.14.6)
treetop (1.4.9)
tzinfo (0.3.27)
warden (1.0.4)
You need to install the bundler gem as well.
Update
Now that the OP has posted his gemset...
You must have two gemsets, usually this is because you're using two different rubys. The gem command is just a script, with a shebang line pointing to a Ruby. The gem list you're showing will be the gemset for that Ruby. You can see this with this command: head -1 $(which gem)
Your passenger configuration must be pointing to a different Ruby with a different gemset. You can see this in your passenger.conf lines for Apache.
I suspect after installing the bundler gem - you may experience other problems if your Gemfile doesn't include all the gems your project requires.
So next time - look at the error message.
no such file to load -- bundler
from the above example - you can notice that 'bundler' is causing the problem.
That will give you a clue as what other gems you'd need to install and possibly missed out in your Gemfile - in which case issue the command:
gem install <missing-gem>

Kindly suggest appropriate Attachment plugin/gem for use with Rails 2.0.2 and Ruby 1.8.7

I am trying to attach files in my RoR app. I am using Rails 2.0.2 and Ruby 1.8.7 for project specific purposes. I am using Ubuntu 10.04 OS.
I have tried out two plugins(paperclip and attachment_fu) but I have no luck so far in getting things working with them. I am basically facing compatibility issues as the configuration I am using is pretty much not used these days.
Kindly have a look at these URL'S in order to better understand the issues that I am currently facing:-
Undefined method `has_attached_file' with paperclip 2.3.8 gem for Rails 2 using Ruby 1.8.7
https://stackoverflow.com/questions/6000588/issues-with-attachment-fu-plugin-in-rails-2
It would be great if you can help me with your insights on these issues.
Also, can you kindly suggest plugins or gems which I can make use of to attach files in my rails app based on the above configuration.
[EDITED QUESTION]
I also would like to add I tried out paperclip 2.1.2 gem but it doesn't seem to get detected through IRB. I don't know how much of a difference this information will make, but I would like to add that I am also making use of RVM and having another ruby 1.9.2 with me.
although paperclip gem is installed and shows up in my ruby gems list , I wonder why I get a null( '[]' ) when I do a require 'paperclip' through IRB.
mohnish#mohnish-desktop:~/UP/pocs_tried_for_use/post_with_image$ gem list
*** LOCAL GEMS ***
aasm (2.2.0, 2.1.1)
action_profiler (1.0.0)
actionmailer (2.3.5, 2.0.2)
actionpack (2.3.5, 2.0.2)
activerecord (2.3.5, 2.0.2)
activeresource (2.3.5, 2.0.2)
activesupport (3.0.0, 2.3.5, 2.0.2)
acts_as_reportable (1.1.1)
aws-s3 (0.6.2)
builder (2.1.2)
cgi_multipart_eof_fix (2.5.0)
color (1.4.1)
contacts (1.2.4)
daemons (1.1.0)
fastercsv (1.5.3)
fastthread (1.0.7)
ferret (0.11.6)
gdata (1.1.1)
gem_plugin (0.2.3)
gettext (2.1.0)
hoe (2.6.2)
hpricot (0.8.3, 0.8.2)
httpclient (2.1.5.2)
image_science (1.2.1)
json (1.4.6)
json_pure (1.4.6)
locale (2.0.5)
log4r (1.1.8)
macaddr (1.0.0)
mechanize (1.0.0)
memcache-client (1.8.5)
mime-types (1.16)
mocha (0.9.8)
mongrel (1.1.5)
mysql (2.8.1)
nokogiri (1.4.3.1)
paperclip (2.1.2)
passenger (2.2.4)
pdf-writer (1.1.8)
prawn (0.8.4)
prawn-core (0.8.4)
prawn-layout (0.8.4)
prawn-security (0.8.4)
rack (1.0.1)
railroad (0.5.0)
rails (2.0.2)
rake (0.8.7)
RedCloth (3.0.3)
rfacebook (0.9.8, 0.9.0)
rmagick (2.9.1)
ruby-activeldap (0.8.3.1)
ruby-net-ldap (0.0.4)
ruby-openid (2.1.8, 2.0.2)
rubyforge (2.0.4)
rubygems-update (1.3.7)
ruport (1.6.3)
scrubyt (0.4.06)
tinyurl (1.0.0)
transaction-simple (1.4.0)
uuid (2.3.1)
xml-simple (1.0.12)
mohnish#mohnish-desktop:~/pocs_tried_for_use/post_with_image$ ruby script/console
Loading development environment (Rails 2.0.2)
ruby-1.8.7-p334 :001 > require 'paperclip'
=> []
ruby-1.8.7-p334 :002 >
Your suggestions would be really helpful,
Thank you..
If you're using a significantly older version of Rails you may be exposing yourself to serious security vulnerabilities, so if you can upgrade, you really should, even if it's just to another point release in the 2.0.x series.
That being said, you could always install a version of paperclip that's from that era. Newer versions only support 2.3 or better as far as I know.
Any project that's hosted on github will have a full version history so you can rewind the project to a particular revision that works for you. The git bisect tool is great for handling this sort of thing.

Ruby on Rail gem install activerecord-sqlserver-adapter error

I'm trying to run rake commands on my local SQL server database using ODBC. I have setup the ODBC connections and thought I had the rails end covered however, i'm running into this error.
Please install the sqlserver adapter: gem install activerecord-sqlserver-adapter (no such file to load -- active_record/connection_adapters/sqlserver_adapter)
I have the following gems installed:
abstract (1.0.0)
actionmailer (3.0.5)
actionpack (3.0.5)
activemodel (3.0.5)
activerecord (3.0.5, 1.15.6)
activerecord-sqlserver-adapter (3.0.10)
activeresource (3.0.5)
activesupport (3.0.5, 1.4.4)
arel (2.0.9)
builder (3.0.0, 2.1.2)
bundler (1.0.10)
dbd-odbc (0.2.4)
dbi (0.4.1)
deprecated (3.0.0, 2.0.1)
erubis (2.6.6)
i18n (0.5.0)
mail (2.2.15)
mime-types (1.16)
minitest (2.0.2, 1.6.0)
odbc-rails (1.5)
polyglot (0.3.1)
rack (1.2.2)
rack-mount (0.7.1, 0.6.14)
rack-test (0.5.7)
rails (3.0.5)
railties (3.0.5)
rake (0.8.7)
rdoc (3.5.3, 2.5.8)
thor (0.14.6)
treetop (1.4.9)
tzinfo (0.3.25)
Am I missing a gem? What else do I need to get this running on my windows box?
Thanks in advance for any help :-)
Try to add such line in your %APP_ROOT%/Gemfile
gem 'activerecord-sqlserver-adapter'
Also, your way behind on the times. First the DBI/DBD-ODBC were removed from the adapter stack about a year ago. Also, the easiest way (and best performance) is to use TinyTDS for the connection mode. See there wiki here.
https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/wiki/Using-TinyTds

Resources