Skip to content
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

import DSL method removed without replacement? #1632

Closed
bclennox opened this issue Aug 13, 2018 · 3 comments
Closed

import DSL method removed without replacement? #1632

bclennox opened this issue Aug 13, 2018 · 3 comments
Labels

Comments

@bclennox
Copy link

Steps to reproduce

In v3.6.0, the DSL supported an import method to load another config file within a given file. We use this to have a default.rb that gets loaded into each of our environments, which have environment-specific config in development.rb, production.rb, etc.

This method was removed in #1234 without any obvious explanation. There is a load method, but that doesn't load the file immediately (or at all?) the way that import does:

# config/puma/development.rb
load 'default'
puts 'Should not get here'

# config/puma/default.rb
raise 'Raising from default.rb'

$ bundle exec puma -e development
Should not get here
Puma starting in single mode...
# ...

With import instead of load:

# config/puma/development.rb
import 'default'
puts 'Should not get here'

# config/puma/default.rb
raise 'Raising from default.rb'

$ bundle exec puma -e development
RuntimeError: Raising from default.rb
  config/puma/default.rb:1:in `_load_from'
  /Users/brandan/repos/baseline/vendor/bundle/ruby/2.5.0/gems/puma-3.6.0/lib/puma/dsl.rb:26:in `instance_eval'
  /Users/brandan/repos/baseline/vendor/bundle/ruby/2.5.0/gems/puma-3.6.0/lib/puma/dsl.rb:26:in `_load_from'
  /Users/brandan/repos/baseline/vendor/bundle/ruby/2.5.0/gems/puma-3.6.0/lib/puma/dsl.rb:70:in `import'
  config/puma/development.rb:1:in `_load_from'
  /Users/brandan/repos/baseline/vendor/bundle/ruby/2.5.0/gems/puma-3.6.0/lib/puma/dsl.rb:26:in `instance_eval'
  /Users/brandan/repos/baseline/vendor/bundle/ruby/2.5.0/gems/puma-3.6.0/lib/puma/dsl.rb:26:in `_load_from'
  /Users/brandan/repos/baseline/vendor/bundle/ruby/2.5.0/gems/puma-3.6.0/lib/puma/dsl.rb:9:in `load'
  /Users/brandan/repos/baseline/vendor/bundle/ruby/2.5.0/gems/puma-3.6.0/lib/puma/configuration.rb:205:in `block in load'
  /Users/brandan/repos/baseline/vendor/bundle/ruby/2.5.0/gems/puma-3.6.0/lib/puma/configuration.rb:202:in `each'
  /Users/brandan/repos/baseline/vendor/bundle/ruby/2.5.0/gems/puma-3.6.0/lib/puma/configuration.rb:202:in `load'
  /Users/brandan/repos/baseline/vendor/bundle/ruby/2.5.0/gems/puma-3.6.0/lib/puma/launcher.rb:62:in `initialize'
  /Users/brandan/repos/baseline/vendor/bundle/ruby/2.5.0/gems/puma-3.6.0/lib/puma/cli.rb:65:in `new'
  /Users/brandan/repos/baseline/vendor/bundle/ruby/2.5.0/gems/puma-3.6.0/lib/puma/cli.rb:65:in `initialize'
  /Users/brandan/repos/baseline/vendor/bundle/ruby/2.5.0/gems/puma-3.6.0/bin/puma:8:in `new'
  /Users/brandan/repos/baseline/vendor/bundle/ruby/2.5.0/gems/puma-3.6.0/bin/puma:8:in `<top (required)>'
  /Users/brandan/repos/baseline/vendor/bundle/ruby/2.5.0/bin/puma:23:in `load'
  /Users/brandan/repos/baseline/vendor/bundle/ruby/2.5.0/bin/puma:23:in `<top (required)>'

According to the docs in the source, we would have to call Configuration#load at some point, but I'm not sure how or when to do that, since we're not explicitly creating a Configuration.

Expected behavior

I expected that import would still be supported when upgrading to v3.12.0, but since it's been over a year since it was removed and it doesn't seem to be affecting others (based on searching issues here), is there a different pattern that we should be following? Is there a way to make load work the way import worked?

Actual behavior

The "loaded" file does not seem to be loaded at all.

System configuration

Ruby version: 2.5.1
Rails version: 5.2.1
Puma version: 3.12.0

@bclennox
Copy link
Author

I should note that _load_from appears to work the same as import if you pass it an absolute path:

# config/puma/development.rb
_load_from File.join(__dir__, 'default.rb')
puts 'Should not get here'

# config/puma/default.rb
raise 'Raising from default.rb'

$ bundle exec puma -e development
RuntimeError: Raising from default.rb
  config/puma/default.rb:1:in `_load_from'
  # ...

@nateberkopec
Copy link
Member

I believe we'd like you to use the new system introduced in #1234 instead. Not really SemVer there so sorry about that. Is there a reason you can't do that?

@bclennox
Copy link
Author

We were able to consolidate back to a single config file in config/puma.rb. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants