[ruby/erb] Give up on using resolve_feature_path

Apparently `$LOAD_PATH.resolve_feature_path('erb/escape')` returns true
for miniruby but `require 'erb/escape'` fails on it.

I still don't want to check it and rescue LoadError at the same time
because the code looks too complicated. Let me just rescue LoadError for
platforms that don't build native extensions.

https://github.com/ruby/erb/commit/3081c6b20f
This commit is contained in:
Takashi Kokubun 2025-05-13 16:52:03 -07:00 committed by git
parent e8e7daa71a
commit 1d3221ad28

View File

@ -10,9 +10,10 @@ require 'cgi/escape'
# Load or define ERB::Escape#html_escape.
# We don't build the C extention 'cgi/escape' for JRuby, TruffleRuby, and WASM.
if $LOAD_PATH.resolve_feature_path('erb/escape')
# miniruby (used by CRuby build scripts) also fails to load erb/escape.so.
begin
require 'erb/escape'
else
rescue LoadError
# ERB::Escape
#
# A subset of ERB::Util. Unlike ERB::Util#html_escape, we expect/hope