Strange error in rails - missing helper

2019-01-07 09:43发布

问题:

I am not sure , but this might be associated with a crashed computer. After restarting (after the crash) I get a missing helper error where the helper name is wrong. Switching branches has no effect on the outcome.

The error is:

Missing helper file helpers//users/xxxx/sites/xxxx/app/helpers/accounts_helper.rb_helper.rb

Ive tried updating gems, uninstalled rails and reinstalled, checked helper names and anywhere helpers are included. Ive also reviewed git logs and checked recently changed code. No luck.

Stack Trace

Started GET "/" for 127.0.0.1 at 2015-01-09 17:53:57 -0700
  ActiveRecord::SchemaMigration Load (1.1ms)  SELECT "schema_migrations".* FROM "schema_migrations"

AbstractController::Helpers::MissingHelperError - Missing helper file helpers//users/xxxx/sites/xxxx/app/helpers/accounts_helper.rb_helper.rb:
  actionpack (4.2.0) lib/abstract_controller/helpers.rb:151:in `rescue in block in modules_for_helpers'
  actionpack (4.2.0) lib/abstract_controller/helpers.rb:148:in `block in modules_for_helpers'
  actionpack (4.2.0) lib/abstract_controller/helpers.rb:144:in `modules_for_helpers'
  actionpack (4.2.0) lib/action_controller/metal/helpers.rb:93:in `modules_for_helpers'
  actionpack (4.2.0) lib/abstract_controller/helpers.rb:108:in `helper'
  actionpack (4.2.0) lib/action_controller/railties/helpers.rb:17:in `inherited'
  app/controllers/application_controller.rb:1:in `<top (required)>'
  activesupport (4.2.0) lib/active_support/dependencies.rb:457:in `block in load_file'
  activesupport (4.2.0) lib/active_support/dependencies.rb:647:in `new_constants_in'
  activesupport (4.2.0) lib/active_support/dependencies.rb:456:in `load_file'
  activesupport (4.2.0) lib/active_support/dependencies.rb:354:in `require_or_load'
  activesupport (4.2.0) lib/active_support/dependencies.rb:494:in `load_missing_constant'
  activesupport (4.2.0) lib/active_support/dependencies.rb:184:in `const_missing'
  app/controllers/pages_controller.rb:1:in `<top (required)>'
  activesupport (4.2.0) lib/active_support/dependencies.rb:457:in `block in load_file'
  activesupport (4.2.0) lib/active_support/dependencies.rb:647:in `new_constants_in'
  activesupport (4.2.0) lib/active_support/dependencies.rb:456:in `load_file'
  activesupport (4.2.0) lib/active_support/dependencies.rb:354:in `require_or_load'
  activesupport (4.2.0) lib/active_support/dependencies.rb:494:in `load_missing_constant'
  activesupport (4.2.0) lib/active_support/dependencies.rb:184:in `const_missing'
  activesupport (4.2.0) lib/active_support/inflector/methods.rb:261:in `block in constantize'
  activesupport (4.2.0) lib/active_support/inflector/methods.rb:259:in `constantize'
  activesupport (4.2.0) lib/active_support/dependencies.rb:566:in `get'
  activesupport (4.2.0) lib/active_support/dependencies.rb:597:in `constantize'
  actionpack (4.2.0) lib/action_dispatch/routing/route_set.rb:69:in `controller_reference'
  actionpack (4.2.0) lib/action_dispatch/routing/route_set.rb:59:in `controller'
  actionpack (4.2.0) lib/action_dispatch/routing/route_set.rb:38:in `serve'
  actionpack (4.2.0) lib/action_dispatch/journey/router.rb:43:in `block in serve'
  actionpack (4.2.0) lib/action_dispatch/journey/router.rb:30:in `serve'
  actionpack (4.2.0) lib/action_dispatch/routing/route_set.rb:802:in `call'
  bullet (4.14.0) lib/bullet/rack.rb:10:in `call'
  meta_request (0.3.4) lib/meta_request/middlewares/app_request_handler.rb:13:in `call'
  meta_request (0.3.4) lib/meta_request/middlewares/meta_request_handler.rb:13:in `call'
  rack (1.6.0) lib/rack/etag.rb:24:in `call'
  rack (1.6.0) lib/rack/conditionalget.rb:25:in `call'
  rack (1.6.0) lib/rack/head.rb:13:in `call'
  actionpack (4.2.0) lib/action_dispatch/middleware/params_parser.rb:27:in `call'
  actionpack (4.2.0) lib/action_dispatch/middleware/flash.rb:260:in `call'
  rack (1.6.0) lib/rack/session/abstract/id.rb:225:in `context'
  rack (1.6.0) lib/rack/session/abstract/id.rb:220:in `call'
  actionpack (4.2.0) lib/action_dispatch/middleware/cookies.rb:560:in `call'
  activerecord (4.2.0) lib/active_record/query_cache.rb:36:in `call'
  activerecord (4.2.0) lib/active_record/connection_adapters/abstract/connection_pool.rb:647:in `call'
  activerecord (4.2.0) lib/active_record/migration.rb:378:in `call'
  actionpack (4.2.0) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
  activesupport (4.2.0) lib/active_support/callbacks.rb:88:in `_run_callbacks'
  activesupport (4.2.0) lib/active_support/callbacks.rb:734:in `_run_call_callbacks'
  activesupport (4.2.0) lib/active_support/callbacks.rb:81:in `run_callbacks'
  actionpack (4.2.0) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
  actionpack (4.2.0) lib/action_dispatch/middleware/reloader.rb:73:in `call'
  actionpack (4.2.0) lib/action_dispatch/middleware/remote_ip.rb:78:in `call'
  better_errors (2.1.0) lib/better_errors/middleware.rb:84:in `protected_app_call'
  better_errors (2.1.0) lib/better_errors/middleware.rb:79:in `better_errors_call'
  better_errors (2.1.0) lib/better_errors/middleware.rb:57:in `call'
  rack-contrib (1.2.0) lib/rack/contrib/response_headers.rb:17:in `call'
  meta_request (0.3.4) lib/meta_request/middlewares/headers.rb:16:in `call'
  web-console (2.0.0) lib/action_dispatch/debug_exceptions.rb:18:in `middleware_call'
  web-console (2.0.0) lib/action_dispatch/debug_exceptions.rb:13:in `call'
  actionpack (4.2.0) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
  railties (4.2.0) lib/rails/rack/logger.rb:38:in `call_app'
  railties (4.2.0) lib/rails/rack/logger.rb:20:in `block in call'
  activesupport (4.2.0) lib/active_support/tagged_logging.rb:68:in `block in tagged'
  activesupport (4.2.0) lib/active_support/tagged_logging.rb:26:in `tagged'
  activesupport (4.2.0) lib/active_support/tagged_logging.rb:68:in `tagged'
  railties (4.2.0) lib/rails/rack/logger.rb:20:in `call'
  actionpack (4.2.0) lib/action_dispatch/middleware/request_id.rb:21:in `call'
  rack (1.6.0) lib/rack/methodoverride.rb:22:in `call'
  rack (1.6.0) lib/rack/runtime.rb:18:in `call'
  activesupport (4.2.0) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
  rack (1.6.0) lib/rack/lock.rb:17:in `call'
  actionpack (4.2.0) lib/action_dispatch/middleware/static.rb:113:in `call'
  rack (1.6.0) lib/rack/sendfile.rb:113:in `call'
  rack-mini-profiler (0.9.2) lib/mini_profiler/profiler.rb:300:in `call'
  railties (4.2.0) lib/rails/engine.rb:518:in `call'
  railties (4.2.0) lib/rails/application.rb:164:in `call'
  rack (1.6.0) lib/rack/lock.rb:17:in `call'
  rack (1.6.0) lib/rack/content_length.rb:15:in `call'
  rack (1.6.0) lib/rack/handler/webrick.rb:89:in `service'
  /Users/Hank/.rvm/rubies/ruby-2.2.0-rc1/lib/ruby/2.2.0/webrick/httpserver.rb:138:in `service'
  /Users/Hank/.rvm/rubies/ruby-2.2.0-rc1/lib/ruby/2.2.0/webrick/httpserver.rb:94:in `run'
  /Users/Hank/.rvm/rubies/ruby-2.2.0-rc1/lib/ruby/2.2.0/webrick/server.rb:294:in `block in start_thread'

回答1:

The problem seems to have been introduced in the latest version of ruby, ruby 2.2.0.

Try this experiment:

in rails console/or irb:

[1] pry(main)>File.expand_path ("./") 
=> "/users/xxxx/Sites/xxxx"

and in the terminal window:

]$ pwd
/users/xxxx/sites/xxxx

See the different case? If you get that, then deep in the bowels of active support a regex goes south. One fix is to remove the "sites" directory and recreate. It might also work to rename the sites directory using the finder, as rename it to "foobar" and then back to "sites".

hth.

(from this page in Japan) http://translate.google.com/translate?hl=en&sl=ja&u=http://d.hatena.ne.jp/jiikko/20150108&prev=search

And when I was debugging this with another person, it was enough to have a mixed case directory name in the path. We renamed it to 'farknerd' and then back the original, except all lower case, and it worked.



回答2:

For me, the folder 'sites' only needed to be renamed, not the entire directory.

from my user root directory I did this...

mv sites sites1
mv sites1 sites


回答3:

Following Rob's instructions, I found it necessary to rename + lowercase every folder in the filepath up to 'Users' before my error went away.



回答4:

Mine also was a case issue. I was initially in the folder C:\users\pxxx\projects\odot which was throwing the above error. When I changed to C:\Users\Pxxx\projects\odot it seemed to work



回答5:

The problem..

For me the same issue with the error

 "missing helper file app/helpers/application_helper.rb_helper.rb"

The app was located in a directory tree

/Users/grantsayer/Documents/Work/recipes

So on conducting the test to show the path, both from within the terminal and within the ruby environment I found the following:

1. Ruby environment

Grants-MacBook-Pro:Recipes grantsayer$ irb

2.2.0 :001 >

2.2.0 :002 > File.expand_path("./") => "/Users/grantsayer/Documents/Work/Recipes"

2. Unix Terminal

Grants-MacBook-Pro:Recipes grantsayer$ pwd /Users/grantsayer/Documents/Work/recipes

At this stage running the rails server and navigating to http://localhost:3000 resulted in the error about a missing application helper. This error, as others have described, appears to be a bug within ruby causing case conversion on the file path.

I solved the issue by renaming the recipes folder to Recipes so that the ruby environment check in irb matched the local filesystem.



回答6:

I had the same problem, apparently related to dropbox, but not case sensitive as others have suggested.

Following @Rob's answer, the output of [1] pry(main)>File.expand_path ("./") resulted in:

/Users/xxxx/dropbox/xxxx

and the output of ]$ pwd also resulted in:

/Users/xxxx/dropbox/xxxx

Following @Beengie's instructions, from my Users root directory, I did:

mv Dropbox Dropbox1
mv Dropbox1 Dropbox

This solves the problem for me -- until I reboot, at which point I have to perform the operation again. I'm still looking for a permanent fix.



回答7:

I had the same problem, but NO user-created directories that had uppercase letter in them... only /Users.

I tried upgrading to ruby 2.2.1 - this did not fix it.

I very hesitantly fixed it by doing the same case-sensitive "fix" on my /Users directory:

cd /
sudo mv Users users1
sudo mv users1 users

I have yet to see if that breaks anything else....



回答8:

I had the same issue using powder gem. Here is how I fixed it:

powder unlink
powder link


回答9:

This had been bugging me for so long. I didn't find any joy with attempting to rename the files or directories.

I did, however, find a really easy fix. Simply go into the main directory of your project and run 'bundle install'. It installed all of the gem dependencies (without overwriting any data I had written) which effectively fixed any issues.

Opened up the rails server and hurrah, normal service was resumed.

Hope that helps!



回答10:

I'm running 2.2.0 and did as @Rob said and found that it was my the apps root directory that had the problem since it had a capitalized name. I'm also not keeping the app in the Sites directory but another sibling directory.



回答11:

Had the same problem on Ruby 2.2.0 and i only managed to fix it by changing the folder structure from

/Users/xxx/Documents/Ruby/xxxx

to

/Users/xxx/Documents/ruby/xxxx

So lower case the folder name



回答12:

I got the same error as above, but it was not due to a case issue. It ended up being due to a combination of things. I had two ruby version managers installed- rvm and rbenv- and I was using an old gem installer. I had to uninstall rvm (How can I remove RVM (Ruby Version Manager) from my system?) and reinstall rbenv (brew reinstall rbenv)and upgrade to the lastest version of ruby. Then I had to update rubygems (gem update --system). Then, reinstalled all gems and a reboot and everything was fixed.

Essentially, my ruby manager was pointing to an old version of ruby and using an outdated version of the gem installer (2.2.0). You might be able to fix things with just an upgrade to rubygems.

It took me a day and a half to get this resolved. Hopefully, this will save someone some time and frustration.



回答13:

I had a dash in one of my directories: the-mission which was also causing an error. In addition to making sure all of your parent directories are lowercase (including changing Desktop to desktop), also make sure the only characters in your directory names are letters.



回答14:

I got this error after creating a helpers directory for the first time.

The problem went away after running spring stop and trying again.



回答15:

in my case i was using windows. Using Git shell, i kept getting this error while trying to install the gem administrate from thoughtbot. The command that kept giving me the error,"AbstractController::Helpers::MissingHelperError", was:

$ rails generate administrate:install

I did not rename my folder's to lowercase as many answers have suggested. I instead used the window's cmd. It worked perfectly.



回答16:

This happened to me after I updated Rubymine. All i did was changing the folder of my website from HelloWord to helloword. Removed capital and other symbol and it works fine.