i have the code belowin the environment.rb and i keep getting the error uninitialized constant YAML::ENGINE (NameError) when i try to run it.
environment.rb
require 'yaml'
YAML::ENGINE.yamler= 'syck'
# Load the rails application
require File.expand_path('../application', __FILE__)
# Initialize the rails application
Quora::Application.initialize!
anybody have an idea?
YAML::ENGINE doesn't exist in Ruby 1.8.7. This is defined in Ruby 1.9. I tried running irb on 1.8.7 and 1.9.2. Strange though, both of their YAML version number is the same (0.6.0).
Also, I think Ruby 1.8.7's YAML already uses SYCK for yaml parsing. :)
Related
When I run rails c I get an error:
/usr/lib/ruby/vendor_ruby/active_support/test_case.rb:12:in `<module:ActiveSupport>': uninitialized constant Test::Unit::TestCase (NameError)
Please help me to fix this error.
Add require 'test/unit'
at the beginning of
/usr/lib/ruby/vendor_ruby/active_support/test_case.rb
I am getting this error uninitialized constant YAML::ENGINE error when i run rake db:migrate . I have the ruby version ruby 1.9.3p327 and rails version Rails 3.0.20, my gems version is 1.8.25. can anyone please help that whats wrong.
this is how my config/boot.rb file looks like
require 'yaml'
YAML::ENGINE.yamler= 'syck'
on this second line I am getting this error.
I'm trying to use the Rails site map_generator gem to generate site maps for a 8,000,00 page site. The gem can be found here: https://github.com/kjvarga/sitemap_generator
Here is my code in sitemap.rb:
require 'rubygems'
require 'sitemap_generator'
# Set the host name for URL creation
SitemapGenerator::Sitemap.default_host = "http://www.mysite.com"
SitemapGenerator::Sitemap.create do
add '/content.aspx?page=privacypolicy'
Product.find_each do |product|
add product_path(ppid), :lastmod => content.updated_at
end
end
However, when I run
>> ruby sitemap.rb
I get an error that says:
sitemap.rb:9:in `block in ': uninitialized constant
SitemapGenerator::Interpreter::Product (NameError)
However "Product" is the correct name of my model. Why is this happening?
I'm running Rails 3.1.2 and Ruby 1.9.
I'm the author of the gem. Better to open an issue on the GitHub page in future. SitemapGenerator does work in Rails 3 and Ruby 1.9.*. If you are running Rails, you don't need these lines:
require 'rubygems'
require 'sitemap_generator'
Also you generate your sitemaps by running Rake:
rake sitemap:refresh:no_ping
What is happening in your case is that because you're not running through Rake, the script does not know about the Product class, since your Rails environment hasn't been loaded.
Well, I wasn't able to get this gem working. My guess is that it doesn't work on Rails 3.1.2 or with Ruby 1.9. However, I was able to get another gem (big_sitemap) to work. Here is the link to it.
https://github.com/alexrabarts/big_sitemap
I have an app build on 1.8.7 and I'm trying to start it on a system with 1.9.3
When I run script/server, I'm getting:
/usr/local/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- test/unit/error (LoadError)
from /usr/local/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
My server script looks like this:
#!/usr/bin/env ruby
require File.expand_path('../../config/boot', __FILE__)
require 'commands/server
What am I missing?
Thanks
Thomas
You don't add the origin path of your test. Add in your script to improve the LOAD_PATH
#!/usr/bin/env ruby
$: << File.dirname(__FILE__) + '../..'
require File.expand_path('../../config/boot', __FILE__)
require 'commands/server
In my case, this error was due to I was trying to run a Rails 2.1.1 application with Ruby 2.0.0. I solved it by changing to Ruby 1.8.6, which was the one supported by Rails 2.1.1.
If you want to upgrade your Ruby version, you'll probably need to upgrade your Rails application as well. (Check this post for info about Ruby-Rails compatibility.)
I solved by removing the ../ path in the file /var/www/redmine-2.6.0/config/boot.rb
# Before
require File.expand_path('../../config/boot', __FILE__)
# After
require File.expand_path('../config/boot', __FILE__)
I hope it helps.
Marcos Rogerio
I have an application using Rails 2.3.4 which I'm trying to run. No matter how I start it, by using script/console or script/ferret_server, it always boils down to the same error:
uninitialized constant Gem
When I search online, I only find people who has a similar problem finding something inside of the Gem class. But in my case, Gem is just not there at all.
I am running Ruby on Ubuntu. I tried using the version of Ruby that came with APT and a more recent one with RVM. Nothing helped.
Any idea how what can be causing thing and how to fix it? Thanks in advance!
Some extra details, as requested by commenters:
Output of ruby -v:
ruby 1.8.7 (2011-02-18 patchlevel 334) [x86_64-linux], MBARI 0x6770, Ruby Enterprise Edition 2011.03
Output of gem -v:
1.8.6
Calling ruby script/console outputs a similar error (edited):
Loading development environment (Rails 2.3.4)
/var/www/sites/example.com/releases/20110726061310/config/environment.rb:12:NameError: uninitialized constant Gem
/usr/local/rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/irb/init.rb:254:in `require': no such file to load -- console_app (LoadError)
from /usr/local/rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/irb/init.rb:254:in `load_modules'
from /usr/local/rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/irb/init.rb:252:in `each'
from /usr/local/rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/irb/init.rb:252:in `load_modules'
from /usr/local/rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/irb/init.rb:21:in `setup'
from /usr/local/rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/irb.rb:54:in `start'
from /usr/local/rvm/rubies/ree-1.8.7-2011.03/bin/irb:17
I'm trying to call Ferret Server to allow Passenger to connect to it, with the command:
ruby --debug script/ferret_server -e production start
Outputs the following error:
Exception `NameError' at ./script/../vendor/plugins/acts_as_ferret/lib/../../../../config/environment.rb:12 - uninitialized constant Gem
uninitialized constant Gem
Alternatively, calling bundle exec ruby --debug script/ferret_server -e production start outputs the following error:
superclass mismatch for class GemDependency
Please note that I added the following right above the Rails::Initializer.run do |config| line in config/environment.rb:
require 'thread'
if Gem::VERSION >= "1.3.6"
module Rails
class GemDependency
def requirement
r = super
(r == Gem::Requirement.default) ? nil : r
end
end
end
end
require File.join(File.dirname(__FILE__), 'boot')
Remove the lines mentioned above gives uninitialized constant Rails errors instead.
Try putting:
require 'rubygems'
Just after require 'thread'