New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple error with namespaced padrino projects #1595

Closed
pablox-cl opened this Issue Feb 16, 2014 · 2 comments

Comments

Projects
None yet
2 participants
@pablox-cl
Contributor

pablox-cl commented Feb 16, 2014

$ padrino g project tarjira -c sass -d mongoid -e slim -m rr -t rspec -b
$ cd tarjira
$ bundle install
$ padrino g admin
$ bundle install
$ padrino start
# no problem, loads good
$ padrino g project tarjira -c sass -d mongoid -e slim -m rr -n tarjira -t rspec -b
$ cd tarjira
$ bundle install
$ padrino g admin
$ bundle install
$ padrino start
/vendor/bundle/gems/padrino-core-0.12.0/lib/padrino-core/mounter.rb:86:in `map_onto': undefined method `set' for Tarjira:Module (NoMethodError)
    from /home/pablo/code/padrino/era/tarjira-new/vendor/bundle/gems/padrino-core-0.12.0/lib/padrino-core.rb:71:in `block in application'
    from /home/pablo/code/padrino/era/tarjira-new/vendor/bundle/gems/padrino-core-0.12.0/lib/padrino-core.rb:71:in `each'
    from /home/pablo/code/padrino/era/tarjira-new/vendor/bundle/gems/padrino-core-0.12.0/lib/padrino-core.rb:71:in `application'
    from /home/pablo/code/padrino/era/tarjira-new/vendor/bundle/gems/padrino-core-0.12.0/lib/padrino-core/server.rb:12:in `run!'
    from /home/pablo/code/padrino/era/tarjira-new/vendor/bundle/gems/padrino-core-0.12.0/lib/padrino-core/cli/adapter.rb:7:in `start'
    from /home/pablo/code/padrino/era/tarjira-new/vendor/bundle/gems/padrino-core-0.12.0/lib/padrino-core/cli/base.rb:32:in `start'
    from /home/pablo/code/padrino/era/tarjira-new/vendor/bundle/gems/thor-0.17.0/lib/thor/task.rb:27:in `run'
    from /home/pablo/code/padrino/era/tarjira-new/vendor/bundle/gems/thor-0.17.0/lib/thor/invocation.rb:120:in `invoke_task'
    from /home/pablo/code/padrino/era/tarjira-new/vendor/bundle/gems/thor-0.17.0/lib/thor.rb:344:in `dispatch'
    from /home/pablo/code/padrino/era/tarjira-new/vendor/bundle/gems/thor-0.17.0/lib/thor/base.rb:434:in `start'
    from /home/pablo/code/padrino/era/tarjira-new/vendor/bundle/gems/padrino-core-0.12.0/bin/padrino:9:in `<top (required)>'
    from /home/pablo/code/padrino/era/tarjira-new/bin/padrino:16:in `load'
    from /home/pablo/code/padrino/era/tarjira-new/bin/padrino:16:in `<main>'
$ padrino console # namespaced
=> Loading development console (Padrino v.0.12.0)
=> Loading Application Tarjira::Admin
=> Loading Application Tarjira::Tarjira
/home/pablo/code/padrino/era/tarjira-new/vendor/bundle/gems/padrino-core-0.12.0/lib/padrino-core/cli/console.rb:19:in `block in <top (required)>': undefined method `setup_application!' for Tarjira:Module (NoMethodError)
    from /home/pablo/code/padrino/era/tarjira-new/vendor/bundle/gems/padrino-core-0.12.0/lib/padrino-core/cli/console.rb:17:in `each'
    from /home/pablo/code/padrino/era/tarjira-new/vendor/bundle/gems/padrino-core-0.12.0/lib/padrino-core/cli/console.rb:17:in `<top (required)>'
    from /home/pablo/code/padrino/era/tarjira-new/vendor/bundle/gems/padrino-core-0.12.0/lib/padrino-core/cli/base.rb:75:in `require'
    from /home/pablo/code/padrino/era/tarjira-new/vendor/bundle/gems/padrino-core-0.12.0/lib/padrino-core/cli/base.rb:75:in `console'
    from /home/pablo/code/padrino/era/tarjira-new/vendor/bundle/gems/thor-0.17.0/lib/thor/task.rb:27:in `run'
    from /home/pablo/code/padrino/era/tarjira-new/vendor/bundle/gems/thor-0.17.0/lib/thor/invocation.rb:120:in `invoke_task'
    from /home/pablo/code/padrino/era/tarjira-new/vendor/bundle/gems/thor-0.17.0/lib/thor.rb:344:in `dispatch'
    from /home/pablo/code/padrino/era/tarjira-new/vendor/bundle/gems/thor-0.17.0/lib/thor/base.rb:434:in `start'
    from /home/pablo/code/padrino/era/tarjira-new/vendor/bundle/gems/padrino-core-0.12.0/bin/padrino:9:in `<top (required)>'
    from /home/pablo/code/padrino/era/tarjira-new/bin/padrino:16:in `load'
    from /home/pablo/code/padrino/era/tarjira-new/bin/padrino:16:in `<main>'


$ padrino console # no-namespace
=> Loading development console (Padrino v.0.12.0)
=> Loading Application Tarjira::Admin
=> Loading Application Tarjira::App
irb(main):001:0>

As I posted in the title, this only happens when it's namespaced say:

# config/apps.rb
Padrino.mount('Tarjira::Tarjira', :app_file => Padrino.root('app/app.rb')).to('/')
#### instead of
Padrino.mount('Tarjira::App', :app_file => Padrino.root('app/app.rb')).to('/')

# app/app.rb
  class Tarjira < Padrino::Application
#### 
  class App < Padrino::Application

Those are the only differences between the two generated apps, so I'm quite lost O.o

@pablox-cl

This comment has been minimized.

Show comment
Hide comment
@pablox-cl

pablox-cl Feb 16, 2014

Contributor

I have diffed the two directories, and this is the only difference:

diff --unified -Naur -x vendor tarjira/app/app.rb tarjira-new/app/app.rb
--- tarjira/app/app.rb  2014-02-15 21:16:32.937489634 -0300
+++ tarjira-new/app/app.rb  2014-02-15 20:59:09.142538867 -0300
@@ -1,5 +1,5 @@
 module Tarjira
-  class App < Padrino::Application
+  class Tarjira < Padrino::Application
     register SassInitializer
     register Padrino::Rendering
     register Padrino::Mailer
diff --unified -Naur -x vendor tarjira/config/apps.rb tarjira-new/config/apps.rb
--- tarjira/config/apps.rb  2014-02-15 21:22:24.676092296 -0300
+++ tarjira-new/config/apps.rb  2014-02-15 21:13:12.112000298 -0300
@@ -27,7 +27,7 @@
 #
 Padrino.configure_apps do
   # enable :sessions
-  set :session_secret, '8fb2eca3791676d469a4f92205a560d2a95d31c64bc6a6db74ad8423f4f9cf04'
+  set :session_secret, '92f45a801d359629a6705fdff20d07665f5aef5c48ef8c4dedd637d174ed7614'
   set :protection, :except => :path_traversal
   set :protect_from_csrf, true
 end
@@ -35,4 +35,4 @@
 # Mounts the core application for this project

 Padrino.mount("Tarjira::Admin", :app_file => Padrino.root('admin/app.rb')).to("/admin")
-Padrino.mount('Tarjira::App', :app_file => Padrino.root('app/app.rb')).to('/')
+Padrino.mount('Tarjira::Tarjira', :app_file => Padrino.root('app/app.rb')).to('/')
diff --unified -Naur -x vendor tarjira/spec/spec_helper.rb tarjira-new/spec/spec_helper.rb
--- tarjira/spec/spec_helper.rb 2014-02-15 21:16:32.935489659 -0300
+++ tarjira-new/spec/spec_helper.rb 2014-02-15 20:59:09.107539304 -0300
@@ -9,9 +9,9 @@
 # You can use this method to custom specify a Rack app
 # you want rack-test to invoke:
 #
-#   app Tarjira::App
-#   app Tarjira::App.tap { |a| }
-#   app(Tarjira::App) do
+#   app Tarjira::Tarjira
+#   app Tarjira::Tarjira.tap { |a| }
+#   app(Tarjira::Tarjira) do
 #     set :foo, :bar
 #   end
 #
Contributor

pablox-cl commented Feb 16, 2014

I have diffed the two directories, and this is the only difference:

diff --unified -Naur -x vendor tarjira/app/app.rb tarjira-new/app/app.rb
--- tarjira/app/app.rb  2014-02-15 21:16:32.937489634 -0300
+++ tarjira-new/app/app.rb  2014-02-15 20:59:09.142538867 -0300
@@ -1,5 +1,5 @@
 module Tarjira
-  class App < Padrino::Application
+  class Tarjira < Padrino::Application
     register SassInitializer
     register Padrino::Rendering
     register Padrino::Mailer
diff --unified -Naur -x vendor tarjira/config/apps.rb tarjira-new/config/apps.rb
--- tarjira/config/apps.rb  2014-02-15 21:22:24.676092296 -0300
+++ tarjira-new/config/apps.rb  2014-02-15 21:13:12.112000298 -0300
@@ -27,7 +27,7 @@
 #
 Padrino.configure_apps do
   # enable :sessions
-  set :session_secret, '8fb2eca3791676d469a4f92205a560d2a95d31c64bc6a6db74ad8423f4f9cf04'
+  set :session_secret, '92f45a801d359629a6705fdff20d07665f5aef5c48ef8c4dedd637d174ed7614'
   set :protection, :except => :path_traversal
   set :protect_from_csrf, true
 end
@@ -35,4 +35,4 @@
 # Mounts the core application for this project

 Padrino.mount("Tarjira::Admin", :app_file => Padrino.root('admin/app.rb')).to("/admin")
-Padrino.mount('Tarjira::App', :app_file => Padrino.root('app/app.rb')).to('/')
+Padrino.mount('Tarjira::Tarjira', :app_file => Padrino.root('app/app.rb')).to('/')
diff --unified -Naur -x vendor tarjira/spec/spec_helper.rb tarjira-new/spec/spec_helper.rb
--- tarjira/spec/spec_helper.rb 2014-02-15 21:16:32.935489659 -0300
+++ tarjira-new/spec/spec_helper.rb 2014-02-15 20:59:09.107539304 -0300
@@ -9,9 +9,9 @@
 # You can use this method to custom specify a Rack app
 # you want rack-test to invoke:
 #
-#   app Tarjira::App
-#   app Tarjira::App.tap { |a| }
-#   app(Tarjira::App) do
+#   app Tarjira::Tarjira
+#   app Tarjira::Tarjira.tap { |a| }
+#   app(Tarjira::Tarjira) do
 #     set :foo, :bar
 #   end
 #
@pablox-cl

This comment has been minimized.

Show comment
Hide comment
@pablox-cl

pablox-cl Feb 16, 2014

Contributor

Ok, this is really weird (unless I am missing something). This bug it's only reproducible when the project name and the namespace (with the -n flag) it's the same and only after you install the admin module (though I believe it would happen with any other app mounted).

$ padrino g project no-namespace -c sass -d mongoid -e slim -m rr -t rspec
$ cd no-namespace
$ bundle install
$ padrino g admin
$ bundle install
$ padrino c
# no problem

$ padrino g project namespaced -c sass -d mongoid -e slim -m rr -t rspec -n namespaced
$ cd namespaced
$ bundle install
$ padrino g admin
$ bundle install 
$ padrino c # same with padrino s or any other command
# error!

$ padrino g project another_proj -c sass -d mongoid -e slim -m rr -t rspec -n namespace
$ cd another_proj
$ bundle install
$ padrino g admin
$ bundle install
$ padrino c
# no problem

The error is the following (when happens)

$ padrino c
=> Loading development console (Padrino v.0.12.0)
=> Loading Application Namespaced::Admin
=> Loading Application Namespaced::Namespaced
/home/pablo/code/padrino12/padrino-0.12/gems/padrino-core-0.12.0/lib/padrino-core/cli/console.rb:19:in `block in <top (required)>': undefined method `setup_application!' for Namespaced:Module (NoMethodError)
    from /home/pablo/code/padrino12/padrino-0.12/gems/padrino-core-0.12.0/lib/padrino-core/cli/console.rb:17:in `each'
    from /home/pablo/code/padrino12/padrino-0.12/gems/padrino-core-0.12.0/lib/padrino-core/cli/console.rb:17:in `<top (required)>'
    from /home/pablo/code/padrino12/padrino-0.12/gems/padrino-core-0.12.0/lib/padrino-core/cli/base.rb:75:in `require'
    from /home/pablo/code/padrino12/padrino-0.12/gems/padrino-core-0.12.0/lib/padrino-core/cli/base.rb:75:in `console'
    from /home/pablo/code/padrino12/padrino-0.12/gems/thor-0.17.0/lib/thor/task.rb:27:in `run'
    from /home/pablo/code/padrino12/padrino-0.12/gems/thor-0.17.0/lib/thor/invocation.rb:120:in `invoke_task'
    from /home/pablo/code/padrino12/padrino-0.12/gems/thor-0.17.0/lib/thor.rb:344:in `dispatch'
    from /home/pablo/code/padrino12/padrino-0.12/gems/thor-0.17.0/lib/thor/base.rb:434:in `start'
    from /home/pablo/code/padrino12/padrino-0.12/gems/padrino-core-0.12.0/bin/padrino:9:in `<top (required)>'
    from /home/pablo/code/padrino12/padrino-0.12/bin/padrino:23:in `load'
    from /home/pablo/code/padrino12/padrino-0.12/bin/padrino:23:in `<main>'
$ padrino s
/home/pablo/code/padrino12/padrino-0.12/gems/padrino-core-0.12.0/lib/padrino-core/mounter.rb:86:in `map_onto': undefined method `set' for Namespaced:Module (NoMethodError)
    from /home/pablo/code/padrino12/padrino-0.12/gems/padrino-core-0.12.0/lib/padrino-core.rb:71:in `block in application'
    from /home/pablo/code/padrino12/padrino-0.12/gems/padrino-core-0.12.0/lib/padrino-core.rb:71:in `each'
    from /home/pablo/code/padrino12/padrino-0.12/gems/padrino-core-0.12.0/lib/padrino-core.rb:71:in `application'
    from /home/pablo/code/padrino12/padrino-0.12/gems/padrino-core-0.12.0/lib/padrino-core/server.rb:12:in `run!'
    from /home/pablo/code/padrino12/padrino-0.12/gems/padrino-core-0.12.0/lib/padrino-core/cli/adapter.rb:7:in `start'
    from /home/pablo/code/padrino12/padrino-0.12/gems/padrino-core-0.12.0/lib/padrino-core/cli/base.rb:32:in `start'
    from /home/pablo/code/padrino12/padrino-0.12/gems/thor-0.17.0/lib/thor/task.rb:27:in `run'
    from /home/pablo/code/padrino12/padrino-0.12/gems/thor-0.17.0/lib/thor/invocation.rb:120:in `invoke_task'
    from /home/pablo/code/padrino12/padrino-0.12/gems/thor-0.17.0/lib/thor.rb:344:in `dispatch'
    from /home/pablo/code/padrino12/padrino-0.12/gems/thor-0.17.0/lib/thor/base.rb:434:in `start'
    from /home/pablo/code/padrino12/padrino-0.12/gems/padrino-core-0.12.0/bin/padrino:9:in `<top (required)>'
    from /home/pablo/code/padrino12/padrino-0.12/bin/padrino:23:in `load'
    from /home/pablo/code/padrino12/padrino-0.12/bin/padrino:23:in `<main>'
Contributor

pablox-cl commented Feb 16, 2014

Ok, this is really weird (unless I am missing something). This bug it's only reproducible when the project name and the namespace (with the -n flag) it's the same and only after you install the admin module (though I believe it would happen with any other app mounted).

$ padrino g project no-namespace -c sass -d mongoid -e slim -m rr -t rspec
$ cd no-namespace
$ bundle install
$ padrino g admin
$ bundle install
$ padrino c
# no problem

$ padrino g project namespaced -c sass -d mongoid -e slim -m rr -t rspec -n namespaced
$ cd namespaced
$ bundle install
$ padrino g admin
$ bundle install 
$ padrino c # same with padrino s or any other command
# error!

$ padrino g project another_proj -c sass -d mongoid -e slim -m rr -t rspec -n namespace
$ cd another_proj
$ bundle install
$ padrino g admin
$ bundle install
$ padrino c
# no problem

The error is the following (when happens)

$ padrino c
=> Loading development console (Padrino v.0.12.0)
=> Loading Application Namespaced::Admin
=> Loading Application Namespaced::Namespaced
/home/pablo/code/padrino12/padrino-0.12/gems/padrino-core-0.12.0/lib/padrino-core/cli/console.rb:19:in `block in <top (required)>': undefined method `setup_application!' for Namespaced:Module (NoMethodError)
    from /home/pablo/code/padrino12/padrino-0.12/gems/padrino-core-0.12.0/lib/padrino-core/cli/console.rb:17:in `each'
    from /home/pablo/code/padrino12/padrino-0.12/gems/padrino-core-0.12.0/lib/padrino-core/cli/console.rb:17:in `<top (required)>'
    from /home/pablo/code/padrino12/padrino-0.12/gems/padrino-core-0.12.0/lib/padrino-core/cli/base.rb:75:in `require'
    from /home/pablo/code/padrino12/padrino-0.12/gems/padrino-core-0.12.0/lib/padrino-core/cli/base.rb:75:in `console'
    from /home/pablo/code/padrino12/padrino-0.12/gems/thor-0.17.0/lib/thor/task.rb:27:in `run'
    from /home/pablo/code/padrino12/padrino-0.12/gems/thor-0.17.0/lib/thor/invocation.rb:120:in `invoke_task'
    from /home/pablo/code/padrino12/padrino-0.12/gems/thor-0.17.0/lib/thor.rb:344:in `dispatch'
    from /home/pablo/code/padrino12/padrino-0.12/gems/thor-0.17.0/lib/thor/base.rb:434:in `start'
    from /home/pablo/code/padrino12/padrino-0.12/gems/padrino-core-0.12.0/bin/padrino:9:in `<top (required)>'
    from /home/pablo/code/padrino12/padrino-0.12/bin/padrino:23:in `load'
    from /home/pablo/code/padrino12/padrino-0.12/bin/padrino:23:in `<main>'
$ padrino s
/home/pablo/code/padrino12/padrino-0.12/gems/padrino-core-0.12.0/lib/padrino-core/mounter.rb:86:in `map_onto': undefined method `set' for Namespaced:Module (NoMethodError)
    from /home/pablo/code/padrino12/padrino-0.12/gems/padrino-core-0.12.0/lib/padrino-core.rb:71:in `block in application'
    from /home/pablo/code/padrino12/padrino-0.12/gems/padrino-core-0.12.0/lib/padrino-core.rb:71:in `each'
    from /home/pablo/code/padrino12/padrino-0.12/gems/padrino-core-0.12.0/lib/padrino-core.rb:71:in `application'
    from /home/pablo/code/padrino12/padrino-0.12/gems/padrino-core-0.12.0/lib/padrino-core/server.rb:12:in `run!'
    from /home/pablo/code/padrino12/padrino-0.12/gems/padrino-core-0.12.0/lib/padrino-core/cli/adapter.rb:7:in `start'
    from /home/pablo/code/padrino12/padrino-0.12/gems/padrino-core-0.12.0/lib/padrino-core/cli/base.rb:32:in `start'
    from /home/pablo/code/padrino12/padrino-0.12/gems/thor-0.17.0/lib/thor/task.rb:27:in `run'
    from /home/pablo/code/padrino12/padrino-0.12/gems/thor-0.17.0/lib/thor/invocation.rb:120:in `invoke_task'
    from /home/pablo/code/padrino12/padrino-0.12/gems/thor-0.17.0/lib/thor.rb:344:in `dispatch'
    from /home/pablo/code/padrino12/padrino-0.12/gems/thor-0.17.0/lib/thor/base.rb:434:in `start'
    from /home/pablo/code/padrino12/padrino-0.12/gems/padrino-core-0.12.0/bin/padrino:9:in `<top (required)>'
    from /home/pablo/code/padrino12/padrino-0.12/bin/padrino:23:in `load'
    from /home/pablo/code/padrino12/padrino-0.12/bin/padrino:23:in `<main>'

@ujifgc ujifgc added this to the 0.12.1 milestone Feb 17, 2014

tyabe added a commit to tyabe/padrino-framework that referenced this issue Feb 28, 2014

Fix bug in Padrino::Mounter.app_constant (#1595)
If the module with the same name as the application class has already been defined,
Padrino::Mounter.app_constant had returned the very module object.

So I intend not to search towards ancestors with second parameter 'false' in 'const_defined?'.
This code is only valid in the Ruby 1.9 or later.

@ujifgc ujifgc closed this in 9f4cfa7 Mar 2, 2014

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