-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Capybara 'webrick' server registration not compatible with rack 3 #2640
Comments
Per my understanding Rails edge is currently locked to rack 3.0+ and (sadly) not fully compatible yet. There is no easy way to use Rack 2.x+ for now. If you would like to use rack 3 + webrick I think something like this should work (not tested): # Gemfile
gem 'rackup'
...
# test helper
Capybara.register_server :webrick do |app, port, host, **options|
require 'rackup/handler/webrick'
options = { Host: host, Port: port, AccessLog: [], Logger: WEBrick::Log.new(nil, 0) }.merge(options)
Rackup::Handler::WEBrick.run(app, **options)
end
Capybara.server = :webrick |
Ah, so rails edge is actually known to not actually be working properly? In the sense that it requires rack 3, but is known to not yet work with it? So much for my plan of testing against Rails edge! I had thought that Rails edge should always be in an internally consistent working state, i guess I misunderstood! Thanks for that demo code, i will try it out, super helpful! (update: Does appear to work!) But regardless of what Rails is doing or does -- should |
Indeed Capybara needs to be updated (to either work with both Rack 2 and 3 or just one of them), the changes are in the Rack 3 upgrade guide: https://github.com/rack/rack/blob/7acfe495c907c4b219125309f97f7309e64a563c/UPGRADE-GUIDE.md#binrackup-rackserver-rackhandlerand--racklobster-were-moved-to-a-separate-gem |
Just wanted to add some clarification here: Rails edge allows either Rack 2.x or 3.x. 3.x was first allowed in rails/rails#47133 so that compatibility could be fixed across multiple PRs since the diff ended up really big in a single PR. You should be able to prevent a Rack 3.x resolution with something like https://github.com/rails/rails/blob/c8190750f9d28b831f9b38b4ded8a3ee5b41fd9d/Gemfile#L72
probably a good idea to add a |
@skipkayhil ahh, thanks for clarification. I was a little confused since there was a lot of changes related to actionpack gemspec happening at short time. |
(update: I at first had trouble getting a rack 2 resolution with |
Rails main allow rack 3 in rails/rails#46594. However, capybara doesn't support rack 3 yet. teamcapybara/capybara#2640 To test only for rails gem, lock rack version in 2.x.
Issue here is that Capybaras tests depend on sinatra which doesn't yet have a versions which supports rack 3, so we can't currently add rack 3 to the automated tests. |
Trial "fix" merged here - 2db340d - please give it a try and let me know - we can reopen if anything else is required |
Thank you for the workaround commit for simi's local workaround at #2640 (comment) also works fine for me, and is reasonable. The bigger concern is of course the block on capybara running CI for rack 3! Would it be useful to make an open issue here to track that, for people curious to find? And I wonder the most realistic path to resolving that. The sinatra project does not currently seem to have resources engaged for adding support for rack 3. sinatra/sinatra#1797 Swapping sinatra out in capybara CI may or may not be desirable/feasible. (swapping it out for... roda? The roda gemspec does not specify any rack version requirements, not sure if that actually means it is fully supported for rack 3; I haven't found it's CI to see what it builds with; some posts in Github Discussions and Issues seem to suggest some people are using it with rack 3). |
@jrochkind Feel free to try out sinatra/sinatra#1857 :-) |
@dentarg Looks like Rack::File was removed, and it needs to be Rack::Files::Iterator at https://github.com/dentarg/sinatra/blob/rack-3/lib/sinatra/base.rb#L294 now -- not sure where else in the code that may affect |
@twalpole Yes, but not until Rack 3.1: rack/rack#1811 (will try to address that too) |
@dentarg Files is available in Rack 2.x too --- it's just that File was an alias of it --- should be able to just swap to using Files in both 2 and 3 |
I noticed |
This landed in #601 due to capybara incompatibility with rack 3. However, this issue has been solved in teamcapybara/capybara#2640.
Capybara Version: 3.38.0
The capybara 'webrick' registration tries to require and use:
require 'rack/handler/webrick'
.capybara/lib/capybara/registrations/servers.rb
Lines 8 to 10 in 48fe701
The file
rack/handler/webrick
is no longer at that location in rack in 3.0. It looks like they have been removed to a separaterackup
gem. rack/rack#1937This means if you try to use capybara with rack 3 and
Capybara.server = :webrick
, you get an error something like:I discovered this because I run CI on a project against rails "edge" for early warnings, and Rails edge main branch seems to have recently allowed rack 3?
rails/rails@859b526
I'm a bit confused about what Rails is doing here. Current edge of
main
definitely allows rack 3, as far as what's in the gemspec. And this commit saying "Merge PR 46594" seems to be committed: rails/rails@1b44989But actual Rails PR 46594 "Allow rack >= 3 in Rails" is still in an open state? rails/rails#46594. (And I think current Rails edge of
main
actually not only allows but possibly requires rack 3.0.x, or at any rate I'm having trouble getting bundler to create a resolution with rack 2.x... I'm getting confused about what's going on in Rails land)At any rate, regardless of what's going on in Rails, capybara is not only used with Rails, and rack 3.0 was released in Nov 2022, and capybara gemspec allows any
rack >= 1.6.0
-- shouldCapybara.server = :webrick
be fixed to work with rack 3?The text was updated successfully, but these errors were encountered: