Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Linux PATH has "[]" , some file can not loaded by rails ? #5521

daigong opened this Issue Mar 20, 2012 · 6 comments


None yet
4 participants

daigong commented Mar 20, 2012

if app path has "[]", for example, My app is in "/home/daigong/[]/app_name"

My OS is Ubuntu11.10_x86_64

Rails version is 3.1

when I run script/rails s , get warning:

You did not specify how you would like Rails to report deprecation notices for your development environment, please set config.active_support.deprecation to :log at config/environments/development.rb

when I viste my site ,get error:

A secret is required to generate an integrity hash for cookie session data. Use config.secret_token = "some secret phrase of at least 30 characters"in config/initializers/secret_token.rb

but same app at path ( for example, " /home/daigong/app_name/ ") ,all is ok... no waring,no error

I think this is a path problom, if app_path has "[]" chars , some file can not loaded by rails


byroot commented Mar 21, 2012

Same here under OS X.

Initializers and the environment file (at least) are not executed if the app is located in a directory with [] in its name.

spilin commented Mar 21, 2012

After some investigation, it turns out that while loading config initializers, Engine uses Dir to expand path and retrieve all config files. Since Dir.glob accepts pattern, where "[" and "]" represent special globbing chars, it cannot properly expand these paths. This leads to skipping loading of config files. I'm not sure is this should be fixed or not.


byroot commented Mar 21, 2012

It can be fixed by escaping the rails root path with some \


byroot commented Mar 21, 2012

Here my fix tentative. I'm also not sure if it should be merged, but IHMO having this kind of strange limitations about where your rails app is installed is sad...

daigong commented Mar 22, 2012

I get this problom because ours SVN PATH is like "%SVN_PATH%/System[Code]" .... I hate it...

now,I change my app path, thanks u very much


tenderlove commented Mar 23, 2012

I think this will fix it:

diff --git a/railties/lib/rails/paths.rb b/railties/lib/rails/paths.rb
index b37421c..cb275ab 100644
--- a/railties/lib/rails/paths.rb
+++ b/railties/lib/rails/paths.rb
@@ -157,7 +157,11 @@ module Rails
           path = File.expand_path(p, @root.path)

           if @glob
-            result.concat Dir[File.join(path, @glob)].sort
+            Dir.chdir(path) do
+              result.concat Dir.glob(@glob).map { |file|
+                File.join path, file
+              }.sort
+            end
             result << path

I need to make sure the tests run, then I'll commit it. :-/

carlosantoniodasilva pushed a commit to carlosantoniodasilva/rails that referenced this issue Mar 24, 2012

greggroth added a commit to greggroth/rails that referenced this issue Mar 26, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment