Trying to start the rails server to complete "Learn Ruby on Rails" by Kehoe and keep getting psych errors and have no idea how to troubleshoot.
Here is the output:
/Dropbox/workspace/learn-rails$ rails s
/home/mark/.rvm/gems/ruby-2.1.2#global/gems/psych-2.0.6/lib/psych.rb:370:in `parse': (<unknown>): mapping values are not allowed in this context at line 6 column 15 (Psych::SyntaxError)
from /home/mark/.rvm/gems/ruby-2.1.2#global/gems/psych-2.0.6/lib/psych.rb:370:in `parse_stream'
from /home/mark/.rvm/gems/ruby-2.1.2#global/gems/psych-2.0.6/lib/psych.rb:318:in `parse'
from /home/mark/.rvm/gems/ruby-2.1.2#global/gems/psych-2.0.6/lib/psych.rb:245:in `load'
from /home/mark/.rvm/gems/ruby-2.1.2#learn-rails/gems/figaro-1.0.0/lib/figaro/application.rb:60:in `parse'
from /home/mark/.rvm/gems/ruby-2.1.2#learn-rails/gems/figaro-1.0.0/lib/figaro/application.rb:56:in `block in raw_configuration'
from /home/mark/.rvm/gems/ruby-2.1.2#learn-rails/gems/figaro-1.0.0/lib/figaro/application.rb:56:in `yield'
from /home/mark/.rvm/gems/ruby-2.1.2#learn-rails/gems/figaro-1.0.0/lib/figaro/application.rb:56:in `raw_configuration'
from /home/mark/.rvm/gems/ruby-2.1.2#learn-rails/gems/figaro-1.0.0/lib/figaro/application.rb:64:in `global_configuration'
from /home/mark/.rvm/gems/ruby-2.1.2#learn-rails/gems/figaro-1.0.0/lib/figaro/application.rb:32:in `configuration'
from /home/mark/.rvm/gems/ruby-2.1.2#learn-rails/gems/figaro-1.0.0/lib/figaro/application.rb:42:in `each'
from /home/mark/.rvm/gems/ruby-2.1.2#learn-rails/gems/figaro-1.0.0/lib/figaro/application.rb:36:in `load'
from /home/mark/.rvm/gems/ruby-2.1.2#learn-rails/gems/figaro-1.0.0/lib/figaro.rb:23:in `load'
from /home/mark/.rvm/gems/ruby-2.1.2#learn-rails/gems/figaro-1.0.0/lib/figaro/rails/railtie.rb:5:in `block in <class:Railtie>'
from /home/mark/.rvm/gems/ruby-2.1.2#learn-rails/gems/activesupport-4.1.6/lib/active_support/lazy_load_hooks.rb:36:in `call'
from /home/mark/.rvm/gems/ruby-2.1.2#learn-rails/gems/activesupport-4.1.6/lib/active_support/lazy_load_hooks.rb:36:in `execute_hook'
from /home/mark/.rvm/gems/ruby-2.1.2#learn-rails/gems/activesupport-4.1.6/lib/active_support/lazy_load_hooks.rb:45:in `block in run_load_hooks'
from /home/mark/.rvm/gems/ruby-2.1.2#learn-rails/gems/activesupport-4.1.6/lib/active_support/lazy_load_hooks.rb:44:in `each'
from /home/mark/.rvm/gems/ruby-2.1.2#learn-rails/gems/activesupport-4.1.6/lib/active_support/lazy_load_hooks.rb:44:in `run_load_hooks'
from /home/mark/.rvm/gems/ruby-2.1.2#learn-rails/gems/railties-4.1.6/lib/rails/application.rb:123:in `initialize'
from /home/mark/.rvm/gems/ruby-2.1.2#learn-rails/gems/railties-4.1.6/lib/rails/railtie.rb:171:in `new'
from /home/mark/.rvm/gems/ruby-2.1.2#learn-rails/gems/railties-4.1.6/lib/rails/railtie.rb:171:in `instance'
from /home/mark/.rvm/gems/ruby-2.1.2#learn-rails/gems/railties-4.1.6/lib/rails/application.rb:90:in `inherited'
from /home/mark/Dropbox/workspace/learn-rails/config/application.rb:10:in `<module:LearnRails>'
from /home/mark/Dropbox/workspace/learn-rails/config/application.rb:9:in `<top (required)>'
from /home/mark/.rvm/gems/ruby-2.1.2#learn-rails/gems/railties-4.1.6/lib/rails/commands/commands_tasks.rb:79:in `require'
from /home/mark/.rvm/gems/ruby-2.1.2#learn-rails/gems/railties-4.1.6/lib/rails/commands/commands_tasks.rb:79:in `block in server'
from /home/mark/.rvm/gems/ruby-2.1.2#learn-rails/gems/railties-4.1.6/lib/rails/commands/commands_tasks.rb:76:in `tap'
from /home/mark/.rvm/gems/ruby-2.1.2#learn-rails/gems/railties-4.1.6/lib/rails/commands/commands_tasks.rb:76:in `server'
from /home/mark/.rvm/gems/ruby-2.1.2#learn-rails/gems/railties-4.1.6/lib/rails/commands/commands_tasks.rb:40:in `run_command!'
from /home/mark/.rvm/gems/ruby-2.1.2#learn-rails/gems/railties-4.1.6/lib/rails/commands.rb:17:in `<top (required)>'
from bin/rails:8:in `require'
from bin/rails:8:in `<main>'
Psych is a YAML parser and emitter. I guess that either you have a malformed database.yml or wrong encoding or something like that.
Given that Psych is a gem for handling YAML files and that your error indicates a syntax error, the odds are pretty solid you have a malformed YAML file somewhere in your config/ directory.
Related
I am doing some open source stuff for the rails app https://github.com/publiclab/mapknitter but when I try to launch the rails server using rails s I get the following error message:
DEPRECATION WARNING: Support for Rails versions before 4.2 is deprecated and will be removed from skylight 2.0. (called from require at /Users/bena/.rvm/rubies/ruby-2.4.6/lib/ruby/site_ruby/2.4.0/bundler/runtime.rb:81)
=> Booting WEBrick
=> Rails 3.2.22.5 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[SKYLIGHT] [1.7.2] Running Skylight in development mode. No data will be reported until you deploy your app.
(To disable this message for all local apps, run `skylight disable_dev_warning`.)
Exiting
/Users/bena/.rvm/gems/ruby-2.4.6/gems/railties-3.2.22.5/lib/rails/application/configuration.rb:115:in `read': No such file or directory # rb_sysopen - /Users/bena/Documents/repos/ben-repos/mapknitter/config/database.yml (Errno::ENOENT)
from /Users/bena/.rvm/gems/ruby-2.4.6/gems/railties-3.2.22.5/lib/rails/application/configuration.rb:115:in `database_configuration'
from /Users/bena/.rvm/gems/ruby-2.4.6/gems/activerecord-3.2.22.5/lib/active_record/railtie.rb:84:in `block (2 levels) in <class:Railtie>'
from /Users/bena/.rvm/gems/ruby-2.4.6/gems/activesupport-3.2.22.5/lib/active_support/lazy_load_hooks.rb:36:in `instance_eval'
from /Users/bena/.rvm/gems/ruby-2.4.6/gems/activesupport-3.2.22.5/lib/active_support/lazy_load_hooks.rb:36:in `execute_hook'
from /Users/bena/.rvm/gems/ruby-2.4.6/gems/activesupport-3.2.22.5/lib/active_support/lazy_load_hooks.rb:43:in `block in run_load_hooks'
from /Users/bena/.rvm/gems/ruby-2.4.6/gems/activesupport-3.2.22.5/lib/active_support/lazy_load_hooks.rb:42:in `each'
from /Users/bena/.rvm/gems/ruby-2.4.6/gems/activesupport-3.2.22.5/lib/active_support/lazy_load_hooks.rb:42:in `run_load_hooks'
from /Users/bena/.rvm/gems/ruby-2.4.6/gems/activerecord-3.2.22.5/lib/active_record/base.rb:720:in `<top (required)>'
from /Users/bena/.rvm/gems/ruby-2.4.6/gems/skylight-1.7.2/lib/skylight/probes.rb:119:in `require'
from /Users/bena/.rvm/gems/ruby-2.4.6/gems/skylight-1.7.2/lib/skylight/probes.rb:119:in `require'
from /Users/bena/.rvm/gems/ruby-2.4.6/gems/activesupport-3.2.22.5/lib/active_support/dependencies.rb:251:in `block in require'
from /Users/bena/.rvm/gems/ruby-2.4.6/gems/activesupport-3.2.22.5/lib/active_support/dependencies.rb:236:in `load_dependency'
from /Users/bena/.rvm/gems/ruby-2.4.6/gems/activesupport-3.2.22.5/lib/active_support/dependencies.rb:251:in `require'
from /Users/bena/Documents/repos/ben-repos/mapknitter/config/initializers/column_definition.rb:19:in `<class:ColumnDefinition>'
from /Users/bena/Documents/repos/ben-repos/mapknitter/config/initializers/column_definition.rb:17:in `<top (required)>'
from /Users/bena/.rvm/gems/ruby-2.4.6/gems/activesupport-3.2.22.5/lib/active_support/dependencies.rb:245:in `load'
from /Users/bena/.rvm/gems/ruby-2.4.6/gems/activesupport-3.2.22.5/lib/active_support/dependencies.rb:245:in `block in load'
from /Users/bena/.rvm/gems/ruby-2.4.6/gems/activesupport-3.2.22.5/lib/active_support/dependencies.rb:236:in `load_dependency'
from /Users/bena/.rvm/gems/ruby-2.4.6/gems/activesupport-3.2.22.5/lib/active_support/dependencies.rb:245:in `load'
from /Users/bena/.rvm/gems/ruby-2.4.6/gems/railties-3.2.22.5/lib/rails/engine.rb:593:in `block (2 levels) in <class:Engine>'
from /Users/bena/.rvm/gems/ruby-2.4.6/gems/railties-3.2.22.5/lib/rails/engine.rb:592:in `each'
from /Users/bena/.rvm/gems/ruby-2.4.6/gems/railties-3.2.22.5/lib/rails/engine.rb:592:in `block in <class:Engine>'
from /Users/bena/.rvm/gems/ruby-2.4.6/gems/railties-3.2.22.5/lib/rails/initializable.rb:30:in `instance_exec'
from /Users/bena/.rvm/gems/ruby-2.4.6/gems/railties-3.2.22.5/lib/rails/initializable.rb:30:in `run'
from /Users/bena/.rvm/gems/ruby-2.4.6/gems/railties-3.2.22.5/lib/rails/initializable.rb:55:in `block in run_initializers'
from /Users/bena/.rvm/gems/ruby-2.4.6/gems/railties-3.2.22.5/lib/rails/initializable.rb:54:in `each'
from /Users/bena/.rvm/gems/ruby-2.4.6/gems/railties-3.2.22.5/lib/rails/initializable.rb:54:in `run_initializers'
from /Users/bena/.rvm/gems/ruby-2.4.6/gems/railties-3.2.22.5/lib/rails/application.rb:136:in `initialize!'
from /Users/bena/.rvm/gems/ruby-2.4.6/gems/railties-3.2.22.5/lib/rails/railtie/configurable.rb:30:in `method_missing'
from /Users/bena/Documents/repos/ben-repos/mapknitter/config/environment.rb:5:in `<top (required)>'
from /Users/bena/.rvm/gems/ruby-2.4.6/gems/skylight-1.7.2/lib/skylight/probes.rb:119:in `require'
from /Users/bena/.rvm/gems/ruby-2.4.6/gems/skylight-1.7.2/lib/skylight/probes.rb:119:in `require'
from /Users/bena/Documents/repos/ben-repos/mapknitter/config.ru:3:in `block in <main>'
from /Users/bena/.rvm/gems/ruby-2.4.6/gems/rack-1.4.7/lib/rack/builder.rb:51:in `instance_eval'
from /Users/bena/.rvm/gems/ruby-2.4.6/gems/rack-1.4.7/lib/rack/builder.rb:51:in `initialize'
from /Users/bena/Documents/repos/ben-repos/mapknitter/config.ru:in `new'
from /Users/bena/Documents/repos/ben-repos/mapknitter/config.ru:in `<main>'
from /Users/bena/.rvm/gems/ruby-2.4.6/gems/rack-1.4.7/lib/rack/builder.rb:40:in `eval'
from /Users/bena/.rvm/gems/ruby-2.4.6/gems/rack-1.4.7/lib/rack/builder.rb:40:in `parse_file'
from /Users/bena/.rvm/gems/ruby-2.4.6/gems/rack-1.4.7/lib/rack/server.rb:200:in `app'
from /Users/bena/.rvm/gems/ruby-2.4.6/gems/railties-3.2.22.5/lib/rails/commands/server.rb:46:in `app'
from /Users/bena/.rvm/gems/ruby-2.4.6/gems/rack-1.4.7/lib/rack/server.rb:304:in `wrapped_app'
from /Users/bena/.rvm/gems/ruby-2.4.6/gems/rack-1.4.7/lib/rack/server.rb:254:in `start'
from /Users/bena/.rvm/gems/ruby-2.4.6/gems/railties-3.2.22.5/lib/rails/commands/server.rb:70:in `start'
from /Users/bena/.rvm/gems/ruby-2.4.6/gems/railties-3.2.22.5/lib/rails/commands.rb:55:in `block in <top (required)>'
from /Users/bena/.rvm/gems/ruby-2.4.6/gems/railties-3.2.22.5/lib/rails/commands.rb:50:in `tap'
from /Users/bena/.rvm/gems/ruby-2.4.6/gems/railties-3.2.22.5/lib/rails/commands.rb:50:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
Is the problem caused by the the version of rails I am using or the version of skylight or something else entirely?
I am using ruby 2.4.6p354 and rails 3.2.22.5
I have installed and tried to switch to rails 4.2.0 but that doesn't seem to be working, I think because in the gemfile there is a pessimistic version constraint of gem "rails" ,"~>3.2" but I could be completely wrong. I have been told not to change the gemfile.
Check first line in error backtrace. You dont have /config/database.yml in your project
No such file or directory # rb_sysopen -
/Users/bena/Documents/repos/ben-repos/mapknitter/config/database.yml
(Errno::ENOENT)
Make sure you install everything from Prerequisites and simply follow Installation guide
I've created multiple rails application from scratch, but somehow I'm not able fix Circular dependency error. For reproducing the error, I created new app with following commands,
rails new circular_test -d mysql
cd circular_test
rails g model MyImage
rails g scaffold MachineImage
rm db/migrate/20170419063916_create_my_image.rb
rails db:create
rails db:migrate
After this I edited the models, which are as follows,
app/models/machine_image.rb
class MachineImage < ApplicationRecord
AVAILABLE_FLAVORS = { "MyImage" => MyImage}
end
app/models/my_image.rb
class MyImage < MachineImage
end
Everything else was left with default setting. Nothing was changed. Note that, MyImage is inheriting from MachineImage, instead of ApplicationRecord. When I ran this application in development environment, everything works. But when I run the application in production mode (I made sure db:create & db:migrate is done for prod environment as well),
RAILS_ENV=production rails s
I get following error on running above command,
=> Booting Puma
=> Rails 5.0.2 application starting in production on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
Exiting
/Users/abhigup/.rvm/gems/ruby-2.2.2/gems/activesupport-5.0.2/lib/active_support/dependencies.rb:509:in `load_missing_constant': Circular dependency detected while autoloading constant MyImage (RuntimeError)
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/activesupport-5.0.2/lib/active_support/dependencies.rb:203:in `const_missing'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/activesupport-5.0.2/lib/active_support/dependencies.rb:543:in `load_missing_constant'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/activesupport-5.0.2/lib/active_support/dependencies.rb:203:in `const_missing'
from /Users/abhigup/Work/git/circular_test/app/models/machine_image.rb:2:in `<class:MachineImage>'
from /Users/abhigup/Work/git/circular_test/app/models/machine_image.rb:1:in `<top (required)>'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/activesupport-5.0.2/lib/active_support/dependencies.rb:293:in `require'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/activesupport-5.0.2/lib/active_support/dependencies.rb:293:in `block in require'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/activesupport-5.0.2/lib/active_support/dependencies.rb:259:in `load_dependency'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/activesupport-5.0.2/lib/active_support/dependencies.rb:293:in `require'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/activesupport-5.0.2/lib/active_support/dependencies.rb:380:in `block in require_or_load'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/activesupport-5.0.2/lib/active_support/dependencies.rb:37:in `block in load_interlock'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/activesupport-5.0.2/lib/active_support/dependencies/interlock.rb:12:in `block in loading'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/activesupport-5.0.2/lib/active_support/concurrency/share_lock.rb:150:in `exclusive'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/activesupport-5.0.2/lib/active_support/dependencies/interlock.rb:11:in `loading'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/activesupport-5.0.2/lib/active_support/dependencies.rb:37:in `load_interlock'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/activesupport-5.0.2/lib/active_support/dependencies.rb:358:in `require_or_load'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/activesupport-5.0.2/lib/active_support/dependencies.rb:511:in `load_missing_constant'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/activesupport-5.0.2/lib/active_support/dependencies.rb:203:in `const_missing'
from /Users/abhigup/Work/git/circular_test/app/models/my_image.rb:1:in `<top (required)>'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/activesupport-5.0.2/lib/active_support/dependencies.rb:293:in `require'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/activesupport-5.0.2/lib/active_support/dependencies.rb:293:in `block in require'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/activesupport-5.0.2/lib/active_support/dependencies.rb:259:in `load_dependency'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/activesupport-5.0.2/lib/active_support/dependencies.rb:293:in `require'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/activesupport-5.0.2/lib/active_support/dependencies.rb:380:in `block in require_or_load'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/activesupport-5.0.2/lib/active_support/dependencies.rb:37:in `block in load_interlock'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/activesupport-5.0.2/lib/active_support/dependencies/interlock.rb:12:in `block in loading'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/activesupport-5.0.2/lib/active_support/concurrency/share_lock.rb:150:in `exclusive'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/activesupport-5.0.2/lib/active_support/dependencies/interlock.rb:11:in `loading'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/activesupport-5.0.2/lib/active_support/dependencies.rb:37:in `load_interlock'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/activesupport-5.0.2/lib/active_support/dependencies.rb:358:in `require_or_load'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/activesupport-5.0.2/lib/active_support/dependencies.rb:336:in `depend_on'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/activesupport-5.0.2/lib/active_support/dependencies.rb:252:in `require_dependency'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/railties-5.0.2/lib/rails/engine.rb:476:in `block (2 levels) in eager_load!'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/railties-5.0.2/lib/rails/engine.rb:475:in `each'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/railties-5.0.2/lib/rails/engine.rb:475:in `block in eager_load!'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/railties-5.0.2/lib/rails/engine.rb:473:in `each'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/railties-5.0.2/lib/rails/engine.rb:473:in `eager_load!'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/railties-5.0.2/lib/rails/engine.rb:354:in `eager_load!'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/railties-5.0.2/lib/rails/application/finisher.rb:59:in `each'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/railties-5.0.2/lib/rails/application/finisher.rb:59:in `block in <module:Finisher>'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/railties-5.0.2/lib/rails/initializable.rb:30:in `instance_exec'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/railties-5.0.2/lib/rails/initializable.rb:30:in `run'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/railties-5.0.2/lib/rails/initializable.rb:55:in `block in run_initializers'
from /Users/abhigup/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/tsort.rb:226:in `block in tsort_each'
from /Users/abhigup/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/tsort.rb:348:in `block (2 levels) in each_strongly_connected_component'
from /Users/abhigup/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/tsort.rb:429:in `each_strongly_connected_component_from'
from /Users/abhigup/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/tsort.rb:347:in `block in each_strongly_connected_component'
from /Users/abhigup/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/tsort.rb:345:in `each'
from /Users/abhigup/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/tsort.rb:345:in `call'
from /Users/abhigup/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/tsort.rb:345:in `each_strongly_connected_component'
from /Users/abhigup/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/tsort.rb:224:in `tsort_each'
from /Users/abhigup/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/tsort.rb:203:in `tsort_each'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/railties-5.0.2/lib/rails/initializable.rb:54:in `run_initializers'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/railties-5.0.2/lib/rails/application.rb:352:in `initialize!'
from /Users/abhigup/Work/git/circular_test/config/environment.rb:5:in `<top (required)>'
from /Users/abhigup/Work/git/circular_test/config.ru:3:in `require_relative'
from /Users/abhigup/Work/git/circular_test/config.ru:3:in `block in <main>'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/rack-2.0.1/lib/rack/builder.rb:55:in `instance_eval'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/rack-2.0.1/lib/rack/builder.rb:55:in `initialize'
from /Users/abhigup/Work/git/circular_test/config.ru:in `new'
from /Users/abhigup/Work/git/circular_test/config.ru:in `<main>'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/rack-2.0.1/lib/rack/builder.rb:49:in `eval'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/rack-2.0.1/lib/rack/builder.rb:49:in `new_from_string'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/rack-2.0.1/lib/rack/builder.rb:40:in `parse_file'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/rack-2.0.1/lib/rack/server.rb:318:in `build_app_and_options_from_config'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/rack-2.0.1/lib/rack/server.rb:218:in `app'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/railties-5.0.2/lib/rails/commands/server.rb:59:in `app'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/rack-2.0.1/lib/rack/server.rb:353:in `wrapped_app'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/rack-2.0.1/lib/rack/server.rb:282:in `start'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/railties-5.0.2/lib/rails/commands/server.rb:79:in `start'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/railties-5.0.2/lib/rails/commands/commands_tasks.rb:90:in `block in server'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/railties-5.0.2/lib/rails/commands/commands_tasks.rb:85:in `tap'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/railties-5.0.2/lib/rails/commands/commands_tasks.rb:85:in `server'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/railties-5.0.2/lib/rails/commands/commands_tasks.rb:49:in `run_command!'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/railties-5.0.2/lib/rails/commands.rb:18:in `<top (required)>'
from /Users/abhigup/Work/git/circular_test/bin/rails:9:in `require'
from /Users/abhigup/Work/git/circular_test/bin/rails:9:in `<top (required)>'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/spring-2.0.1/lib/spring/client/rails.rb:28:in `load'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/spring-2.0.1/lib/spring/client/rails.rb:28:in `call'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/spring-2.0.1/lib/spring/client/command.rb:7:in `call'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/spring-2.0.1/lib/spring/client.rb:30:in `run'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/spring-2.0.1/bin/spring:49:in `<top (required)>'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/spring-2.0.1/lib/spring/binstub.rb:31:in `load'
from /Users/abhigup/.rvm/gems/ruby-2.2.2/gems/spring-2.0.1/lib/spring/binstub.rb:31:in `<top (required)>'
from /Users/abhigup/.rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:69:in `require'
from /Users/abhigup/.rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:69:in `require'
from /Users/abhigup/Work/git/circular_test/bin/spring:15:in `<top (required)>'
from bin/rails:3:in `load'
from bin/rails:3:in `<main>'
I was able to solve the problem by making config.eager_load = false in production.rb, but that is not ideal way to solve this issue. To addon, in my previous application I had similar structure, but it works flawlessly in production mode. Only difference is, that it is using SQLite. Is MySQL creating issue with this kind of structure? If not, What is the ideal way to solve this issue?
Note: I've tried looked into this, but it doesn't apply to me. As this error is related to load_missing_constant.
Ruby version: 2.2.2
Rails version: 5.0.2
OS: macOS Sierra 10.12.4
MySQL version: 5.7.17 Homebrew
Update: I found this article, which talks about possible reason. But it didn't specify, why the logic fails only when I try to use MySQL.
I would say that superclass shouldn't really know about sublclasses, however if you have to do so, in your specific case instead of having a constant AVAILABLE_FLAVORS, make it a class method:
def self.available_flavors
{ "MyImage" => MyImage}
end
This method won't be called when loading the class, then no circular dependency is there.
I'm in the process of upgrading a 3.0.20 app to 4.x. This was done by starting with a blank rails4 directory and adding code/tests.
Things are going well thanks to lots of rspec tests.
When some of the test fail due to validation errors (which are expected), I am getting complaints from I18n, which appears to be trying to load a directory as a translation file.
I18n::UnknownFileType: can not load translations from $MYLONGPATH/beaumont4/lib, the file type is not known
from (irb):10:in `load_file'
from /home/mcr/.rvm/gems/ruby-2.1.5/gems/i18n-0.7.0/lib/i18n/backend/base.rb:15:in `block in load_translations'
from /home/mcr/.rvm/gems/ruby-2.1.5/gems/i18n-0.7.0/lib/i18n/backend/base.rb:15:in `each'
from /home/mcr/.rvm/gems/ruby-2.1.5/gems/i18n-0.7.0/lib/i18n/backend/base.rb:15:in `load_translations'
from /home/mcr/.rvm/gems/ruby-2.1.5/gems/i18n-0.7.0/lib/i18n/backend/simple.rb:57:in `init_translations'
from /home/mcr/.rvm/gems/ruby-2.1.5/gems/i18n-0.7.0/lib/i18n/backend/simple.rb:40:in `available_locales'
from /home/mcr/.rvm/gems/ruby-2.1.5/gems/i18n-0.7.0/lib/i18n/config.rb:43:in `available_locales'
from /home/mcr/.rvm/gems/ruby-2.1.5/gems/i18n-0.7.0/lib/i18n/config.rb:49:in `available_locales_set'
from /home/mcr/.rvm/gems/ruby-2.1.5/gems/i18n-0.7.0/lib/i18n.rb:278:in `locale_available?'
from /home/mcr/.rvm/gems/ruby-2.1.5/gems/i18n-0.7.0/lib/i18n.rb:284:in `enforce_available_locales!'
from /home/mcr/.rvm/gems/ruby-2.1.5/gems/i18n-0.7.0/lib/i18n.rb:151:in `translate'
from /home/mcr/.rvm/gems/ruby-2.1.5/gems/activemodel-4.2.5/lib/active_model/naming.rb:188:in `human'
from /home/mcr/.rvm/gems/ruby-2.1.5/gems/activemodel-4.2.5/lib/active_model/errors.rb:437:in `generate_message'
from /home/mcr/.rvm/gems/ruby-2.1.5/gems/activemodel-4.2.5/lib/active_model/errors.rb:449:in `normalize_message'
from /home/mcr/.rvm/gems/ruby-2.1.5/gems/activemodel-4.2.5/lib/active_model/errors.rb:300:in `add'
from /home/mcr/.rvm/gems/ruby-2.1.5/gems/activemodel-4.2.5/lib/active_model/validations/length.rb:57:in `block in validate_each'
... 40 levels...
from /home/mcr/.rvm/gems/ruby-2.1.5/gems/railties-4.2.5/lib/rails/commands/console.rb:9:in `start'
from /home/mcr/.rvm/gems/ruby-2.1.5/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:68:in `console'
from /home/mcr/.rvm/gems/ruby-2.1.5/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
from /home/mcr/.rvm/gems/ruby-2.1.5/gems/railties-4.2.5/lib/rails/commands.rb:17:in `<top (required)>'
from /home/mcr/.rvm/gems/ruby-2.1.5/gems/activesupport-4.2.5/lib/active_support/dependencies.rb:274:in `require'
from /home/mcr/.rvm/gems/ruby-2.1.5/gems/activesupport-4.2.5/lib/active_support/dependencies.rb:274:in `block in require'
from /home/mcr/.rvm/gems/ruby-2.1.5/gems/activesupport-4.2.5/lib/active_support/dependencies.rb:240:in `load_dependency'
from /home/mcr/.rvm/gems/ruby-2.1.5/gems/activesupport-4.2.5/lib/active_support/dependencies.rb:274:in `require'
from /net/galaxy/home/mcr1002/nv/clientportaltest/beaumont4/bin/rails:9:in `<top (required)>'
from /home/mcr/.rvm/gems/ruby-2.1.5/gems/activesupport-4.2.5/lib/active_support/dependencies.rb:268:in `load'
from /home/mcr/.rvm/gems/ruby-2.1.5/gems/activesupport-4.2.5/lib/active_support/dependencies.rb:268:in `block in load'
from /home/mcr/.rvm/gems/ruby-2.1.5/gems/activesupport-4.2.5/lib/active_support/dependencies.rb:240:in `load_dependency'
from /home/mcr/.rvm/gems/ruby-2.1.5/gems/activesupport-4.2.5/lib/active_support/dependencies.rb:268:in `load'
from /home/mcr/.rvm/rubies/ruby-2.1.5/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /home/mcr/.rvm/rubies/ruby-2.1.5/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in `require'
I determined finally that the problem was that my I18path was borked by me.
I did:
config.i18n.load_path += Dir[Rails.root.join('lib').to_s]
The I18n.loadpath does not take directories, but files.
I meant to do:
config.autoload_paths += Dir[Rails.root.join('lib').to_s]
ID10T error.
I have an up to date rails application, using rails 3.2 with mongoid 2. I was unable to start testing by typing rake. The exception thrown is (sanitized):
rake test
/railsapp/app/models/image.rb:18:in `<class:Image>': undefined method `[]' for nil:NilClass (NoMethodError)
from /railsapp/app/models/image.rb:1:in `<top (required)>'
from /gems/activesupport-3.2.8/lib/active_support/dependencies.rb:251:in `require'
from /gems/activesupport-3.2.8/lib/active_support/dependencies.rb:251:in `block in require'
from /gems/activesupport-3.2.8/lib/active_support/dependencies.rb:236:in `load_dependency'
from /gems/activesupport-3.2.8/lib/active_support/dependencies.rb:251:in `require'
from /gems/activesupport-3.2.8/lib/active_support/dependencies.rb:359:in `require_or_load'
from /gems/activesupport-3.2.8/lib/active_support/dependencies.rb:313:in `depend_on'
from /gems/activesupport-3.2.8/lib/active_support/dependencies.rb:225:in `require_dependency'
from /gems/railties-3.2.8/lib/rails/engine.rb:439:in `block (2 levels) in eager_load!'
from /gems/railties-3.2.8/lib/rails/engine.rb:438:in `each'
from /gems/railties-3.2.8/lib/rails/engine.rb:438:in `block in eager_load!'
from /gems/railties-3.2.8/lib/rails/engine.rb:436:in `each'
from /gems/railties-3.2.8/lib/rails/engine.rb:436:in `eager_load!'
from /gems/railties-3.2.8/lib/rails/application/finisher.rb:53:in `block in <module:Finisher>'
from /gems/railties-3.2.8/lib/rails/initializable.rb:30:in `instance_exec'
from /gems/railties-3.2.8/lib/rails/initializable.rb:30:in `run'
from /gems/railties-3.2.8/lib/rails/initializable.rb:55:in `block in run_initializers'
from /gems/railties-3.2.8/lib/rails/initializable.rb:54:in `each'
from /gems/railties-3.2.8/lib/rails/initializable.rb:54:in `run_initializers'
from /gems/railties-3.2.8/lib/rails/application.rb:136:in `initialize!'
from /gems/railties-3.2.8/lib/rails/railtie/configurable.rb:30:in `method_missing'
from /railsapp/config/environment.rb:7:in `<top (required)>'
from /railsapp/test/test_helper.rb:2:in `require'
from /railsapp/test/test_helper.rb:2:in `<top (required)>'
from /railsapp/test/unit/post_test.rb:1:in `require'
from /railsapp/test/unit/post_test.rb:1:in `<top (required)>'
from /gems/rake-0.9.2.2/lib/rake/rake_test_loader.rb:10:in `require'
from /gems/rake-0.9.2.2/lib/rake/rake_test_loader.rb:10:in `block (2 levels) in <main>'
from /gems/rake-0.9.2.2/lib/rake/rake_test_loader.rb:9:in `each'
from /gems/rake-0.9.2.2/lib/rake/rake_test_loader.rb:9:in `block in <main>'
from /gems/rake-0.9.2.2/lib/rake/rake_test_loader.rb:4:in `select'
from /gems/rake-0.9.2.2/lib/rake/rake_test_loader.rb:4:in `<main>'
Errors running test:units! #<RuntimeError: Command failed with status (1): [/Users/janlimpens/.rvm/rubies/ruby-1.9.3-p...]>
I created a gist with the files that are of interest in the context:
https://gist.github.com/3989760
There is no test concerning the image model at all, there are no fixtures and the only test I have got is included into the gist, but it is not to blame, the error is thrown upon including test_helper.rb.
What are my options?
When the tests start Rails loads up, as it does so it evaluates all of your models.
This includes the Image model, which apparently has a bug or typo on line 18.
Which would be this line:
:path => "#{APP_CONFIG['uploads_dir']}/:class/:id/:attachment/:style.:extension",
The only array notation here is:
APP_CONFIG['uploads_dir']
So, where is APP_CONFIG defined? And why is it a nil? These are the questions we must answer.
You might start by grepping your project for this string.
I am working my way through the Ruby on Rails Tutorial. In chapter 5, I've hit another bump in the road that I can't figure out nor find a solution for.
For one, my home page has dissapeared and I don't know why. That is, for some reason the access to it is gone.
And when I run the test. I get the following response:
Exception encountered: RuntimeError: Application has been already initialized.
backtrace:
Can someone help?
Here is the backtrace (with some helpful formatting for easier viewing):
/Users/tomgalpin/.rvm/gems/ruby-1.9.3-p194#rails3tutorial2ndEd/gems/railties-3.2.8/lib/rails/application.rb:135:in `initialize!'
/Users/tomgalpin/.rvm/gems/ruby-1.9.3-p194#rails3tutorial2ndEd/gems/railties-3.2.8/lib/rails/railtie/configurable.rb:30:in `method_missing'
/Users/tomgalpin/rails_projects/sample_app/config/environment.rb:5:in `<top (required)>'
/Users/tomgalpin/.rvm/gems/ruby-1.9.3-p194#rails3tutorial2ndEd/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:251:in `require'
/Users/tomgalpin/.rvm/gems/ruby-1.9.3-p194#rails3tutorial2ndEd/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:251:in `block in require'
/Users/tomgalpin/.rvm/gems/ruby-1.9.3-p194#rails3tutorial2ndEd/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:236:in `load_dependency'
/Users/tomgalpin/.rvm/gems/ruby-1.9.3-p194#rails3tutorial2ndEd/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:251:in `require'
/Users/tomgalpin/rails_projects/sample_app/spec/spec_helper.rb:3:in `<top (required)>'
/Users/tomgalpin/.rvm/gems/ruby-1.9.3-p194#rails3tutorial2ndEd/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:245:in `load'
/Users/tomgalpin/.rvm/gems/ruby-1.9.3-p194#rails3tutorial2ndEd/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:245:in `block in load'
/Users/tomgalpin/.rvm/gems/ruby-1.9.3-p194#rails3tutorial2ndEd/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:236:in `load_dependency'
/Users/tomgalpin/.rvm/gems/ruby-1.9.3-p194#rails3tutorial2ndEd/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:245:in `load'
/Users/tomgalpin/.rvm/gems/ruby-1.9.3-p194#rails3tutorial2ndEd/gems/spork-0.9.2/lib/spork/run_strategy/forking.rb:11:in `block in run'
/Users/tomgalpin/.rvm/gems/ruby-1.9.3-p194#rails3tutorial2ndEd/gems/spork-0.9.2/lib/spork/forker.rb:21:in `block in initialize'
/Users/tomgalpin/.rvm/gems/ruby-1.9.3-p194#rails3tutorial2ndEd/gems/spork-0.9.2/lib/spork/forker.rb:18:in `fork'
/Users/tomgalpin/.rvm/gems/ruby-1.9.3-p194#rails3tutorial2ndEd/gems/spork-0.9.2/lib/spork/forker.rb:18:in `initialize'
/Users/tomgalpin/.rvm/gems/ruby-1.9.3-p194#rails3tutorial2ndEd/gems/spork-0.9.2/lib/spork/run_strategy/forking.rb:9:in `new'
/Users/tomgalpin/.rvm/gems/ruby-1.9.3-p194#rails3tutorial2ndEd/gems/spork-0.9.2/lib/spork/run_strategy/forking.rb:9:in `run'
/Users/tomgalpin/.rvm/gems/ruby-1.9.3-p194#rails3tutorial2ndEd/gems/spork-0.9.2/lib/spork/server.rb:48:in `run'
/Users/tomgalpin/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/drb/drb.rb:1548:in `perform_without_block'
/Users/tomgalpin/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/drb/drb.rb:1508:in `perform'
/Users/tomgalpin/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/drb/drb.rb:1586:in `block (2 levels) in main_loop'
/Users/tomgalpin/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/drb/drb.rb:1582:in `loop'
/Users/tomgalpin/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/drb/drb.rb:1582:in `block in main_loop'
This fixed the issue for me:
bundle exec spork --bootstrap