Closed mathieujobin closed 2 years ago
WEBrick is the fallback, i.e., puma or other rack based adapters will always be used if they exist prior to webrick.
The challenge is that YARD needs at least one guaranteed-to-be-present HTTP server library on your system to function properly, specifically webrick is needed for underlying mime type parsing in yard server
. Unfortunately RubyGems is not smart enough to allow for either-or style dependencies, so there is no way for YARD to require "either puma or webrick" and we must make a decision to guarantee that YARD works out of the box without any specific HTTP dependencies.
This was not a problem in Ruby 2.x when webrick was part of the distribution. You can blame Ruby for removing this default from the library in 3.0+. See #1387 for details.
That is a good point. But not without a solution.
Webrick could be set as a dev dependency for tests to pass and all.
And when puma isn't available and it falls back to webrick which is also missing. Then it would simply raise an error.
I see the other issue made you do the exact opposite.
Forcing people to add it to their gemfile when desired would not have been too bad in my opinion
webrick is needed for underlying mime type parsing in yard server
I don't use YARD server that often, so I'm not familiar with the code, but...
YARD::Server::Commands::StaticFileHelpers
is including WEBrick::HTTPUtils
, maybe for its DefaultMimeTypes
hash constant and mime_type
method. That functionality is also in Rack::Mime
.
Since WEBrick
isn't in the std-lib anymore, maybe switch to the Rack version? Could be done at runtime? Not.Sure.
yard is the only gem left that requires webrick in my application. and I was wondering if it was possible to make it optional ?
Thanks
Steps to reproduce
use yard
Actual Output
webrick is required
Expected Output
webrick is not, fallback to puma
Environment details:
ruby -v
): 2.7.5yard -v
): 0.9.27