I'm setting up Log4r using an XML configuration file, and I can't get the EmailOutputter to work correctly. Here's my outputter tag:
<outputter type="EmailOutputter" name="exception_email" trunc="false" level="ERROR" buffsize="10">
<formatter type="PatternFormatter" pattern="#{pattern}"/>
<server>#{smtp_address}</server>
<port>#{smtp_port}</port>
<domain>#{smtp_domain}</domain>
<from>logging##{smtp_domain}</from>
<to>exceptions#mydomain.com</to>
<subject>Log Report</subject>
<immediate_at>ERROR, FATAL</immediate_at>
</outputter>
I've triple and quadruple checked that all the XML variables are being passed in correctly using the RubyMine step-through debugger. The exception message is:
Uncaught exception: Problem creating outputter: uninitialized constant Log4r::Configurator::EmailOutputter
/usr/local/lib/ruby/gems/1.9.1/gems/log4r-1.1.10/lib/log4r/configurator.rb:87:in block in decode_xml'
/usr/local/lib/ruby/1.9.1/rexml/element.rb:905:inblock in each'
/usr/local/lib/ruby/1.9.1/rexml/xpath.rb:67:in each'
/usr/local/lib/ruby/1.9.1/rexml/xpath.rb:67:ineach'
/usr/local/lib/ruby/1.9.1/rexml/element.rb:905:in each'
/usr/local/lib/ruby/gems/1.9.1/gems/log4r-1.1.10/lib/log4r/configurator.rb:87:indecode_xml'
/usr/local/lib/ruby/gems/1.9.1/gems/log4r-1.1.10/lib/log4r/configurator.rb:82:in actual_load'
/usr/local/lib/ruby/gems/1.9.1/gems/log4r-1.1.10/lib/log4r/configurator.rb:56:inload_xml_file'
/root/src/upside/common/upside_logger.rb:16:in initialize'
/root/src/upside/common/logger_factory.rb:7:innew'
/root/src/upside/common/logger_factory.rb:7:in new_logger'
/root/src/upside/config/application.rb:30:inblock in '
/usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.2.11/lib/active_support/lazy_load_hooks.rb:34:in call'
/usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.2.11/lib/active_support/lazy_load_hooks.rb:34:inexecute_hook'
/usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.2.11/lib/active_support/lazy_load_hooks.rb:26:in block in on_load'
/usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.2.11/lib/active_support/lazy_load_hooks.rb:25:ineach'
/usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.2.11/lib/active_support/lazy_load_hooks.rb:25:in on_load'
/usr/local/lib/ruby/gems/1.9.1/gems/railties-3.2.11/lib/rails/railtie/configuration.rb:43:inbefore_configuration'
/root/src/upside/config/application.rb:29:in <class:Application>'
/root/src/upside/config/application.rb:15:in'
/root/src/upside/config/application.rb:14:in <top (required)>'
/usr/local/lib/ruby/gems/1.9.1/gems/railties-3.2.11/lib/rails/commands.rb:53:inrequire'
/usr/local/lib/ruby/gems/1.9.1/gems/railties-3.2.11/lib/rails/commands.rb:53:in block in <top (required)>'
/usr/local/lib/ruby/gems/1.9.1/gems/railties-3.2.11/lib/rails/commands.rb:50:intap'
/usr/local/lib/ruby/gems/1.9.1/gems/railties-3.2.11/lib/rails/commands.rb:50:in <top (required)>'
/root/src/upside/script/rails:6:inrequire'
/root/src/upside/script/rails:6:in `'
I've double checked the gem installation and the emailoutputter.rb is in the correct directory with the other outputters (which function correctly).
Thanks!
I found that the log4r file lib/log4r.rb to be missing the line require "log4r/outputter/emailoutputter". Adding this missing require to my Rails application in a config/initializer file allowed the EmailOutputter class available.
Related
Whenever I run rake assets:precompile RAILS_ENV=production in my command line, I get this error which prevents me from precompiling my assets.
Below is the complete error displayed in the command line:
rake aborted!
Uglifier::Error: Unexpected token: operator (<)
/usr/local/rvm/gems/ruby-2.3.4/gems/uglifier-4.1.4/lib/uglifier.rb:234:in parse_result'
/usr/local/rvm/gems/ruby-2.3.4/gems/uglifier-4.1.4/lib/uglifier.rb:216:in run_uglifyjs'
/usr/local/rvm/gems/ruby-2.3.4/gems/uglifier-4.1.4/lib/uglifier.rb:168:in compile'
/usr/local/rvm/gems/ruby-2.3.4/gems/sprockets-3.7.1/lib/sprockets/compressing.rb:65:in block in js_compressor='
/usr/local/rvm/gems/ruby-2.3.4/gems/sprockets-3.7.1/lib/sprockets/legacy_proc_processor.rb:31:in call'
/usr/local/rvm/gems/ruby-2.3.4/gems/sprockets-3.7.1/lib/sprockets/processor_utils.rb:75:in call_processor'
/usr/local/rvm/gems/ruby-2.3.4/gems/sprockets-3.7.1/lib/sprockets/processor_utils.rb:57:in block in call_processors'
/usr/local/rvm/gems/ruby-2.3.4/gems/sprockets-3.7.1/lib/sprockets/processor_utils.rb:56:in reverse_each'
/usr/local/rvm/gems/ruby-2.3.4/gems/sprockets-3.7.1/lib/sprockets/processor_utils.rb:56:in call_processors'
/usr/local/rvm/gems/ruby-2.3.4/gems/sprockets-3.7.1/lib/sprockets/loader.rb:134:in load_from_unloaded'
/usr/local/rvm/gems/ruby-2.3.4/gems/sprockets-3.7.1/lib/sprockets/loader.rb:60:in block in load'
/usr/local/rvm/gems/ruby-2.3.4/gems/sprockets-3.7.1/lib/sprockets/loader.rb:317:in fetch_asset_from_dependency_cache'
/usr/local/rvm/gems/ruby-2.3.4/gems/sprockets-3.7.1/lib/sprockets/loader.rb:44:in load'
/usr/local/rvm/gems/ruby-2.3.4/gems/sprockets-3.7.1/lib/sprockets/cached_environment.rb:20:in block in initialize'
/usr/local/rvm/gems/ruby-2.3.4/gems/sprockets-3.7.1/lib/sprockets/cached_environment.rb:47:in load'
/usr/local/rvm/gems/ruby-2.3.4/gems/sprockets-3.7.1/lib/sprockets/base.rb:66:in find_asset'
/usr/local/rvm/gems/ruby-2.3.4/gems/sprockets-3.7.1/lib/sprockets/base.rb:73:in find_all_linked_assets'
/usr/local/rvm/gems/ruby-2.3.4/gems/sprockets-3.7.1/lib/sprockets/manifest.rb:142:in block in find'
/usr/local/rvm/gems/ruby-2.3.4/gems/sprockets-3.7.1/lib/sprockets/legacy.rb:114:in block (2 levels) in logical_paths'
/usr/local/rvm/gems/ruby-2.3.4/gems/sprockets-3.7.1/lib/sprockets/path_utils.rb:228:in block in stat_tree'
/usr/local/rvm/gems/ruby-2.3.4/gems/sprockets-3.7.1/lib/sprockets/path_utils.rb:212:in block in stat_directory'
/usr/local/rvm/gems/ruby-2.3.4/gems/sprockets-3.7.1/lib/sprockets/path_utils.rb:209:in each'
/usr/local/rvm/gems/ruby-2.3.4/gems/sprockets-3.7.1/lib/sprockets/path_utils.rb:209:in stat_directory'
/usr/local/rvm/gems/ruby-2.3.4/gems/sprockets-3.7.1/lib/sprockets/path_utils.rb:227:in stat_tree'
/usr/local/rvm/gems/ruby-2.3.4/gems/sprockets-3.7.1/lib/sprockets/legacy.rb:105:in each'
/usr/local/rvm/gems/ruby-2.3.4/gems/sprockets-3.7.1/lib/sprockets/legacy.rb:105:in block in logical_paths'
/usr/local/rvm/gems/ruby-2.3.4/gems/sprockets-3.7.1/lib/sprockets/legacy.rb:104:in each'
/usr/local/rvm/gems/ruby-2.3.4/gems/sprockets-3.7.1/lib/sprockets/legacy.rb:104:in logical_paths'
/usr/local/rvm/gems/ruby-2.3.4/gems/sprockets-3.7.1/lib/sprockets/manifest.rb:140:in find'
/usr/local/rvm/gems/ruby-2.3.4/gems/sprockets-3.7.1/lib/sprockets/manifest.rb:185:in compile'
/usr/local/rvm/gems/ruby-2.3.4/gems/sprockets-rails-3.2.1/lib/sprockets/rails/task.rb:68:in block (3 levels) in define'
/usr/local/rvm/gems/ruby-2.3.4/gems/sprockets-3.7.1/lib/rake/sprocketstask.rb:147:in with_logger'
/usr/local/rvm/gems/ruby-2.3.4/gems/sprockets-rails-3.2.1/lib/sprockets/rails/task.rb:67:in block (2 levels) in define'
/usr/local/rvm/gems/ruby-2.3.4/gems/rake-12.3.0/exe/rake:27:in <top (required)>'
/usr/local/rvm/gems/ruby-2.3.4/bin/ruby_executable_hooks:15:in eval'
/usr/local/rvm/gems/ruby-2.3.4/bin/ruby_executable_hooks:15:in <main>'
Tasks: TOP => assets:precompile
(See full trace by running task with --trace)
What exactly do I need to do to fix this error?
I encountered the same error. Interestingly, it was triggered by the direct_upload.js file that Rails itself recommends for ActiveStorage! I found the solution here: https://github.com/lautis/uglifier/issues/127
Try replacing
config.assets.js_compressor = :uglifier
with
config.assets.js_compressor = Uglifier.new(harmony: true)
in config/environments/production.rb
You can always check the JS files by parsing it with the uglifier compiler.
Open your rails console
const JS_FOLDER = [file1_path, file2_path];
JS_FOLDER.each do. |file_name|
puts "#{file_name}"
puts Uglifier.compile(File.read(file_name))
end
And there you will have your corrupted file.
The trace is indicating that you have a syntax error in one of your JavaScript files. If you look in your browser's console, it might tell you where the error is.
If not, I'd suggest removing JS files until you find the culprit, and then commenting out lines in the offending file until you find the error. A binary search method might be helpful; start by removing roughly half your JS files and then trying the precompilation. If the error still occurs, then remove half of what's left and retry. When the error stops occurring, then you know which group of files contains the offending file, so you can back up one step, remove everything but that group, and try recompiling again. Eventually you should figure out which file contains the error.
Once you've narrowed it down to a single file, you can use the same technique by commenting out about half the lines in the file, recompile, etc.
I'm attempting to follow the documentation for the Mail_form gem to add a custom email template. The documentation states:
To customize the e-mail template that is used create a file called contact.erb in app/views/mail_form. Take a look at lib/mail_form/views/mail_form/contact.erb in this repo to see how the default template works.
Also, I found this issue in the repo and did the same:
I created a mail_for.rb file in initializers and added MailForm::Notifier.template_root = File.join(Rails.root, "app", "views"), to the file.
I created a mail_form directory in views and added a contact.erb file and copied the default template to it.
However, when I restart the server I get the following error:
Booting WEBrick
=> Rails 4.2.5 application starting in development on http://localhost:3000
=> Run rails server -h for more startup options
=> Ctrl-C to shutdown server Exiting /Users/Tony/.rvm/gems/ruby-2.2.1/gems/actionmailer-4.2.5/lib/action_mailer/base.rb:569:in
method_missing': undefined methodtemplate_root=' for
MailForm::Notifier:Class (NoMethodError) from
/Users/Tony/Desktop/Corner_Stone/vagrant/src/cornerstone/config/initializers/mail_form.rb:1:in
<top (required)>' from
/Users/Tony/.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.5/lib/active_support/dependencies.rb:268:inload' from
/Users/Tony/.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.5/lib/active_support/dependencies.rb:268:in block in load' from
/Users/Tony/.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.5/lib/active_support/dependencies.rb:240:inload_dependency' from
/Users/Tony/.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.5/lib/active_support/dependencies.rb:268:in load' from
/Users/Tony/.rvm/gems/ruby-2.2.1/gems/railties-4.2.5/lib/rails/engine.rb:652:in
block in load_config_initializer' from
/Users/Tony/.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.5/lib/active_support/notifications.rb:166:in
instrument' from
/Users/Tony/.rvm/gems/ruby-2.2.1/gems/railties-4.2.5/lib/rails/engine.rb:651:in
load_config_initializer' from
/Users/Tony/.rvm/gems/ruby-2.2.1/gems/railties-4.2.5/lib/rails/engine.rb:616:in
block (2 levels) in <class:Engine>' from
/Users/Tony/.rvm/gems/ruby-2.2.1/gems/railties-4.2.5/lib/rails/engine.rb:615:in
each' from
/Users/Tony/.rvm/gems/ruby-2.2.1/gems/railties-4.2.5/lib/rails/engine.rb:615:in
block in <class:Engine>' from
/Users/Tony/.rvm/gems/ruby-2.2.1/gems/railties-4.2.5/lib/rails/initializable.rb:30:in
instance_exec' from
/Users/Tony/.rvm/gems/ruby-2.2.1/gems/railties-4.2.5/lib/rails/initializable.rb:30:in
run' from
/Users/Tony/.rvm/gems/ruby-2.2.1/gems/railties-4.2.5/lib/rails/initializable.rb:55:in
block in run_initializers' from
/Users/Tony/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/tsort.rb:226:in
block in tsort_each' from
/Users/Tony/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/tsort.rb:348:in
block (2 levels) in each_strongly_connected_component' from
/Users/Tony/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/tsort.rb:420:in
block (2 levels) in each_strongly_connected_component_from' from
/Users/Tony/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/tsort.rb:429:in
each_strongly_connected_component_from' from
/Users/Tony/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/tsort.rb:419:in
block in each_strongly_connected_component_from' from
/Users/Tony/.rvm/gems/ruby-2.2.1/gems/railties-4.2.5/lib/rails/initializable.rb:44:in
each' from
/Users/Tony/.rvm/gems/ruby-2.2.1/gems/railties-4.2.5/lib/rails/initializable.rb:44:in
tsort_each_child' from
/Users/Tony/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/tsort.rb:413:in
call' from
/Users/Tony/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/tsort.rb:413:in
each_strongly_connected_component_from' from
/Users/Tony/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/tsort.rb:347:in
block in each_strongly_connected_component' from
/Users/Tony/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/tsort.rb:345:in
each' from
/Users/Tony/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/tsort.rb:345:in
call' from
/Users/Tony/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/tsort.rb:345:in
each_strongly_connected_component' from
/Users/Tony/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/tsort.rb:224:in
tsort_each' from
/Users/Tony/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/tsort.rb:203:in
tsort_each' from
/Users/Tony/.rvm/gems/ruby-2.2.1/gems/railties-4.2.5/lib/rails/initializable.rb:54:in
run_initializers' from
/Users/Tony/.rvm/gems/ruby-2.2.1/gems/railties-4.2.5/lib/rails/application.rb:352:in
initialize!' from
/Users/Tony/Desktop/Corner_Stone/vagrant/src/cornerstone/config/environment.rb:5:in
' from
/Users/Tony/Desktop/Corner_Stone/vagrant/src/cornerstone/config.ru:3:in
require' from
/Users/Tony/Desktop/Corner_Stone/vagrant/src/cornerstone/config.ru:3:in
block in ' from
/Users/Tony/.rvm/gems/ruby-2.2.1/gems/rack-1.6.4/lib/rack/builder.rb:55:in
instance_eval' from
/Users/Tony/.rvm/gems/ruby-2.2.1/gems/rack-1.6.4/lib/rack/builder.rb:55:in
initialize' from
/Users/Tony/Desktop/Corner_Stone/vagrant/src/cornerstone/config.ru:in
new' from
/Users/Tony/Desktop/Corner_Stone/vagrant/src/cornerstone/config.ru:in
' from
/Users/Tony/.rvm/gems/ruby-2.2.1/gems/rack-1.6.4/lib/rack/builder.rb:49:in
eval' from
/Users/Tony/.rvm/gems/ruby-2.2.1/gems/rack-1.6.4/lib/rack/builder.rb:49:in
new_from_string' from
/Users/Tony/.rvm/gems/ruby-2.2.1/gems/rack-1.6.4/lib/rack/builder.rb:40:in
parse_file' from
/Users/Tony/.rvm/gems/ruby-2.2.1/gems/rack-1.6.4/lib/rack/server.rb:299:in
build_app_and_options_from_config' from
/Users/Tony/.rvm/gems/ruby-2.2.1/gems/rack-1.6.4/lib/rack/server.rb:208:in
app' from
/Users/Tony/.rvm/gems/ruby-2.2.1/gems/railties-4.2.5/lib/rails/commands/server.rb:61:in
app' from
/Users/Tony/.rvm/gems/ruby-2.2.1/gems/rack-1.6.4/lib/rack/server.rb:336:in
wrapped_app' from
/Users/Tony/.rvm/gems/ruby-2.2.1/gems/railties-4.2.5/lib/rails/commands/server.rb:139:in
log_to_stdout' from
/Users/Tony/.rvm/gems/ruby-2.2.1/gems/railties-4.2.5/lib/rails/commands/server.rb:78:in
start' from
/Users/Tony/.rvm/gems/ruby-2.2.1/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:80:in
block in server' from
/Users/Tony/.rvm/gems/ruby-2.2.1/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:75:in
tap' from
/Users/Tony/.rvm/gems/ruby-2.2.1/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:75:in
server' from
/Users/Tony/.rvm/gems/ruby-2.2.1/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:39:in
run_command!' from
/Users/Tony/.rvm/gems/ruby-2.2.1/gems/railties-4.2.5/lib/rails/commands.rb:17:in
' from
/Users/Tony/Desktop/Corner_Stone/vagrant/src/cornerstone/bin/rails:9:in
require' from
/Users/Tony/Desktop/Corner_Stone/vagrant/src/cornerstone/bin/rails:9:in
' from
/Users/Tony/.rvm/gems/ruby-2.2.1/gems/spring-1.6.4/lib/spring/client/rails.rb:28:in
load' from
/Users/Tony/.rvm/gems/ruby-2.2.1/gems/spring-1.6.4/lib/spring/client/rails.rb:28:in
call' from
/Users/Tony/.rvm/gems/ruby-2.2.1/gems/spring-1.6.4/lib/spring/client/command.rb:7:in
call' from
/Users/Tony/.rvm/gems/ruby-2.2.1/gems/spring-1.6.4/lib/spring/client.rb:28:in
run' from
/Users/Tony/.rvm/gems/ruby-2.2.1/gems/spring-1.6.4/bin/spring:49:in
<top (required)>' from
/Users/Tony/.rvm/gems/ruby-2.2.1/gems/spring-1.6.4/lib/spring/binstub.rb:11:in
load' from
/Users/Tony/.rvm/gems/ruby-2.2.1/gems/spring-1.6.4/lib/spring/binstub.rb:11:in
<top (required)>' from
/Users/Tony/Desktop/Corner_Stone/vagrant/src/cornerstone/bin/spring:13:in
require' from
/Users/Tony/Desktop/Corner_Stone/vagrant/src/cornerstone/bin/spring:13:in
<top (required)>' from bin/rails:3:inload' from bin/rails:3:in
`'
Everything works when I remove the code in the mail_form.rb file, but I want to customize the mail notification to my liking. The error says undefined method template_root=' for MailForm::Notifier:Class, but I don't know what it means. I'm still learning so this error is a little over my head, Any help would be greatly appreciated! Thanks!
I was faced with the same problem. It was quite frustrating that their documentation is lacking information about custom template. It's so nebulous. I need to give credit to a colleague of mine for finding a quick solution. He is way more skilled than me in Ruby.
Here's what he did:
Remove/delete the mail_form.rb file in initializers. My colleague thinks the gem already does this by default, and after testing this theory I guess he was right. So you don't need the file.
Expend your External Libraries folder in your project tree and find the mail_form folder. I'm using RubyMine so I don't know if your software will show this. tell me if if it doesn't and I will update my answer and paste the initial template code.
Inside the mail_form folder, expand and access the following file lib>mail_form>views>mail_form>contact.erb. This .erb file is the initial template used by the gem.
Copy/paste the content of the file accessed above into the contact.erb file that you previously created inside your mail_form directory in your views directory. This will become your custom template.
Once this is done, you now have full control over the email template, so modify the code to your liking.
Currently using rails 4.2.0 & ruby 2.2.0p0
re-bundled to pick up some gem updates
RAILS_ENV=production rails c fails with the following stack trace
/home/linkee/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/bundler-1.7.11/lib/bundler/runtime.rb:76:in require': File is already defined (NameError)
from /home/linkee/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/bundler-1.7.11/lib/bundler/runtime.rb:76:inblock (2 levels) in require'
from /home/linkee/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/bundler-1.7.11/lib/bundler/runtime.rb:72:in each'
from /home/linkee/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/bundler-1.7.11/lib/bundler/runtime.rb:72:inblock in require'
from /home/linkee/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/bundler-1.7.11/lib/bundler/runtime.rb:61:in each'
from /home/linkee/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/bundler-1.7.11/lib/bundler/runtime.rb:61:inrequire'
from /home/linkee/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/bundler-1.7.11/lib/bundler.rb:134:in require'
from /home/linkee/linker/config/application.rb:14:in'
from /home/linkee/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:141:in require'
from /home/linkee/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:141:inrequire_application_and_environment!'
from /home/linkee/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:67:in console'
from /home/linkee/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:39:inrun_command!'
from /home/linkee/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/railties-4.2.0/lib/rails/commands.rb:17:in <top (required)>'
from /home/linkee/linker/bin/rails:4:inrequire'
from /home/linkee/linker/bin/rails:4:in `'
I note that the runtime.rb fails when trying to require 'zipruby' so I excluded that gem from being required by changing line 76 in require.rb to
pp required_file = file
Kernel.require(file) unless file == 'zipruby'
and that at least bypassed whatever the problem was.
Please let me know if you require further information to help in sorting out this problem.
I am migrating my rails app from Rails 2.3 to 3.2. I have ActiveSupport 3.2 dependency but at app startup I keep getting following error. I am not using active_support/secure_random anywhere in my code. Can someone please help me solve this problem?
Error Logs -
[Thu Sep 04 22:52:56.014721 2014] [:warn] [pid 1440] FastCGI: server "AppRootFolder/bin/rails_dispatch.fcgi" (pid 1554) terminated by calling exit with status '1'
AppRootFolder/ruby1.9/gems/1.9.1/gems/activesupport-3.2.19/lib/active_support/dependencies.rb:317:in rescue in depend_on': No such file to load -- active_support/secure_random (LoadError) from AppRootFolder/ruby1.9/gems/1.9.1/gems/activesupport-3.2.19/lib/active_support/dependencies.rb:312:independ_on'
from AppRootFolder/ruby1.9/gems/1.9.1/gems/activesupport-3.2.19/lib/active_support/dependencies.rb:225:in require_dependency' from AppRootFolder/ruby1.9/gems/1.9.1/gems/railties-3.2.19/lib/rails/engine.rb:444:inblock (2 levels) in eager_load!'
from AppRootFolder/ruby1.9/gems/1.9.1/gems/railties-3.2.19/lib/rails/engine.rb:443:in each' from AppRootFolder/ruby1.9/gems/1.9.1/gems/railties-3.2.19/lib/rails/engine.rb:443:inblock in eager_load!'
from AppRootFolder/ruby1.9/gems/1.9.1/gems/railties-3.2.19/lib/rails/engine.rb:441:in each' from AppRootFolder/ruby1.9/gems/1.9.1/gems/railties-3.2.19/lib/rails/engine.rb:441:ineager_load!'
from AppRootFolder/ruby1.9/gems/1.9.1/gems/railties-3.2.19/lib/rails/application/finisher.rb:53:in block in <module:Finisher>' from AppRootFolder/ruby1.9/gems/1.9.1/gems/railties-3.2.19/lib/rails/initializable.rb:30:ininstance_exec'
from AppRootFolder/ruby1.9/gems/1.9.1/gems/railties-3.2.19/lib/rails/initializable.rb:30:in run' from AppRootFolder/ruby1.9/gems/1.9.1/gems/railties-3.2.19/lib/rails/initializable.rb:55:inblock in run_initializers'
from AppRootFolder/ruby1.9/gems/1.9.1/gems/railties-3.2.19/lib/rails/initializable.rb:54:in each' from AppRootFolder/ruby1.9/gems/1.9.1/gems/railties-3.2.19/lib/rails/initializable.rb:54:inrun_initializers'
from AppRootFolder/ruby1.9/gems/1.9.1/gems/railties-3.2.19/lib/rails/application.rb:136:in initialize!' from AppRootFolder/ruby1.9/gems/1.9.1/gems/railties-3.2.19/lib/rails/railtie/configurable.rb:30:inmethod_missing'
from AppRootFolder/var/rails-root/config/environment.rb:4:in <top (required)>' from AppRootFolder/ruby1.9/1.9.1/rubygems/custom_require.rb:36:inrequire'
from AppRootFolder/ruby1.9/1.9.1/rubygems/custom_require.rb:36:in require' from AppRootFolder/var/rails-root/config.ru:3:inblock in '
from AppRootFolder/ruby1.9/gems/1.9.1/gems/rack-1.4.5/lib/rack/builder.rb:51:in instance_eval' from AppRootFolder/ruby1.9/gems/1.9.1/gems/rack-1.4.5/lib/rack/builder.rb:51:ininitialize'
from AppRootFolder/var/rails-root/config.ru:in new' from AppRootFolder/var/rails-root/config.ru:in'
from AppRootFolder/ruby1.9/gems/1.9.1/gems/rack-1.4.5/lib/rack/builder.rb:40:in eval' from AppRootFolder/ruby1.9/gems/1.9.1/gems/rack-1.4.5/lib/rack/builder.rb:40:inparse_file'
from AppRootFolder/ruby1.9/gems/1.9.1/gems/rack-1.4.5/lib/rack/server.rb:200:in app' from AppRootFolder/ruby1.9/gems/1.9.1/gems/rack-1.4.5/lib/rack/server.rb:304:inwrapped_app'
from AppRootFolder/ruby1.9/gems/1.9.1/gems/rack-1.4.5/lib/rack/server.rb:254:in start' from AppRootFolder/ruby1.9/gems/1.9.1/gems/rack-1.4.5/lib/rack/server.rb:137:instart'
from AppRootFolder/bin/rails_dispatch.fcgi:20:in `'
ActiveSupport::SecureRandom was removed from rails 3.2 because rails 3.2 requires ruby 1.8.7 already has a builtin SecureRandom.
Replace any requires with
require 'securerandom'
And use SecureRandom instead.
If you're not using SecureRandom directly then you are probably using a gem that does, for example old versions of devise.
i'm trying to move my rails app from ubuntu to osx. when running rspec, i get the following obscure error:
/Users/josh/dev/myproject/spec/support/devise.rb:3:in `block in <top (required)>': uninitialized constant RequestHelpers (NameError)
from /Users/josh/.rvm/gems/ruby-1.9.3-p286#myproject/gems/rspec-core-2.11.1/lib/rspec/core.rb:92:in `configure'
from /Users/josh/dev/myproject/spec/support/devise.rb:1:in `<top (required)>'
from /Users/josh/dev/myproject/spec/spec_helper.rb:21:in `block (2 levels) in <top (required)>'
from /Users/josh/dev/myproject/spec/spec_helper.rb:21:in `each'
from /Users/josh/dev/myproject/spec/spec_helper.rb:21:in `block in <top (required)>'
from /Users/josh/.rvm/gems/ruby-1.9.3-p286#myproject/gems/spork-0.9.2/lib/spork.rb:24:in `prefork'
from /Users/josh/dev/myproject/spec/spec_helper.rb:4:in `<top (required)>'
from /Users/josh/dev/myproject/spec/controllers/comments_controller_spec.rb:1:in `require'
from /Users/josh/dev/myproject/spec/controllers/comments_controller_spec.rb:1:in `<top (required)>'
from /Users/josh/.rvm/gems/ruby-1.9.3-p286#myproject/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:780:in `load'
from /Users/josh/.rvm/gems/ruby-1.9.3-p286#myproject/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:780:in `block in load_spec_files'
from /Users/josh/.rvm/gems/ruby-1.9.3-p286#myproject/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:780:in `map'
from /Users/josh/.rvm/gems/ruby-1.9.3-p286#myproject/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:780:in `load_spec_files'
from /Users/josh/.rvm/gems/ruby-1.9.3-p286#myproject/gems/rspec-core-2.11.1/lib/rspec/core/command_line.rb:22:in `run'
from /Users/josh/.rvm/gems/ruby-1.9.3-p286#myproject/gems/rspec-core-2.11.1/lib/rspec/core/runner.rb:66:in `rescue in run'
from /Users/josh/.rvm/gems/ruby-1.9.3-p286#myproject/gems/rspec-core-2.11.1/lib/rspec/core/runner.rb:62:in `run'
from /Users/josh/.rvm/gems/ruby-1.9.3-p286#myproject/gems/rspec-core-2.11.1/lib/rspec/core/runner.rb:8:in `block in autorun'
everything works nicely in Ubuntu, so i guess it must be environmental. Any ideas where to start digging?
thanks
- Josh
EDIT: no idea why, but the file request_helpers.rb could not be found by rake. moving it elsewhere resolved the issue.
This hardly seems an operating system problem, much rather a matter of configuration. Make sure your environemnt is the same in terms of:
using rvm installed the same way
having all the needed gems in the Gemfile
using bundle to execute rspec
using the same version of everything.
By te way this is not an obscure message, it's in fact pretty clear:
uninitialized constant RequestHelpers (NameError)
so the spec/support/devise.rb file can't find the needed class.
Have you written that file? If not, how did you generate it? Repeat the procedure to generate it (probably rake something or rails generate something) and it will be OK.