[ruby-core:113019] [Ruby master Bug#19414] uninitialized constant URI::WSS in 3.0.X and 3.1.X
From:
"nagachika (Tomoyuki Chikanaga) via ruby-core" <ruby-core@...>
Date:
2023-03-26 05:23:15 UTC
List:
ruby-core #113019
Issue #19414 has been updated by nagachika (Tomoyuki Chikanaga).
Backport changed from 2.7: UNKNOWN, 3.0: REQUIRED, 3.1: REQUIRED, 3.2: DONTNEED to 2.7: UNKNOWN, 3.0: REQUIRED, 3.1: DONE, 3.2: DONTNEED
Merged PR into ruby_3_1 at da27583cf364c0d69c085db4abf358c334a8eca1.
----------------------------------------
Bug #19414: uninitialized constant URI::WSS in 3.0.X and 3.1.X
https://bugs.ruby-lang.org/issues/19414#change-102553
* Author: noraj (Alexandre ZANNI)
* Status: Closed
* Priority: Normal
* ruby -v: 3.1.3
* Backport: 2.7: UNKNOWN, 3.0: REQUIRED, 3.1: DONE, 3.2: DONTNEED
----------------------------------------
I have a library called [ctf-party](https://github.com/noraj/ctf-party), [making use of URI:WSS](https://github.com/noraj/ctf-party/blob/ef3b82cc1668325b782246a9bb162b18a9b2930c/lib/ctf_party/defang.rb#L86), and it's making my [CI pipeline fails](https://github.com/noraj/ctf-party/actions/runs/4059895670).
I'm able to reproduce it locally (`bundle exec rake test`), working with ruby 3.2.0 and not with 3.1.3.
The error is:
```
irb(main):001:0> require 'uri'
=> true
irb(main):002:0> URI::WS
=> URI::WS
irb(main):003:0> URI::WSS
(irb):3:in `<main>': uninitialized constant URI::WSS (NameError)
from /home/noraj/.asdf/installs/ruby/3.1.3/lib/ruby/gems/3.1.0/gems/irb-1.4.1/exe/irb:11:in `<top (required)>'
from /home/noraj/.asdf/installs/ruby/3.1.3/bin/irb:25:in `load'
from /home/noraj/.asdf/installs/ruby/3.1.3/bin/irb:25:in `<main>'
```
I don't understand why is that happening since [it exists in the official documentation](https://ruby-doc.org/3.1.3/stdlibs/uri/URI/WSS.html) and the [code looks ok to me on tag 3.1.3](https://github.com/ruby/ruby/blob/v3_1_3/lib/uri/wss.rb) which is [strictly identical to the code on tag 3.2.0](https://github.com/ruby/ruby/blob/v3_2_0/lib/uri/wss.rb).
It works if I require the file explicitly:
```
irb(main):004:0> require 'uri/wss'
=> true
irb(main):005:0> URI::WSS
=> URI::WSS
```
The issue come from the fact that [in 3.2.0 `'uri/wss'` is required](https://github.com/ruby/ruby/blob/v3_2_0/lib/uri.rb#L104) but [not in 3.1.3](https://github.com/ruby/ruby/blob/v3_1_3/lib/uri.rb#L103). In [3.0.5](https://github.com/ruby/ruby/blob/v3_0_5/lib/uri.rb) it is even worse as neither ws and wss are required.
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- ruby-core@ml.ruby-lang.org
To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/