ruby / ruby/rbs

[prototype runtime] fails due to `cannot load such file -- sorted_set` with Ruby 3.0

Open
#590 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Ruby
Stars
2.2k
Forks
256
Avg merge
6d 17h
Merged PRs (30d)
37

Description

Hello, I find a bug that the rbs prototype runtime Object command fails on Ruby 3.0 (it succeeds on Ruby 2.7).
Please see the reproduction below for details.

Reproduction

Note: I'm using Docker to reduce any environment-specific problems.

Ruby 3.0

rbs prototype runtime Object fails with LoadError:

$ docker run --rm -it rubylang/ruby:3.0.0-focal bash
# gem install rbs:1.0.4
Fetching rbs-1.0.4.gem
Successfully installed rbs-1.0.4
1 gem installed

# rbs prototype runtime Object
/usr/local/lib/ruby/3.0.0/set/sorted_set.rb:4:in `rescue in <top (required)>': The `SortedSet` class has been extracted from the `set` library.You must use the `sorted_set` gem or other alternatives. (RuntimeError)
	from /usr/local/lib/ruby/3.0.0/set/sorted_set.rb:1:in `<top (required)>'
	from <internal:/usr/local/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
	from <internal:/usr/local/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
	from /usr/local/lib/ruby/gems/3.0.0/gems/rbs-1.0.4/lib/rbs/prototype/runtime.rb:305:in `const_get'
	from /usr/local/lib/ruby/gems/3.0.0/gems/rbs-1.0.4/lib/rbs/prototype/runtime.rb:305:in `block in generate_constants'
	from /usr/local/lib/ruby/gems/3.0.0/gems/rbs-1.0.4/lib/rbs/prototype/runtime.rb:304:in `each'
	from /usr/local/lib/ruby/gems/3.0.0/gems/rbs-1.0.4/lib/rbs/prototype/runtime.rb:304:in `generate_constants'
	from /usr/local/lib/ruby/gems/3.0.0/gems/rbs-1.0.4/lib/rbs/prototype/runtime.rb:385:in `generate_class'
	from /usr/local/lib/ruby/gems/3.0.0/gems/rbs-1.0.4/lib/rbs/prototype/runtime.rb:45:in `block in decls'
	from /usr/local/lib/ruby/gems/3.0.0/gems/rbs-1.0.4/lib/rbs/prototype/runtime.rb:42:in `each'
	from /usr/local/lib/ruby/gems/3.0.0/gems/rbs-1.0.4/lib/rbs/prototype/runtime.rb:42:in `decls'
	from /usr/local/lib/ruby/gems/3.0.0/gems/rbs-1.0.4/lib/rbs/cli.rb:597:in `run_prototype'
	from /usr/local/lib/ruby/gems/3.0.0/gems/rbs-1.0.4/lib/rbs/cli.rb:113:in `run'
	from /usr/local/lib/ruby/gems/3.0.0/gems/rbs-1.0.4/exe/rbs:7:in `<top (required)>'
	from /usr/local/bin/rbs:23:in `load'
	from /usr/local/bin/rbs:23:in `<main>'
<internal:/usr/local/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require': cannot load such file -- sorted_set (LoadError)
	from <internal:/usr/local/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
	from /usr/local/lib/ruby/3.0.0/set/sorted_set.rb:2:in `<top (required)>'
	from <internal:/usr/local/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
	from <internal:/usr/local/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
	from /usr/local/lib/ruby/gems/3.0.0/gems/rbs-1.0.4/lib/rbs/prototype/runtime.rb:305:in `const_get'
	from /usr/local/lib/ruby/gems/3.0.0/gems/rbs-1.0.4/lib/rbs/prototype/runtime.rb:305:in `block in generate_constants'
	from /usr/local/lib/ruby/gems/3.0.0/gems/rbs-1.0.4/lib/rbs/prototype/runtime.rb:304:in `each'
	from /usr/local/lib/ruby/gems/3.0.0/gems/rbs-1.0.4/lib/rbs/prototype/runtime.rb:304:in `generate_constants'
	from /usr/local/lib/ruby/gems/3.0.0/gems/rbs-1.0.4/lib/rbs/prototype/runtime.rb:385:in `generate_class'
	from /usr/local/lib/ruby/gems/3.0.0/gems/rbs-1.0.4/lib/rbs/prototype/runtime.rb:45:in `block in decls'
	from /usr/local/lib/ruby/gems/3.0.0/gems/rbs-1.0.4/lib/rbs/prototype/runtime.rb:42:in `each'
	from /usr/local/lib/ruby/gems/3.0.0/gems/rbs-1.0.4/lib/rbs/prototype/runtime.rb:42:in `decls'
	from /usr/local/lib/ruby/gems/3.0.0/gems/rbs-1.0.4/lib/rbs/cli.rb:597:in `run_prototype'
	from /usr/local/lib/ruby/gems/3.0.0/gems/rbs-1.0.4/lib/rbs/cli.rb:113:in `run'
	from /usr/local/lib/ruby/gems/3.0.0/gems/rbs-1.0.4/exe/rbs:7:in `<top (required)>'
	from /usr/local/bin/rbs:23:in `load'
	from /usr/local/bin/rbs:23:in `<main>'
Ruby 2.7

rbs prototype runtime Object has no problems:

$ docker run --rm -it rubylang/ruby:2.7.2-bionic bash
# gem install rbs:1.0.4
Fetching rbs-1.0.4.gem
Successfully installed rbs-1.0.4
1 gem installed

# rbs prototype runtime Object
class Object < BasicObject
  include PP::ObjectMixin

  include JSON::Ext::Generator::GeneratorMethods::Object

  include Kernel
end

Object::ARGF: ARGF.class

Object::ARGV: Array[untyped]

Object::CROSS_COMPILING: untyped?

Object::ENV: Object

Object::FALSE: bool

Object::NIL: untyped?

Object::RUBY_COPYRIGHT: String

Object::RUBY_DESCRIPTION: String

Object::RUBY_ENGINE: String

Object::RUBY_ENGINE_VERSION: String

Object::RUBY_PATCHLEVEL: Integer

Object::RUBY_PLATFORM: String

Object::RUBY_RELEASE_DATE: String

Object::RUBY_REVISION: String

Object::RUBY_VERSION: String

Object::STDERR: IO

Object::STDIN: IO

Object::STDOUT: IO

Object::TOPLEVEL_BINDING: Binding

Object::TRUE: bool

Environment

  • Ruby: ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-linux]
  • RBS: rbs 1.0.4

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at lib/rbs/prototype/runtime.rb around line 305, where the reported Ruby 3.0 stack trace shows constant loading reaches sorted_set. Reproduce with rbs prototype runtime Object on Ruby 3.0 and compare with Ruby 2.7; done means the command completes successfully on Ruby 3.0 without the reported LoadError.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.