rails: Missing helper file helpers//Users/xxxx/Sites/xxxx/app/helpers/application_helper.rb_helper.rb

I had a very strange issues out of the blue today. Happens for every controller action; app server and console boot up fine.

It started happening without any changes, and rolling back to a previous commit didn’t fix it either. Reinstalling ruby and rails and all the rest of the gems didn’t fix it either.

Setup: OSX Yosemite, Ruby 2.2.0, Rails 4.1.9.

Missing helper file helpers//Users/xxxx/Sites/xxxx/app/helpers/application_helper.rb_helper.rb

I finally fixed it by renaming all directories (i.e. Sites to sites) in the apps path to lowercase (except /Users).

Full story here: http://stackoverflow.com/a/27966165/893510

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 126 (25 by maintainers)

Commits related to this issue

Most upvoted comments

This issue happened to me today using rails 5.2.3 and ruby 2.5.1 It never happened before in the app I’m working.

Stoping spring solved the problem Run on the command line: $ spring stop

In Windows 10 - I was able to (finally) use Ruby on Rails after making sure the path I was using in my terminal matched case exactly with the actual path.

i.e. C:\Users\Username\Desktop\filefolder...

versus neglecting capitalization (as I was doing)

C:\users\username\desktop\filefolder...

The new APFS is case-sensitive in macOS 10.13 beta2 and giving this bug for me.

helpers//users/username/github/repo_name/app/helpers/active_admin/views_helper.rb_helper.rb /Users/username/Github/Repo-Name/app/helpers/active_admin/views_helper.rb

Not all-lowercase and changed - to _

Manually applying this patch fixed it for me https://github.com/rails/rails/pull/24821

$ spring stop solved my problem. (Same version Ruby & Rails)

I had this issue using rails 4.2.5.1 and ruby 2.2.4. When navigating using Git bash, if I navigated to the “Documents” folder using “documents”, I got the error. I corrected it by navigating using the correct capitalization of folder names. no other changes.

I tried everything and nothing worked except these simple instructions http://quick.as/yvyqsn7j

Just got this and changed “application_helper.rb” to “application_helper.rb_helper.rb” in my app/helpers folder and it works

I’m hitting this error as well on Rails 4.1.9 after switching to Ruby 2.2.0. This line is erroring (filename equals application_helper)

The issue goes away when changing /Users/dan/Projects/my_app to /Users/dan/projects/my_app. My guess is an issue with ruby-2.2.0, unrelated to Rails.

Probably time to nuke this one.

For me this was a Mac OS X quirk. I recall that I created a rails project in a folder called marketing/projname then later renamed marketing to Marketing. Everything worked fine when running the project in Docker but then one day I tried to run it natively and hit this bug. Here is my fix:

cd ../..
mv Marketing x
mkdir Marketing
mv x/* Marketing
rmdir x

This fixed the problem. It should have not effect but I believe Mac OS X for some reason remembers the original case that a folder was created with and regurgitates it on occasion.

This accounts for namespaces

      def all_helpers_from_path(path)
        helpers = Array(path).flat_map do |_path|
          Dir["#{_path}/**/*_helper.rb"].map! { |file|
            sub_folder = file.gsub(_path.to_s, "").gsub(File.basename(file),"").gsub(/^\//,"")
            module_name = File.basename(file, '_helper.rb')
            "#{sub_folder}#{module_name}"
            }.sort!
        end
        helpers.uniq!
        helpers
      end

Here’s on Linux:

2.2.1 :001 > Dir.glob("*")
 => ["Foo"]
2.2.1 :002 > Dir.glob('foO')
 => []
2.2.1 :003 > Dir.glob("F?O")
 => []
2.2.1 :004 > Dir.glob("F??")
 => ["Foo"]
2.2.1 :005 > Dir.glob("f??")
 => []
2.2.1 :006 > Dir.glob("fo?")
 => []
2.2.1 :007 > Dir.glob("Fo?")
 => ["Foo"]
2.2.1 :008 > Dir.glob("F?o")
 => ["Foo"]
2.2.1 :009 > Dir.glob("?oO")
 => []
2.2.1 :010 > Dir.glob("?oo")
 => ["Foo"]
2.2.1 :011 > Dir.glob("?Oo")
 => []
2.2.1 :012 >
2.2.1 :013 >   Dir.glob("*", File::FNM_EXTGLOB)
 => ["Foo"]
2.2.1 :014 > Dir.glob('foO', File::FNM_EXTGLOB)
 => []
2.2.1 :015 > Dir.glob("F?O", File::FNM_EXTGLOB)
 => []
2.2.1 :016 > Dir.glob("F??", File::FNM_EXTGLOB)
 => ["Foo"]
2.2.1 :017 > Dir.glob("f??", File::FNM_EXTGLOB)
 => []
2.2.1 :018 > Dir.glob("fo?", File::FNM_EXTGLOB)
 => []
2.2.1 :019 > Dir.glob("Fo?", File::FNM_EXTGLOB)
 => ["Foo"]
2.2.1 :020 > Dir.glob("F?o", File::FNM_EXTGLOB)
 => ["Foo"]
2.2.1 :021 > Dir.glob("?oO", File::FNM_EXTGLOB)
 => []
2.2.1 :022 > Dir.glob("?oo", File::FNM_EXTGLOB)
 => ["Foo"]
2.2.1 :023 > Dir.glob("?Oo", File::FNM_EXTGLOB)
 => []
2.2.1 :024 >
2.2.1 :025 >   Dir.glob("*", File::FNM_CASEFOLD)
 => ["Foo"]
2.2.1 :026 > Dir.glob('foO', File::FNM_CASEFOLD)
 => []
2.2.1 :027 > Dir.glob("F?O", File::FNM_CASEFOLD)
 => ["Foo"]
2.2.1 :028 > Dir.glob("F??", File::FNM_CASEFOLD)
 => ["Foo"]
2.2.1 :029 > Dir.glob("f??", File::FNM_CASEFOLD)
 => ["Foo"]
2.2.1 :030 > Dir.glob("fo?", File::FNM_CASEFOLD)
 => ["Foo"]
2.2.1 :031 > Dir.glob("Fo?", File::FNM_CASEFOLD)
 => ["Foo"]
2.2.1 :032 > Dir.glob("F?o", File::FNM_CASEFOLD)
 => ["Foo"]
2.2.1 :033 > Dir.glob("?oO", File::FNM_CASEFOLD)
 => ["Foo"]
2.2.1 :034 > Dir.glob("?oo", File::FNM_CASEFOLD)
 => ["Foo"]
2.2.1 :035 > Dir.glob("?Oo", File::FNM_CASEFOLD)
 => ["Foo"]

I don’t understand why, but FNM_EXTGLOB is the way to go.

There are no upcases in Rails’ naming conventions, so this is an issue with folders outside of rails getting borked. Therefore, we only need to add the EXTGLOB flag where we could be getting those as results. It doesn’t seem to me that the Dir here needs it.

def find_template_paths(query)
      Dir[query].uniq.reject do |filename|
        File.directory?(filename) ||
          # deals with case-insensitive file systems.
          !File.fnmatch(query, filename, File::FNM_EXTGLOB)
      end
    end

FWIW, this was a problem for me in ruby 2.3.0, but not with 2.3.1… nearly all the same dependency versions including rails. Also, “use a mac” is a super dumb suggestion for a bugfix.

You might read this SO. Some of the people seem to have been able to simply rename the directory w/o changing the case. http://stackoverflow.com/questions/27871726/strange-error-in-rails-missing-helper/27909917#27909917

On Fri, Mar 6, 2015 at 11:14 PM, Sam Becker notifications@github.com wrote:

Same issue. Rails 4.2 and Ruby 2.2.0.

I recently switched from Unicorn to Puma which crashed soon after and then I restarted my computer. My app, which hasn’t had any serious issues in months, will no longer start. I don’t have my app in the Site folder, however, by following the logic above, it looks like my capitalized user or username folder is the culprit, i.e., /Users/Sam/rails/app_name

Do I really need to lowercase Sam here? I would really like to avoid that for obvious reasons. Is there no Rails or Ruby cache that can be cleared? This is now a permanently corrupt app?

— Reply to this email directly or view it on GitHub https://github.com/rails/rails/issues/18660#issuecomment-77672540.

I only changed the “sites” folder name then renamed it back and it work. I have seen people stating that they renamed the entire directory. It is not needed in my circumstance. Hope that helps.

mv sites sites1 mv sites1 sites