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
Can you please provide a sample application that reproduces the error?
I apparently can't be done, as when I rolled back to a previously-working
commit the error persisted.
On Fri, Jan 23, 2015 at 1:50 PM, Rafael Mendonça França <
[email protected]> wrote:
Can you please provide a sample application that reproduces the error?
—
Reply to this email directly or view it on GitHub
https://github.com/rails/rails/issues/18660#issuecomment-71243551.
Nicolás Waissbluth Razmilic
I've seen this reported several times in the #rubyonrails IRC channel over the last few weeks - haven't been able to pin down a cause.
I've had this problem intermittently since upgrading to Ruby 2.2.0 and Rails 4.2.0 (I'm on Yosemite). Renaming my directories to match case (as per http://stackoverflow.com/questions/27871726/strange-error-in-rails-missing-helper) solves the problem - until I reboot when the issue reappears as OS X re-capitalises a directory name.
Shot in the dark, but possibly related to: https://bugs.ruby-lang.org/issues/10700 ?
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.
Same error here after upgrading to rails 4.2.0
AbstractController::Helpers::MissingHelperError in HomesController#index
Missing helper file helpers//users/joel/sites
my sites folder is "Sites" capitalized
I think the issue is unrelated to rails, as I encountered the issue after upgrading our project to ruby 2.2.0 from ruby 2.1.2, NOT changing the rails version.
@etipton - the timing of that ruby issue https://bugs.ruby-lang.org/issues/10700 and the bug they are trying to fix exactly match. Looks like the guy tested against a Mac OSX machine that had a case sensitive file system (who does that??) and "fixed" his bug, but broke it for the rest of the world.
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
Yeah, this looks unrelated to Rails.
Looks like some other contributors have been digging into this and do think it's an issue in the Rails code-base.
here is a link to the SO, if that helps http://stackoverflow.com/questions/27871726/strange-error-in-rails-missing-helper/27909917#27909917
I'm going to close this because I can't seem to reproduce it - I think it maybe something to do with upgraded Mac OS X versions and the Sites folder capitalisation. The code where the error occurs is here:
def all_helpers_from_path(path)
helpers = Array(path).flat_map do |_path|
extract = /^#{Regexp.quote(_path.to_s)}\/?(.*)_helper.rb$/
names = Dir["#{_path}/**/*_helper.rb"].map { |file| file.sub(extract, '\1') }
names.sort!
end
helpers.uniq!
helpers
end
The path
argument is an array of helper folders - in a new application this is just <root>/app/helpers
. It looks as though Dir[]
is returning case-insensitive matches as described in the Ruby bug and then the extract
regexp doesn't match, leaving the full path in the names
array rather than application
, etc. This then blows up when the application tries to load the helpers.
I've tried to reproduce this on both case sensitive and insensitive file systems.
So... the ruby documentation for Dir.glob(pattern, [flags]) says "Note that this pattern is not a regexp, it’s closer to a shell glob. See File.fnmatch for the meaning of the flags parameter. Note that case sensitivity depends on your system (so File::FNM_CASEFOLD is ignored)"
So although it SEEMS cut-and-dry that the extract pattern will exist in the returned filename, it's actually NOT guaranteed, due to potential case-sensitivity differences. Seems to me like the fix belongs in that method, and that it should do something like:
Dir["#{_path}/**/*_helper.rb"].map { |file| file.sub(extract, '\1') if file =~ extract }.compact
(not fully tested)
Thoughts?
I don't have the ability to reopen this but that Ruby documentation makes me think that this situation should actually be handled by Rails.
btw, great detective work @pixeltrix
Without some steps to repro I'm loathe to change anything - however the logic could be improved which is probably why @matthewd just assigned himself this :smile:
We haven't found a way to prove it :confused:, but I remain of the opinion that the current code is Technically Wrong. (It also just doesn't seem like the nicest way of solving the problem, really.)
I'll "fix" the sub
, and we can assume it'll make this go away, whatever it was.
@etipton I don't think your fix will work because it will miss out helpers - the problem is mismatched case on the application root
Oh, right... damn. Maybe the extract regexp should just have a /i ?
I also agree that the way the whole thing works seems kinda wonky.
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?
* Ok, quick update in case anyone cares, just fixed this issue by renaming the enclosing folder rails
which had always been lowercase to a new name and then back to rails
, not sure how cases played into my issue, if at all *
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 [email protected]
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_nameDo 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.
Ran into the same issue - Rails 4.2 and Ruby 2.2. By renaming the sites folder to another name and renaming it back to sites solved the issue for me. Thanks @robmathews
@raarellano You're Welcome!
I have a reproduction for this now - essentially the config.ru path passed to Rack::Builder
is the wrong case and the problem cascades from there. It can happen in a number of ways - wrong case on symlink for pow, messed capitalisation with Sites folder but the fix should probably go there.
What is the "wrong case"? Is it mixed case and should be downcased? That would probably not work on the case sensitive systems ...
Thanks for tracking this down @pixeltrix!
I ran into this problem because I had the wrong case on symlink for pow (~/sites/example
instead of ~/Sites/example
) and it was tricky to track down because pow fails with a cryptic error Error: unknown process error
and I was only able to see the underlying problem by wrapping initialize!
in config/environment.rb
in a rescue block like so:
# Initialize the rails application
begin
Example::Application.initialize!
rescue Exception => e
raise e.inspect
end
Note also that I wasn't able to call e.backtrace
here for some reason, and needed to call e.backtrace.first(10)
instead, which is bizarre and may explain why pow is crashing hard.
I'll leave some hints behind for future Googlers on pow issues like: https://github.com/basecamp/pow/issues/30 and https://github.com/basecamp/pow/issues/411
@robmathews I think the best solution would be to correct the capitalization (convert ~/sites/example
instead of ~/Sites/example
before passing that to Rack::Builder
) to avoid this issue entirely. We could also consider failing fast with a helpful message, but if we're explaining the problem, I suppose we might as well correct it if we think we can.
@trevor - If we downcased it ( ~/Sites/example => ~/sites/example ),
wouldn't it fail when it tried to load the helper via
"/users/rob/sites/example/app/helpers/application_helper.rb" on on a
case-sensitive unix file system, like ubuntu? Unless I'm missing something,
the problem is more subtle than that ... is there a file and line number in
Rack::Builder that I should read? And yes, I'd be down with trying to
correct it.
On Thu, Apr 23, 2015 at 9:54 AM, Trevor Turk [email protected]
wrote:
Thanks for tracking this down @pixeltrix https://github.com/pixeltrix!
I ran into this problem because I had the wrong case on symlink for pow (
~/sites/example instead of ~/Sites/example) and it was tricky to track
down because pow fails with a cryptic error Error: unknown process error
and I was only able to see the underlying problem by wrapping initialize!
in config/environment.rb in rescue blocks like so:Initialize the rails applicationbegin
Example::Application.initialize!rescue Exception => e
raise e.inspectendI'll leave some hits behind for future Googlers on pow issues like:
basecamp/pow#30 https://github.com/basecamp/pow/issues/30@robmathews https://github.com/robmathews I think the best solution
would be to correct the capitalization (convert ~/sites/example instead
of ~/Sites/example before passing that to Rack::Builder) to avoid this
issue entirely. We could also consider failing fast with a helpful message,
but if we're explaining the problem, I suppose we might as well correct it.—
Reply to this email directly or view it on GitHub
https://github.com/rails/rails/issues/18660#issuecomment-95593625.
@robmathews :sparkles: :bowtie: :sparkles:
@robmathews the problem is that eval
is passed a path that is the not the actual case. This affects the output of the __FILE__
constant amongst other things, e.g.:
>> eval "__FILE__", TOPLEVEL_BINDING, '/foo/bar'
=> "/foo/bar"
and since File.expand_path
doesn't correct the case all of the paths generated this way will end up with the incorrect case. This problem existed before but since Ruby 2.2 Dir.glob
returns the paths with the correct case (which is the right thing to do) then the regex doesn't match,
As @trevor says the correct way to fix this is to make sure that Rack::Builder
uses the correct case - I'm investigating the best way to make that happen.
@pixeltrix :sparkles: :bowtie: :sparkles:
Hi guys, I had the same issue right now, but now it's solved. I'm using OS X Yosemite 10.10.3 and my partition is _Mac OS Extended (Journaled)_ (not case sensitive).
The folder used was Development
(capitalized) and the path below was having the same error as the issue:
/Users/username/Development/folder/projectfolder/app/helpers/application_helper.rb
Ruby was trying to find a path like this (with Development
in downcase):
/Users/username/development/folder/projectfolder/app/helpers/application_helper.rb
After the rename of the Development
folder to development
, everything went back to normal.
That's great, @jhonnymoreira, and hopefully other people running into this issue will find this thread and be able to fix things themselves. Still, it would be ideal if we could proactively correct the case as @pixeltrix suggested for the many people likely to encounter this issue in the future.
The problem is that there doesn't seem to be a way to normalise the case of the path without doing something like this:
>> Dir['/users/andyw/code/testapp'].first
=> "/Users/andyw/Code/testapp"
nothing else seems to work because as @matthewd pointed out this change was a last minute fix to Ruby 2.2 so it's only a change in Dir.glob
code. I think we need to not rely on the path passed to Rack::Builder
as Dir.pwd
seems to return the correctly-cased path.
@pixeltrix Any update on this? I can confirm that your fix/patch works. Will this be added to the next release?
Changing the case worked for me too - I had rspec
issues throwing the error as described. My app had a capitalised folder name. Thankfully, I found this thread and was able to change the folder name. All works with no problem. I'm using Mac Yosemite with Rails 4.2.1 and Ruby 2.2.1p85.
Thanks to all for posting this solution.
Possibly useful data. This:
ruby -- /Users/MichaelBlank/Documents/learn/wikipages/bin/rails s
works.
This:
ruby -- bin/rails s
fails.
Had the same issue and it was because of case sensitivity of folder names.
~/documents/myproject did not work
~/Documents/MyProject worked
I’m slightly confused on whether this is considered to be an expected change in Ruby’s API or indeed a bug? Who should fix this? Even more, I would expect to find an issue reported in Ruby’s Core for a five month old issue, but I can’t seem to find one?
I have this problem when setting up my new OSX. One thing I noticed is that the problematic folder is created by dropbox. I didn't have this issue with folders created through command line locally, so I guess this issue might be related to file system and the way this sync tool maintaining folder names.
This SO does help https://stackoverflow.com/questions/27871726/strange-error-in-rails-missing-helper/27909917#27909917 .
Both the fix in 7b1a6c3 or reverting to Ruby 2.1.6 resolve this issue.
Just ran into this issue as well. Changed case, solved the issue.
Kudos to @shunwen for the SO link. :+1:
Might be unrelated but this issue didn't occur to me until I upgrade Xcode to version 6.4
Just hit this issue.
$ mv projects/ projects1/
$ mv projects1/ projects/
Fixed it per the SO link.
I had previously renamed Projects/ to projects/ which seemed fine until I restarted. (May be unrelated.)
rbenv 0.4.0
Rails 4.2.3
ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-darwin13]
OS X 10.9.5
I use Nginx/Passenger and simple changing root path in nginx site config to downcase fixed the problem for me. No need to rename the folders.
im having the same issue but its not a case sensitive problem for me, i noticed that the ending tag was a doubled up (helpers//Users/xxxx/Sites/xxxx/app/helpers/application_helper.rb_helper.rb) there is 2 (_helper.rb_helper.rb) so i took one of them off and it works but causes other problems. is anyone else having this problem?
I had this issue with an umlaut in a path, renaming back and forth fixed this.
$ mv Kytkemö/ Kytkemo/
$ mv Kytkemo/ Kytkemö/
I had this problem again, renaming was not helping but rebooting solved the problem.
Actually, scratch the previous. A restart will return the issue. Sigh.
I've been bitten by this twice in the last week.
There are a lot of SO threads on this, but they either have case-sensitive file systems or the fix is renaming folders to be lowercase, which is a really user-hostile solution (and a mind-boggling one since it's a case-insensitive file system).
If we're all renaming our folders to all-lowercase, then I fear for what's next. 8-character uppercase filenames? Shallow limits on directory depth like with Node on Windows? We're humans and we need human-readable folder names.
I've no idea how I fixed this on the first machine with the first project, but now it's back again for the second project on the second machine. Just my luck.
FWIW, this is my pwd
:
/Users/Kristaps/Sites/Jaunā teika/jaunateika
and this is my File.expand_path ("./")
:
"/Users/Kristaps/Sites/Jaunā teika/jaunateika"
and here's the trace from WEBrick (via rails server
) — note the wrong case in path:
=> Booting WEBrick
=> Rails 4.2.4 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
[2015-09-06 23:50:53] INFO WEBrick 1.3.1
[2015-09-06 23:50:53] INFO ruby 2.2.3 (2015-08-18) [x86_64-darwin15]
[2015-09-06 23:50:53] INFO WEBrick::HTTPServer#start: pid=99606 port=3000
Started GET "/" for 127.0.0.1 at 2015-09-06 23:51:07 +0300
AbstractController::Helpers::MissingHelperError (Missing helper file helpers//users/kristaps/sites/jaunā teika/jaunateika/app/helpers/application_helper.rb_helper.rb):
actionpack (4.2.4) lib/abstract_controller/helpers.rb:151:in `rescue in block in modules_for_helpers'
actionpack (4.2.4) lib/abstract_controller/helpers.rb:148:in `block in modules_for_helpers'
actionpack (4.2.4) lib/abstract_controller/helpers.rb:144:in `map!'
actionpack (4.2.4) lib/abstract_controller/helpers.rb:144:in `modules_for_helpers'
actionpack (4.2.4) lib/action_controller/metal/helpers.rb:93:in `modules_for_helpers'
actionpack (4.2.4) lib/abstract_controller/helpers.rb:108:in `helper'
actionpack (4.2.4) lib/action_controller/railties/helpers.rb:17:in `inherited'
railties (4.2.4) lib/rails/application_controller.rb:1:in `<top (required)>'
activesupport (4.2.4) lib/active_support/dependencies.rb:274:in `require'
activesupport (4.2.4) lib/active_support/dependencies.rb:274:in `block in require'
activesupport (4.2.4) lib/active_support/dependencies.rb:240:in `load_dependency'
activesupport (4.2.4) lib/active_support/dependencies.rb:274:in `require'
railties (4.2.4) lib/rails/welcome_controller.rb:1:in `<top (required)>'
activesupport (4.2.4) lib/active_support/inflector/methods.rb:263:in `const_get'
activesupport (4.2.4) lib/active_support/inflector/methods.rb:263:in `block in constantize'
activesupport (4.2.4) lib/active_support/inflector/methods.rb:259:in `each'
activesupport (4.2.4) lib/active_support/inflector/methods.rb:259:in `inject'
activesupport (4.2.4) lib/active_support/inflector/methods.rb:259:in `constantize'
activesupport (4.2.4) lib/active_support/dependencies.rb:566:in `get'
activesupport (4.2.4) lib/active_support/dependencies.rb:597:in `constantize'
actionpack (4.2.4) lib/action_dispatch/routing/route_set.rb:72:in `controller_reference'
actionpack (4.2.4) lib/action_dispatch/routing/route_set.rb:62:in `controller'
actionpack (4.2.4) lib/action_dispatch/routing/route_set.rb:41:in `serve'
actionpack (4.2.4) lib/action_dispatch/journey/router.rb:43:in `block in serve'
actionpack (4.2.4) lib/action_dispatch/journey/router.rb:30:in `each'
actionpack (4.2.4) lib/action_dispatch/journey/router.rb:30:in `serve'
actionpack (4.2.4) lib/action_dispatch/routing/route_set.rb:821:in `call'
rack (1.6.4) lib/rack/etag.rb:24:in `call'
rack (1.6.4) lib/rack/conditionalget.rb:25:in `call'
rack (1.6.4) lib/rack/head.rb:13:in `call'
actionpack (4.2.4) lib/action_dispatch/middleware/params_parser.rb:27:in `call'
actionpack (4.2.4) lib/action_dispatch/middleware/flash.rb:260:in `call'
rack (1.6.4) lib/rack/session/abstract/id.rb:225:in `context'
rack (1.6.4) lib/rack/session/abstract/id.rb:220:in `call'
actionpack (4.2.4) lib/action_dispatch/middleware/cookies.rb:560:in `call'
activerecord (4.2.4) lib/active_record/query_cache.rb:36:in `call'
activerecord (4.2.4) lib/active_record/connection_adapters/abstract/connection_pool.rb:653:in `call'
activerecord (4.2.4) lib/active_record/migration.rb:377:in `call'
actionpack (4.2.4) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
activesupport (4.2.4) lib/active_support/callbacks.rb:88:in `__run_callbacks__'
activesupport (4.2.4) lib/active_support/callbacks.rb:778:in `_run_call_callbacks'
activesupport (4.2.4) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (4.2.4) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (4.2.4) lib/action_dispatch/middleware/reloader.rb:73:in `call'
actionpack (4.2.4) lib/action_dispatch/middleware/remote_ip.rb:78:in `call'
actionpack (4.2.4) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
web-console (2.2.1) lib/web_console/middleware.rb:39:in `call'
actionpack (4.2.4) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
railties (4.2.4) lib/rails/rack/logger.rb:38:in `call_app'
railties (4.2.4) lib/rails/rack/logger.rb:20:in `block in call'
activesupport (4.2.4) lib/active_support/tagged_logging.rb:68:in `block in tagged'
activesupport (4.2.4) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (4.2.4) lib/active_support/tagged_logging.rb:68:in `tagged'
railties (4.2.4) lib/rails/rack/logger.rb:20:in `call'
actionpack (4.2.4) lib/action_dispatch/middleware/request_id.rb:21:in `call'
rack (1.6.4) lib/rack/methodoverride.rb:22:in `call'
rack (1.6.4) lib/rack/runtime.rb:18:in `call'
activesupport (4.2.4) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
rack (1.6.4) lib/rack/lock.rb:17:in `call'
actionpack (4.2.4) lib/action_dispatch/middleware/static.rb:116:in `call'
rack (1.6.4) lib/rack/sendfile.rb:113:in `call'
railties (4.2.4) lib/rails/engine.rb:518:in `call'
railties (4.2.4) lib/rails/application.rb:165:in `call'
rack (1.6.4) lib/rack/lock.rb:17:in `call'
rack (1.6.4) lib/rack/content_length.rb:15:in `call'
rack (1.6.4) lib/rack/handler/webrick.rb:88:in `service'
/usr/local/var/rbenv/versions/2.2.3/lib/ruby/2.2.0/webrick/httpserver.rb:138:in `service'
/usr/local/var/rbenv/versions/2.2.3/lib/ruby/2.2.0/webrick/httpserver.rb:94:in `run'
/usr/local/var/rbenv/versions/2.2.3/lib/ruby/2.2.0/webrick/server.rb:294:in `block in start_thread'
Rendered /usr/local/var/rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/actionpack-4.2.4/lib/action_dispatch/middleware/templates/rescues/_source.erb (6.5ms)
Rendered /usr/local/var/rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/actionpack-4.2.4/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb (4.7ms)
Rendered /usr/local/var/rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/actionpack-4.2.4/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb (16.5ms)
Rendered /usr/local/var/rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/actionpack-4.2.4/lib/action_dispatch/middleware/templates/rescues/diagnostics.html.erb within rescues/layout (123.9ms)
Rendered /usr/local/var/rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/web-console-2.2.1/lib/web_console/templates/_markup.html.erb (0.5ms)
Rendered /usr/local/var/rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/web-console-2.2.1/lib/web_console/templates/_inner_console_markup.html.erb within layouts/inlined_string (0.4ms)
Rendered /usr/local/var/rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/web-console-2.2.1/lib/web_console/templates/_prompt_box_markup.html.erb within layouts/inlined_string (0.4ms)
Rendered /usr/local/var/rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/web-console-2.2.1/lib/web_console/templates/style.css.erb within layouts/inlined_string (0.6ms)
Rendered /usr/local/var/rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/web-console-2.2.1/lib/web_console/templates/console.js.erb within layouts/javascript (91.5ms)
Rendered /usr/local/var/rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/web-console-2.2.1/lib/web_console/templates/main.js.erb within layouts/javascript (0.4ms)
Rendered /usr/local/var/rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/web-console-2.2.1/lib/web_console/templates/error_page.js.erb within layouts/javascript (0.6ms)
Rendered /usr/local/var/rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/web-console-2.2.1/lib/web_console/templates/index.html.erb (206.9ms)
@kausters For some this is a case sensitive problem, for me this is ended up being a UTF8 problem. You have a UTF8-character in your path. Try to move your project out of Jaunā teika
and start the server. This has “fixed” the issue for me.
Nevertheless, I don’t understanding where the root cause is. Is this expected Ruby behaviour or is this a bug in Ruby? Where is the bug report? I’ve encountered similar issues with other gems and I presume the cause is the same. Nevertheless, this issue should be fixed since it’s absolutely ridiculous to demand lowercase or ASCII directory names for international users...
@kasper Exactly. I've seen a bunch of complaints and a bunch of people saying that it's fixed after Ruby 2.2.0, but no it is not. On the first project it most probably was a case issue (on a case-insensitive file system nevertheless) and the second one (Jaunā teika
) it probably is the UTF8 symbol and/or the case, but this is just silly having such a problem randomly appearing in 2015.
@kausters In fact, this breaking change happened after 2.1.6. I’ve tested this against 2.1.6 and it works fine. All subsequent versions have this issue. I’ve also tested the patch-branch related to this issue and it also fixes the issue.
@kasper Wow, just found the patch branch. I wonder why it hasn't been merged.
@kausters It seems there’s general confusion in where this problem originates. Neither is there any kind of official decision about this issue. (cc @matthewd)
We know we want something along the lines of 7b1a6c3cf1eebe0609f72428b6b76c7d838d1e31, but that change is failing tests.
If anyone wants to take that, rebase it, and get it working properly, a PR would be very welcome.
We tried changing directory. No success.
We tried the following rubies:
rvm list
* ruby-2.1.5 [ x86_64 ]
=> ruby-2.1.6 [ x86_64 ]
ruby-2.2.1 [ x86_64 ]
What did work for us is to disable eager_load in our production.rb file:
config.eager_load = false
We are on FreeBSD 10.0
What I did, since I use Pow, was move the source code into the actual ~/.pow directory, and symlink _that_ into my work directory. It works, but feels so stupid.
I'm seeing this too.
Rails (4.2.4) is looking for a downcased path (my path is mixed case). This started occurring after a recent XCode upgrade from 7.0 beta 3 to beta 6 (7A192o).
+1 after upgrading XCode.
Solved renaming the rails project parent folder to downcase.
Note: the output from irb File.expand_path("./") and pwd were exactly the same.
Even with path lowercased, I'm still having issues when using Passenger 5 as a server. Webrick seems to work fine.
Solved on my machine (Ruby 2.2.3, Rails 4.2.3) with the solution @robmathews had posted a while back: http://stackoverflow.com/questions/27871726/strange-error-in-rails-missing-helper/27909917#27909917
You see the difference from Turing
to turing
in the file path. I just renamed the folder, then renamed it back, and the problem was solved.
mv turing turing_temp
mv turing_temp turing
Thanks for all the postings, guys! Wouldn't have figured it out without you :)
Note the file path change does more than just the case change. In this lookup, FundRX is being underscored:
Missing helper file helpers//users/fny/documents/organizations/fund_rx/websites/core/app/helpers/application_helper.rb_helper.rb:
Original path: /Users/fny/Documents/Organizations/FundRX/websites/core
"Organizations/FundRX/websites".underscore == "organizations/fund_rx/websites" # => true
Just restarted my computer for the first time in a long time. Now I'm getting this error:
Missing helper file helpers//users/brenner_spear/work/gramercy_app/app/helpers/application_helper.rb_helper.rb (AbstractController::Helpers::MissingHelperError)
my path is:
/Users/BrennerSpear/work/gramercyapp
for some reason, it's downcasing everything, and switching Camel-case to underscores, just like @fny pointed out. But wait, gramercyapp
isn't camel-cased? why is it underscoring it?
Because in finder, it's displayed as GramercyApp
.
I changed it to all undercase, and now it's working. For now...
I had a similar problem, /Users/nicoleanselmo/Desktop/Dev/createHER/the-mission/app/helpers
I had to change the directory names Desktop, Dev, createHER and the-mission so that there were no capital letters or any other characters:
/Users/nicoleanselmo/desktop/dev/createher/themission/app/helpers
I did not have to reboot in order to get my server to run after renaming the directories.
Had the same problem! Renaming the directory to something else and re-renaming it to whatever name you want to use (all in lowercase) fixed it
I am getting this same error. My actual path is:
"C:/Users/Darren/desktop/dev/bookio"
But this is what is "missing" according to the message:
"Missing helper file helpers/c:/users/darren/desktop/dev/bookio/app/helpers/application_helper.rb_helper.rb"
So it's looking for something with every directory lowercased.
I am on a Windows machine, running Windows 10.
Any solutions? I have tried renaming directories and the app name, and changing back. But nothing's working.
Is there a patch that can be used? Any other ideas as to solutions?
I hate to say this ... but the patch is to get a Mac. I've tried using the
Rails on Windows, and you keep getting strange problems with virtually no
support from the community. The reason is simple: we're all using Macs. So,
you can fight it, or join. I gave up and joined, really haven't regretted
it.
On Sun, Dec 20, 2015 at 3:03 AM, darrenbrett [email protected]
wrote:
I am getting this same error. My actual path is:
"C:/Users/Darren/desktop/dev/bookio"But this is what is "missing" according to the message:
"Missing helper file
helpers/c:/users/darren/desktop/dev/bookio/app/helpers/application_helper.rb_helper.rb"So it's looking for something with every directory lowercased.
I am on a Windows machine, running Windows 10.
Any solutions? I have tried renaming directories and the app name, and
changing back. But nothing's working.Is there a patch that can be used? Any other ideas as to solutions?
—
Reply to this email directly or view it on GitHub
https://github.com/rails/rails/issues/18660#issuecomment-166080782.
Mac or run Linux. Both are easy to work with Ruby/Rails on. I’ve never tried using a Windows machine but the people I know who have constantly run into problems. Not saying it can’t be done, it’s just not a Ruby/Rails friendly operating system.
Why not use virtual box on Windows 10 to create a VM with Ubuntu and use that as a development environment? Problem solved.
On Dec 20, 2015, at 9:06 AM, rob mathews [email protected] wrote:
I hate to say this ... but the patch is to get a Mac. I've tried using the
Rails on Windows, and you keep getting strange problems with virtually no
support from the community. The reason is simple: we're all using Macs. So,
you can fight it, or join. I gave up and joined, really haven't regretted
it.On Sun, Dec 20, 2015 at 3:03 AM, darrenbrett [email protected]
wrote:I am getting this same error. My actual path is:
"C:/Users/Darren/desktop/dev/bookio"But this is what is "missing" according to the message:
"Missing helper file
helpers/c:/users/darren/desktop/dev/bookio/app/helpers/application_helper.rb_helper.rb"So it's looking for something with every directory lowercased.
I am on a Windows machine, running Windows 10.
Any solutions? I have tried renaming directories and the app name, and
changing back. But nothing's working.Is there a patch that can be used? Any other ideas as to solutions?
—
Reply to this email directly or view it on GitHub
https://github.com/rails/rails/issues/18660#issuecomment-166080782.—
Reply to this email directly or view it on GitHub https://github.com/rails/rails/issues/18660#issuecomment-166126085.
Probably won’t make much of a difference since this problem (first) originated on OS X and is caused by a change in Ruby.
@darrenbrett There was a patch, see 7b1a6c3, but it needed work and was never accepted as the fix.
Yes, I do think moving to a Mac is in my future. But for now it looks like I'll have to revert to running Ruby 1.9 with Rails 4.2.5, as I was having no problems with that setup on my Windows machine. Just kind of annoying that I don't then have access to all the latest gems.
I'm still having this issue. Any movement?
I have the same issue but renaming the folder to lowercase didn't help. I am switching from ruby-2.1.4 to ruby-2.3.0.
Just got this and changed "application_helper.rb"
to "application_helper.rb_helper.rb"
in my app/helpers folder and it works
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.
No, it's not really a "super dumb suggestion", just a reflection of the
development community in Rails, at least here in Boston. You can denigrate
it, or realize it's just pragmatic advice unless you are one of those
stubborn souls who enjoys debugging obscure configuration and environment
issues alone with minimal help from the developer community. More power to
you if you are.
On Mon, May 2, 2016 at 4:03 PM, aharpervc [email protected] wrote:
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 are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
https://github.com/rails/rails/issues/18660#issuecomment-216345913
I spoke too soon, this regex is definitely not working as expected https://github.com/rails/rails/blob/4-0-stable/actionpack/lib/action_controller/metal/helpers.rb#L95
The regex literal matches okay in the debugger, but extract
doesn't match that same file path. Then there's no sub
action, and the full path (rather than the helper name) is leaking through. Probably something obvious I'm missing... not sure...
Ah, that extract
regex needs to be case insensitive. That seems to reliably fix the regex not matching when it ought.
Depends on the file system. If the file system is case insensitive, then
yes. But if it is case sensitive, then that would be a bug.
OSX can be either - here's a reference
http://apple.stackexchange.com/questions/71357/how-to-check-if-my-hd-is-case-sensitive-or-not
And I think if you read the original checkin/issue comment, it was exactly
around fixing that for case sensitive file systems.
On Mon, May 2, 2016 at 5:49 PM, aharpervc [email protected] wrote:
Ah, that extract regex needs to be case insensitive. That seems to
reliably fix the regex not matching when it ought.—
You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
https://github.com/rails/rails/issues/18660#issuecomment-216374223
I agree the return result from this method should preserve the original case of the helper. However, the regex test to match whether a file is a helper should not be case sensitive regardless of file system. Otherwise it will fail to match valid helpers when the left part of the path differs in case. This is the behavior described in this thread. Even worse, the failure mode is to return the whole file path. That can't possibly be the desired behavior for this method.
Ok, crossposting from #24821
So we have:
A) case sensitive systems
vs
B) case insensitive systems
::::
1) _path is cased differently than some result from Dir[]
vs
2) _path is cased the same as some result from Dir[]
::::
What we need to figure out is if we have a match based off of those situations.
A1 -> not a match
A2 -> match
B1 -> match
B2 -> match
::::
So how do you determine case sensitivity?
Ruby gives you:
File::FNM_SYSCASE
But I get the same result, 0
on my case insensitive OSX filesystem as I do on my case sensitive Ubuntu server, so looking further, HAVE_HFS
exists in Dir.c, etc
, which is set by the existance of __APPLE__
and is used for these kinds of checks, but is not available outside of that as far as I can see. We could have
(File::FNM_SYSCASE > 0) || ((RUBY_PLATFORM =~ /darwin/).to_i > 0)
Which could be tucked in it's own method and then stubbed in a test.
sound good?
::::
So thinking about this more, can we do an end run around this?
all_helpers_from_path
is only used here:
https://github.com/rails/rails/search?utf8=%E2%9C%93&q=all_helpers_from_path
https://github.com/rails/rails/blob/master/railties/lib/rails/engine.rb#L489
it feeds modules_for_helpers
which is used here:
https://github.com/rails/rails/search?utf8=%E2%9C%93&q=modules_for_helpers
https://github.com/rails/rails/blob/master/actionpack/lib/abstract_controller/helpers.rb#L109
https://github.com/rails/rails/blob/master/railties/lib/rails/engine.rb#L490
in helpers.rb
it is used to drive the controller helper method: helper :something
, so it expects to slap a _helper.rb
to the string or symbol and then load that file.
:::
So the glob is looking for _helper.rb
files in the path and all we need is the basename without the _helper.rb
.
we could turn:
def all_helpers_from_path(path)
helpers = Array(path).flat_map do |_path|
extract = /^#{Regexp.quote(_path.to_s)}\/?(.*)_helper.rb$/
names = Dir["#{_path}/**/*_helper.rb"].map { |file| file.sub(extract, '\1') }
names.sort!
end
helpers.uniq!
helpers
end
into
def all_helpers_from_path(path)
helpers = Array(path).flat_map do |_path|
Dir["#{_path}/**/*_helper.rb"].map! { |file| File.basename(file, "_helper.rb") }.sort!
end
helpers.uniq!
helpers
end
And we could forget about case sensitivity entirely!
This may also need to be addressed, I think it's possible for templates to be rejected incorrectly:
https://github.com/rails/rails/blob/master/actionview/lib/action_view/template/resolver.rb#L231
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
@xn clever.... I'll apply that approach locally & give it a try
As far as !File.fnmatch(query, filename, File::FNM_EXTGLOB)
goes, I can't see how that protects against case insensitive filesystems. As far as I understand it, File::FNM_EXTGLOB
simply turns on parsing for this: {a,b}
, I cannot imagine query
to be written in such a way to accommodate that.
@tenderlove, I see you wrote that code here: https://github.com/rails/rails/commit/727ae97793906926fe0e87ec2f105fa47fd6d783#diff-40f2a5bcf9edfd65a8efe42a05c53736
Have a second to chime in?
@darrenbrett can you run this without errors?
Dir.chdir ENV['TEMP']
TMPDIR = Time.now.strftime('%Y%m%d_%H%M%S_delete')
Dir.mkdir(TMPDIR)
Dir.chdir(TMPDIR)
TMPFN = 'Foo'
File.open(TMPFN, 'w') {}
raise 'should return ["Foo"]' if Dir.glob('*') != ["Foo"]
raise 'should return ["Foo"]' if Dir.glob('f?O') != ["Foo"]
raise 'should return ["Foo"]' if Dir.glob('foO') != ["Foo"]
raise 'should return ["Foo"]' if Dir['foO'] != ["Foo"]
raise 'should return ["Foo"]' if Dir.glob('foO', File::FNM_CASEFOLD) != ["Foo"]
raise 'should return ["Foo"]' if Dir.glob('foO', File::FNM_EXTGLOB) != ["Foo"]
File.delete(TMPFN)
Dir.delete(File.join('..', TMPDIR))
@xn I ran the code you gave on my MacBook, OSX 10.10.5 with Ruby 2.3.1 and Rails 2.4.6. I only had an issue with raise 'should return ["Foo"]' if Dir.glob('f?O') != ["Foo"]
.
@dhagerty did you run them individually? What was the return value of that line? Sorry for not codng something a bit more savvy. BTW, do you have a. Cade sensitive file system?
@xn I did run them individually, here's my output:
irb(main):015:0> raise 'should return ["Foo"]' if Dir.glob('f?O') != ["Foo"]
RuntimeError: should return ["Foo"]
from (irb):15
from /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-4.2.6/lib/rails/commands/console.rb:110:in `start'
from /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-4.2.6/lib/rails/commands/console.rb:9:in `start'
from /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:68:in `console'
from /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
from /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-4.2.6/lib/rails/commands.rb:17:in `<top (required)>'
from /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:274:in `require'
from /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:274:in `block in require'
from /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:240:in `load_dependency'
from /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:274:in `require'
from /Users/david/code/ruby/test-app/bin/rails:9:in `<top (required)>'
from /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:268:in `load'
from /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:268:in `block in load'
from /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:240:in `load_dependency'
from /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:268:in `load'
from /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /usr/local/opt/rbenv/versions/2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from -e:1:in `<main>'
Running just Dir.glob('f?O')
returns an empty array.
irb(main):003:0> Dir.glob("f?O")
=> []
Here is relevant information on my file system:
File System Personality: Journaled HFS+
Type (Bundle): hfs
Name (User Visible): Mac OS Extended (Journaled)
Journal: Journal size 24576 KB at offset 0x11502000
It isn't case-sensitive.
So there seems to be some unexpected behavior here, unless there's something I'm missing. Because Dir.glob
will return ["Foo"]
in all the other cases you provided. Here's some output from other variations I've tried (along with a few control cases):
irb(main):004:0> Dir.glob("*")
=> ["Foo"]
irb(main):005:0> Dir.glob('foO')
=> ["Foo"]
irb(main):006:0> Dir.glob("F?O")
=> []
irb(main):007:0> Dir.glob("F??")
=> ["Foo"]
irb(main):008:0> Dir.glob("f??")
=> []
irb(main):009:0> Dir.glob("fo?")
=> []
irb(main):010:0> Dir.glob("Fo?")
=> ["Foo"]
irb(main):012:0> Dir.glob("F?o")
=> ["Foo"]
irb(main):013:0> Dir.glob("?oO")
=> []
irb(main):014:0> Dir.glob("?oo")
=> ["Foo"]
irb(main):015:0> Dir.glob("?Oo")
=> []
I'm not sure if I'm missing something, but all of those should return ["Foo"]
due to my case-insensitive file system.
Does CASEFOLD or EXTGLOB change any of that?
@christian
Works in OSX case-insensitive.
On ubuntu, it has errors, like in this gist:
https://gist.github.com/20c491b1011840fba32219d912f77084
Rails 4.2.6 in all cases.
HTH
On Thu, May 5, 2016 at 5:06 PM, Christian Trosclair <
[email protected]> wrote:
@darrenbrett https://github.com/darrenbrett can you run this without
errors?Dir.chdir ENV['TEMP']
TMPDIR = Time.now.strftime('%Y%m%d_%H%M%S_delete')
Dir.mkdir(TMPDIR)
Dir.chdir(TMPDIR)TMPFN = 'Foo'
File.open(TMPFN, 'w') {}raise 'should return ["Foo"]' if Dir.glob('*') != ["Foo"]
raise 'should return ["Foo"]' if Dir.glob('f?O') != ["Foo"]
raise 'should return ["Foo"]' if Dir.glob('foO') != ["Foo"]
raise 'should return ["Foo"]' if Dir['foO'] != ["Foo"]
raise 'should return ["Foo"]' if Dir.glob('foO', File::FNM_CASEFOLD) != ["Foo"]
raise 'should return ["Foo"]' if Dir.glob('foO', File::FNM_EXTGLOB) != ["Foo"]File.delete(TMPFN)
Dir.delete(File.join('..', TMPDIR))—
You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
https://github.com/rails/rails/issues/18660#issuecomment-217279552
@xn Both CASEFOLD and EXTGLOB fix the issues.
we need to see if everything works correctly on Linux with CASEFOLD and EXTGLOB. If it does, that code should be fine and we can just fix all_helpers_from_path
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
I tried everything and nothing worked except these simple instructions http://quick.as/yvyqsn7j
I'm hitting this right now with codetriage/codetriage. Crazy thing is if I clone into a new directory and set it up, it runs fine (shrug)
I noticed that in git bash i go to the location by not capitalizing my directories, that is 'c:/user/sites/whatever' and it seems to look at that capitalization. When I actually go to the directory to run the project by giving the proper capitalizations in git bash 'cd c:/Users/Sites/Whatever' and then run the project, it works fine
To be clear, this still hits me and I'm on OSX. @aharpervc, any chance to address this in your PR's?
@xn to be clear, you're saying https://github.com/rails/rails/pull/24821 is still broken for you, right, but your latest version of find_template_paths
does work?
Yes. I'm not yet on 5.0, so 4.2 is still broken for me.
Sorry, #24822 is still broken for me and my find_template_paths works.
I have the same problem with Ruby 2.2.3 and Rails 4.2.5.1.
All power and magic of RoR in one place.
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.
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
This happened to me suddenly after no _apparent_ system or dependency changes.
The SO fix worked for me:
mv reponame reponame1
mv reponame1 reponame
IN WINDOWS - SOLUTION
Example Folder Application:
Users/username/apps/blog
I was starting my folder application in bash all lowercase path. The correct is in windows use the folder Users with the first uppercase letter.
cd c:/Users/username/application/blog
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.
Just upgraded an app from Rails 4.x with Ruby 2.0.x to Rails 5.0.2 with Ruby 2.3.3 on Windows and i'm seeing this error on some machines with Windows Server 2016.
Strangely not all machines my machine had an uppercase letter in the directory. Other machines had an lowercase and i needed to rename to uppercase to work. Then another machine had just lowercase and needed to rename to uppercase. Another machine worked from the start.
Isn't there a known fix with ruby instead of wildly renaming directories?
Quite weird that this issue happens on macOS and Windows though Windows is always case-insensitive (unless maybe really weirdly configured to be which no one with a sane mind would dare).
I've now resorted to a monkey patch and added the "i" option to the RegEx.
With that the problem seems to go away. Which of course wouldn't work for people running case sensitive file systems. Although i don't know if they even see this issue.
module ActionController
module Helpers
module ClassMethods
def all_helpers_from_path(path)
helpers = Array(path).flat_map do |_path|
extract = /^#{Regexp.quote(_path.to_s)}\/?(.*)_helper.rb$/i # PATCH: just added the "i" option to the RegEx
names = Dir["#{_path}/**/*_helper.rb"].map { |file| file.sub(extract, '\1'.freeze) }
names.sort!
end
helpers.uniq!
helpers
end
end
end
end
Though my Rails app is starting up and working so far i noticed another side effect of the underlying problem.
In some Helpers and Models i have constants defined and i get "previously initialized constant..." warning for each and every Helper and Model because it seems to try and load them twice.
Once with lowercase and once with uppercase path. Not breaking anything just noise.
I could easily reproduce it by firing up a rails console in production environment on Windows Powershell by arbitrarily writing any letter in uppercase at "cd"
e.g.
PS C:\>cd railsapp
PS C:\railsapp>rails c production
works fine
while
PS C:\>cd Railsapp
PS C:\Railsapp>rails c production
will trigger complaining about constants
So i ended up removing the monkey patch.
From now on i have to keep in mind that ruby will treat any file system as case-sensitive.
So using uppercase letters is technically just fine. You just have to make sure you stick 100% to that and never type it differently.
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
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...
@IkarosAnastasios that did it for me on Windows 8 as well.
@Superpencil did you try the code I posted above at all?
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
@xn I did and it didn't work for me <3
What mechanism is changing dashes to underscores?
This may be a silly question. Why would anyone bend over backwards to do it like this anyway?
extract = /^#{Regexp.quote(_path.to_s)}\/?(.*)_helper.rb$/i
names = Dir["#{_path}/**/*_helper.rb"].map { |file| file.sub(extract, '\1'.freeze) }
You know exactly what prefix and suffix you want to strip and the glob will ensure that every file starts and ends with them. It is easier, cleaner, and more efficient to strip them by length than it is to build a pattern (which doesn't even work properly on every file system):
suffix = "_helper.rb"
names = Dir["#{_path}/**/*#{suffix}"].map { |file| file[(_path.size+1) .. -(suffix.size+1)] }
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.
It it normal that this thread is still relevant in 2018? Never had an issue
like this with any other framework, as much as I enjoy Rails.
In my case I just copy-pasted files file-per-file into a new project and it
worked great. Switched to Node not too long after.
On June 17, 2018 at 5:04:32 PM, Frank ([email protected]) wrote:
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.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/rails/rails/issues/18660#issuecomment-397915324, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AAzXrPXCcwTDSJD7IaElyBG_yDUr02n4ks5t9u6OgaJpZM4DWdjI
.
Probably time to nuke this one.
Had same problem with ruby 2.3.3, 'rails', '4.1.9' on Windows 10 Pro newly setup system. Never had issue before with same app.
Solved issue but correcting case in cmd.exe window from
C:\projects\app
to
C:\Projects\app
For future searchers... This happened to me using rvm, I'd accidentally activated a gemset using an uppercase name, this "worked" as OS X is case insensitive but caused rails to have this load error.
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
$ spring stop
solved my problem. (Same version Ruby & Rails)
$ spring stop
solved the problem for me too. Ruby 2.6.3 / Rails 5.2.3.
Most helpful comment
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