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
update URLMap Regexp usage for Ruby v3.3 #3165
Conversation
Ruby v3.3.0-preview1 doesn't support passing 3 arguments to `Regexp.new`, so update `URLMap` to use a 2 argument version instead.
Thanks for the PR. Wondering if we should just pull in the code from Rack, as it was probably done in 5c9f871? Not sure about using class URLMap
HTTP_HOST = 'HTTP_HOST'
PATH_INFO = 'PATH_INFO'
SCRIPT_NAME = 'SCRIPT_NAME'
SERVER_NAME = 'SERVER_NAME'
SERVER_PORT = 'SERVER_PORT' |
Sounds resonable |
Add a test app like this somewhere? $ cat config.ru
map "/ok" do
run ->(env) { [200, {}, ["OK"]] }
end It currently blows up on Ruby 3.3 like this (when you don't have arm64 $ b e puma
Puma starting in single mode...
* Puma version: 6.2.2 (ruby 3.3.0-p-1) ("Speaking of Now")
* Min threads: 0
* Max threads: 5
* Environment: development
* PID: 81381
! Unable to load application: ArgumentError: wrong number of arguments (given 3, expected 1..2)
bundler: failed to load command: puma (/Users/dentarg/.arm64_rubies/3.3.0-preview1/bin/puma)
/Users/dentarg/.arm64_rubies/3.3.0-preview1/lib/ruby/gems/3.3.0+0/gems/puma-6.2.2/lib/puma/rack/urlmap.rb:37:in `initialize': wrong number of arguments (given 3, expected 1..2) (ArgumentError)
match = Regexp.new("^#{Regexp.quote(location).gsub('/', '/+')}(.*)", nil, 'n')
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
from /Users/dentarg/.arm64_rubies/3.3.0-preview1/lib/ruby/gems/3.3.0+0/gems/puma-6.2.2/lib/puma/rack/urlmap.rb:37:in `new'
from /Users/dentarg/.arm64_rubies/3.3.0-preview1/lib/ruby/gems/3.3.0+0/gems/puma-6.2.2/lib/puma/rack/urlmap.rb:37:in `block in remap'
... |
I suspect it isn't that easy, as the @fallwith how did you notice this issue? do you run any application using Puma where you haven't included |
I think this also occurs with Ruby 3.2, as the change to Regexp happened there... As to testing, we can probably get around the issue by disabling loading rack install in the Gemfile with an ENV setting, then using a test that loads Puma in a sub process. I can investigate, but this isn't a good day for that, tomorrow is better... |
The example I tried (see above) does not blow up on Ruby 3.2.2-p53 |
Yes |
Thanks & sorry. I didn't try it with 3.2, but saw the change in the doc's of the method signature. I didn't notice that it was a deprecation, see rack/rack#1998 |
I work for New Relic and we use a suite of tests to ensure compatibility with Rack. When it comes to testing Puma, we dynamically generate 4 separate The New Relic Ruby agent began instrumenting If I can answer anything else or contribute any further content, please let me know. |
Please add a test as described above |
With a `Gemfile` that excludes `rack`, have Puma use its own `URLMap` class to handle the mapping of the route defined in `config.ru`. Without the fix provided by PR 3165, this new test will time out.
Test added with 8374a5b |
Ruby head builds are broken due to Ruby changes that prevent nio4r from compiling. The Ubuntu-22.04 3.2 job failure is due to an intermittent, unrelated failure. |
ruby head builds had an ABI change that nio4r didn't like. It's been reverted, and the head builds have been updated in GitHub Actions. So, I reran the failing heads builds here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM but since Greg and Dentarg worked on this more closely I'll leave it to you to merge.
Thanks for your work on this. The current test could run on Windows, but won't, due to the I updated that and a few other things. Patch is at 87294d45be. I can cherry-pick to your branch also... |
I added a check to make sure Rack is not loaded in the spawned Puma process. Unlikely to fail, but checking it verifies that the test is running in the proper environment. Prevents accidental failures in the future... |
* test Ruby 3.3 with Puma (via the Rack suite) now that [puma/puma#3165](puma/puma#3165) has been merged * update `add_version` to respect _any_ prefix a human maintainer might want to specify for a version, and not just `=`
Ruby v3.3.0-preview1 doesn't support passing 3 arguments to
Regexp.new
, so updatePuma::Rack::URLMap#remap
to use a 2 argument version instead.I didn't notice where
Puma::Rack::URLMap#remap
was currently tested and could use some advice on the testing front. Syntactically, I've tested the change going back as far as the current minimum supported Ruby, v2.4.Your checklist for this pull request
[ci skip]
to the title of the PR.#issue
" to the PR description or my commit messages.