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

Problems upgrading to 0.9.29 and dependencies #556

Closed
simonhambly opened this Issue May 24, 2011 · 15 comments

Comments

Projects
None yet
4 participants
@simonhambly

simonhambly commented May 24, 2011

I'm upgrading from 0.9.28 (previously upgrading from 0.9.23) and having some problems loading dependencies. I've followed the instructions on the 0.9.29 blog post about adding dependencies.

In the MyApp.dependencies line I've assumed that MyApp is the application name... so have replaced with my app name (DemoProject). When I run padrino console... I get an "uninitialized constant DemoProject (NameError)"

What am I missing?

@nesquena

This comment has been minimized.

Show comment
Hide comment
@nesquena

nesquena May 25, 2011

Member

Excellent question, perhaps you aren't missing anything and the post is incorrect which I apologize for. I'm curious what if you were to try it on the after_load hook? @DAddYE can you help me correct the blog post so the dep declaration works?

Member

nesquena commented May 25, 2011

Excellent question, perhaps you aren't missing anything and the post is incorrect which I apologize for. I'm curious what if you were to try it on the after_load hook? @DAddYE can you help me correct the blog post so the dep declaration works?

@simonhambly

This comment has been minimized.

Show comment
Hide comment
@simonhambly

simonhambly May 25, 2011

Adding the lines to the after_load hook stops that error. After further investigation, if you explicitly require the app/app.rb file then you can add load_paths and dependencies statements in before_load without getting the above error.

However...

Being able to add the statements to the either of the hooks doesn't solve the underlying problem: that files in the app/lib folder aren't being autoloaded.

If you create demo_project as:

$ padrino g project demo_project
$ cd demo_project 
$ padrino g plugin carrierwave
$ mkdir app/lib
$ mv lib/uploader.rb app/lib/uploader.rb

and configure load_paths/dependencies by:

# config/boot.rb
require Padrino.root("app/app.rb")
Padrino.before_load do
  DemoProject.load_paths << ["app/lib/*.rb"]
  DemoProject.dependencies << Padrino.root("app/lib/uploader.rb")
end

then load the app via:

$ padrino console

I get uninitialized constant Upload::Uploader (NameError).

In 0.9.28 and below (at least until 0.9.23) using the following worked and lib files in app/lib were autoloaded correctly

# config/boot.rb
Padrino.custom_dependencies(Padrino.root("app/lib/uploader.rb"))

Is there something else I need to do to get app/lib/*.rb files autoloading?

p.s. I'm using multiple apps in a project and want to keep app specific lib files with the appropriate app (in app/lib, app2/lib etc) - that's why I want to move the carrierwave uploader to app/lib.

simonhambly commented May 25, 2011

Adding the lines to the after_load hook stops that error. After further investigation, if you explicitly require the app/app.rb file then you can add load_paths and dependencies statements in before_load without getting the above error.

However...

Being able to add the statements to the either of the hooks doesn't solve the underlying problem: that files in the app/lib folder aren't being autoloaded.

If you create demo_project as:

$ padrino g project demo_project
$ cd demo_project 
$ padrino g plugin carrierwave
$ mkdir app/lib
$ mv lib/uploader.rb app/lib/uploader.rb

and configure load_paths/dependencies by:

# config/boot.rb
require Padrino.root("app/app.rb")
Padrino.before_load do
  DemoProject.load_paths << ["app/lib/*.rb"]
  DemoProject.dependencies << Padrino.root("app/lib/uploader.rb")
end

then load the app via:

$ padrino console

I get uninitialized constant Upload::Uploader (NameError).

In 0.9.28 and below (at least until 0.9.23) using the following worked and lib files in app/lib were autoloaded correctly

# config/boot.rb
Padrino.custom_dependencies(Padrino.root("app/lib/uploader.rb"))

Is there something else I need to do to get app/lib/*.rb files autoloading?

p.s. I'm using multiple apps in a project and want to keep app specific lib files with the appropriate app (in app/lib, app2/lib etc) - that's why I want to move the carrierwave uploader to app/lib.

@nesquena

This comment has been minimized.

Show comment
Hide comment
@nesquena

nesquena May 25, 2011

Member

@DAddYE Thoughts on how he can achieve this in 0.9.29? Considering we removed custom_dependencies?

Member

nesquena commented May 25, 2011

@DAddYE Thoughts on how he can achieve this in 0.9.29? Considering we removed custom_dependencies?

@DAddYE

This comment has been minimized.

Show comment
Hide comment
@DAddYE

DAddYE May 25, 2011

Member

@simonhambly why you can't simply do that:

class MyApp < Padrino::Application
  dependencies << Padrino.root("app/lib/uploader.rb")
  load_paths     << ["app/lib/*.rb"]
end
Member

DAddYE commented May 25, 2011

@simonhambly why you can't simply do that:

class MyApp < Padrino::Application
  dependencies << Padrino.root("app/lib/uploader.rb")
  load_paths     << ["app/lib/*.rb"]
end
@nesquena

This comment has been minimized.

Show comment
Hide comment
@nesquena

nesquena May 25, 2011

Member

Oh if that worked, even better I can tweak the blog post. Let me know @simonhambly

Member

nesquena commented May 25, 2011

Oh if that worked, even better I can tweak the blog post. Let me know @simonhambly

@ghost ghost assigned DAddYE May 25, 2011

@simonhambly

This comment has been minimized.

Show comment
Hide comment
@simonhambly

simonhambly May 25, 2011

@nesquena - no joy. Adding @DAddYE's suggestion to to MyApp doesn't work - still get uninitialized constant error.

btw can work around by explicitly requiring the app/lib/uploader.rb file in models/upload.rb works - put kind of defeats auto loading...

Also autoloading works if leave uploader as lib/uploader.rb - so is there a difference between how 'core' (I assume) loads dependencies and how the applications load dependencies?

simonhambly commented May 25, 2011

@nesquena - no joy. Adding @DAddYE's suggestion to to MyApp doesn't work - still get uninitialized constant error.

btw can work around by explicitly requiring the app/lib/uploader.rb file in models/upload.rb works - put kind of defeats auto loading...

Also autoloading works if leave uploader as lib/uploader.rb - so is there a difference between how 'core' (I assume) loads dependencies and how the applications load dependencies?

@nesquena

This comment has been minimized.

Show comment
Hide comment
@nesquena

nesquena May 25, 2011

Member

Yes I see that as well, it has to do with order of operations I think, the dependencies/load_paths are being added too late in the loading process. @DAddYE Do you have any other approach for them to try? Hopefully there is a workable solution. If not, we will investigate, fix this and release a new patch ASAP. Thanks for bringing this to our attention.

Member

nesquena commented May 25, 2011

Yes I see that as well, it has to do with order of operations I think, the dependencies/load_paths are being added too late in the loading process. @DAddYE Do you have any other approach for them to try? Hopefully there is a workable solution. If not, we will investigate, fix this and release a new patch ASAP. Thanks for bringing this to our attention.

@nesquena

This comment has been minimized.

Show comment
Hide comment
@nesquena

nesquena Jun 7, 2011

Member

@DAddYE This seems to be a real problem no? We need a way to recommend people to require deps or what do you recommend?

Member

nesquena commented Jun 7, 2011

@DAddYE This seems to be a real problem no? We need a way to recommend people to require deps or what do you recommend?

DAddYE added a commit that referenced this issue Jun 7, 2011

* Fix issue #556 now we resolve correctly prerequisites of your app
* Enhancement for #556 now is possible to add custom prerequisites to our app
@DAddYE

This comment has been minimized.

Show comment
Hide comment
@DAddYE

DAddYE Jun 7, 2011

Member

Fixed, from our docs:

An array of file to load before your app.rb, basically are files wich our app depends on.

By default we look for files:

  yourapp/models.rb
  yourapp/models/**/*.rb
  yourapp/lib.rb
  yourapp/lib/**/*.rb

Examples

MyApp.prerequisites << Padrino.root('my_app', 'custom_model.rb')

Btw as said we load all deps under app_name/lib/*/.rb so I think is no more necessary.

Member

DAddYE commented Jun 7, 2011

Fixed, from our docs:

An array of file to load before your app.rb, basically are files wich our app depends on.

By default we look for files:

  yourapp/models.rb
  yourapp/models/**/*.rb
  yourapp/lib.rb
  yourapp/lib/**/*.rb

Examples

MyApp.prerequisites << Padrino.root('my_app', 'custom_model.rb')

Btw as said we load all deps under app_name/lib/*/.rb so I think is no more necessary.

@DAddYE DAddYE closed this Jun 7, 2011

@nesquena

This comment has been minimized.

Show comment
Hide comment
@nesquena

nesquena Jun 7, 2011

Member

@simonhambly Can you confirm that the prerequisites method does properly load files now?

Member

nesquena commented Jun 7, 2011

@simonhambly Can you confirm that the prerequisites method does properly load files now?

DAddYE added a commit that referenced this issue Jun 7, 2011

@simonhambly

This comment has been minimized.

Show comment
Hide comment
@simonhambly

simonhambly Jun 10, 2011

@nesquena, just had chance to test - the uploader in app/lib is correctly loaded now using the latest code.

Incidently had some issues with carrierwave plugin - it didn't seem to create the upload model in the correct place. Instead it created it as model/upload.rb instead of app/model/upload.rb.

To get the plugin created I had to run:

$ padrino g plugin carrierwave
$ mv model/upload.rb app/model/upload.rb
$ padrino g plugin carrierwave

Then I could test.

Not sure whether this is plugin generator issue or the carrierwave plugin itself.

One last thing on the "Padrino Guides - The Bleeding Edge" instructions... tweaking the version no (appending "-dev") means

$ rake fresh

no longer works.

When I ran

$ bundle install

I got an "Malformed version number string 0.9.29-dev (ArgumentError)" thrown. So the Bleeding Edge guide may need updating.

simonhambly commented Jun 10, 2011

@nesquena, just had chance to test - the uploader in app/lib is correctly loaded now using the latest code.

Incidently had some issues with carrierwave plugin - it didn't seem to create the upload model in the correct place. Instead it created it as model/upload.rb instead of app/model/upload.rb.

To get the plugin created I had to run:

$ padrino g plugin carrierwave
$ mv model/upload.rb app/model/upload.rb
$ padrino g plugin carrierwave

Then I could test.

Not sure whether this is plugin generator issue or the carrierwave plugin itself.

One last thing on the "Padrino Guides - The Bleeding Edge" instructions... tweaking the version no (appending "-dev") means

$ rake fresh

no longer works.

When I ran

$ bundle install

I got an "Malformed version number string 0.9.29-dev (ArgumentError)" thrown. So the Bleeding Edge guide may need updating.

@nesquena

This comment has been minimized.

Show comment
Hide comment
@nesquena

nesquena Jun 10, 2011

Member

Ok thanks simon, we will tweak the carrierwave plugin to fix that issue and update the bleeding edge guide.

Member

nesquena commented Jun 10, 2011

Ok thanks simon, we will tweak the carrierwave plugin to fix that issue and update the bleeding edge guide.

@nesquena

This comment has been minimized.

Show comment
Hide comment
@nesquena

nesquena Jun 10, 2011

Member

@achiu Can you update the plugins? https://github.com/padrino/padrino-recipes/blob/master/plugins/carrierwave_plugin.rb seems to specify app/models but your recent changes to move everything into 'models' by default probably broke several plugins.

Member

nesquena commented Jun 10, 2011

@achiu Can you update the plugins? https://github.com/padrino/padrino-recipes/blob/master/plugins/carrierwave_plugin.rb seems to specify app/models but your recent changes to move everything into 'models' by default probably broke several plugins.

@achiu

This comment has been minimized.

Show comment
Hide comment
@achiu

achiu Jun 10, 2011

Member

@nesquena I made the changes here: padrino/padrino-recipes@4bdb8c5. I'll check out to see if there are any other issues that arise from latest changes but that should cover them.

Member

achiu commented Jun 10, 2011

@nesquena I made the changes here: padrino/padrino-recipes@4bdb8c5. I'll check out to see if there are any other issues that arise from latest changes but that should cover them.

@nesquena

This comment has been minimized.

Show comment
Hide comment
@nesquena

nesquena Jun 10, 2011

Member

Ah great thanks, I will review the recipes a bit later but will assume they are taken care of now.

Member

nesquena commented Jun 10, 2011

Ah great thanks, I will review the recipes a bit later but will assume they are taken care of now.

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