Skip to content
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

Cannot find type definitions for library: stringio ([nil]) (RBS::EnvironmentLoader::UnknownLibraryError) when running solargraph scan #738

Open
pangdaxing23 opened this issue Jan 12, 2025 · 2 comments
Assignees

Comments

@pangdaxing23
Copy link

branch: master@d9a0a89308a3337e2ae4d343a46b96e859b99245
ruby version: 3.4.1
stacktrace:

$ solargraph scan
/home/MYUSER/.local/share/mise/installs/ruby/3.4.1/lib/ruby/gems/3.4.0/gems/rbs-3.8.1/lib/rbs/environment_loader.rb:138:in 'block in RBS::EnvironmentLoader#each_dir': Cannot find type definitions for library: stringio ([nil]) (RBS::EnvironmentLoader::UnknownLibraryError)
        from /home/MYUSER/.local/share/mise/installs/ruby/3.4.1/lib/ruby/3.4.0/set.rb:504:in 'Hash#each_key'
        from /home/MYUSER/.local/share/mise/installs/ruby/3.4.1/lib/ruby/3.4.0/set.rb:504:in 'Set#each'
        from /home/MYUSER/.local/share/mise/installs/ruby/3.4.1/lib/ruby/gems/3.4.0/gems/rbs-3.8.1/lib/rbs/environment_loader.rb:136:in 'RBS::EnvironmentLoader#each_dir'
        from /home/MYUSER/.local/share/mise/installs/ruby/3.4.1/lib/ruby/gems/3.4.0/gems/rbs-3.8.1/lib/rbs/environment_loader.rb:157:in 'RBS::EnvironmentLoader#each_signature'
        from /home/MYUSER/.local/share/mise/installs/ruby/3.4.1/lib/ruby/gems/3.4.0/gems/rbs-3.8.1/lib/rbs/environment_loader.rb:121:in 'RBS::EnvironmentLoader#load'
        from /home/MYUSER/.local/share/mise/installs/ruby/3.4.1/lib/ruby/gems/3.4.0/gems/rbs-3.8.1/lib/rbs/environment.rb:172:in 'block in RBS::Environment.from_loader'
        from <internal:kernel>:91:in 'Kernel#tap'
        from /home/MYUSER/.local/share/mise/installs/ruby/3.4.1/lib/ruby/gems/3.4.0/gems/rbs-3.8.1/lib/rbs/environment.rb:171:in 'RBS::Environment.from_loader'
        from /home/MYUSER/.local/share/mise/installs/ruby/3.4.1/lib/ruby/gems/3.4.0/gems/solargraph-0.50.1/lib/solargraph/rbs_map/core_map.rb:16:in 'Solargraph::RbsMap::CoreMap#initialize'
        from /home/MYUSER/.local/share/mise/installs/ruby/3.4.1/lib/ruby/gems/3.4.0/gems/solargraph-0.50.1/lib/solargraph/api_map.rb:24:in 'Class#new'
        from /home/MYUSER/.local/share/mise/installs/ruby/3.4.1/lib/ruby/gems/3.4.0/gems/solargraph-0.50.1/lib/solargraph/api_map.rb:24:in '<class:ApiMap>'
        from /home/MYUSER/.local/share/mise/installs/ruby/3.4.1/lib/ruby/gems/3.4.0/gems/solargraph-0.50.1/lib/solargraph/api_map.rb:13:in '<module:Solargraph>'
        from /home/MYUSER/.local/share/mise/installs/ruby/3.4.1/lib/ruby/gems/3.4.0/gems/solargraph-0.50.1/lib/solargraph/api_map.rb:9:in '<top (required)>'
        from <internal:/home/MYUSER/.local/share/mise/installs/ruby/3.4.1/lib/ruby/3.4.0/rubygems/core_ext/kernel_require.rb>:136:in 'Kernel#require'
        from <internal:/home/MYUSER/.local/share/mise/installs/ruby/3.4.1/lib/ruby/3.4.0/rubygems/core_ext/kernel_require.rb>:136:in 'Kernel#require'
        from /home/MYUSER/.local/share/mise/installs/ruby/3.4.1/lib/ruby/gems/3.4.0/gems/solargraph-0.50.1/lib/solargraph/shell.rb:180:in 'block in Solargraph::Shell#scan'
        from /home/MYUSER/.local/share/mise/installs/ruby/3.4.1/lib/ruby/gems/3.4.0/gems/benchmark-0.4.0/lib/benchmark.rb:304:in 'Benchmark.measure'
        from /home/MYUSER/.local/share/mise/installs/ruby/3.4.1/lib/ruby/gems/3.4.0/gems/solargraph-0.50.1/lib/solargraph/shell.rb:179:in 'Solargraph::Shell#scan'
        from /home/MYUSER/.local/share/mise/installs/ruby/3.4.1/lib/ruby/gems/3.4.0/gems/thor-1.3.2/lib/thor/command.rb:28:in 'Thor::Command#run'
        from /home/MYUSER/.local/share/mise/installs/ruby/3.4.1/lib/ruby/gems/3.4.0/gems/thor-1.3.2/lib/thor/invocation.rb:127:in 'Thor::Invocation#invoke_command'
        from /home/MYUSER/.local/share/mise/installs/ruby/3.4.1/lib/ruby/gems/3.4.0/gems/thor-1.3.2/lib/thor.rb:538:in 'Thor.dispatch'
        from /home/MYUSER/.local/share/mise/installs/ruby/3.4.1/lib/ruby/gems/3.4.0/gems/thor-1.3.2/lib/thor/base.rb:584:in 'Thor::Base::ClassMethods#start'
        from /home/MYUSER/.local/share/mise/installs/ruby/3.4.1/lib/ruby/gems/3.4.0/gems/solargraph-0.50.1/bin/solargraph:5:in '<top (required)>'
        from /home/MYUSER/.local/share/mise/installs/ruby/3.4.1/bin/solargraph:25:in 'Kernel#load'
        from /home/MYUSER/.local/share/mise/installs/ruby/3.4.1/bin/solargraph:25:in '<main>
@pjezusek
Copy link

pjezusek commented Jan 15, 2025

I made a small investigation. It looks like this is because of change in rbs 3.6.0.

I cloned the repository and forced rbs version 3.5.3 - solagraph works (there are some warnings though). It can be a workaround for people that need this asap.

When I leave rbs in '~> 3.0', I have to remove (no_stdlib: true) from rbs_map/core_map.rb#15. The error about stringio is missing but there is a problem with a new type UntypedFunction that was added in ruby/rbs#1806. There are errors about type.type.required_positionals, type.type.optional_positionals etc. Looks like ruby-lsp had a similar problem: Shopify/ruby-lsp#2631

@castwide
Copy link
Owner

I'm currently working on a fix along the same lines of what @pjezusek caught. I'll push it as a PR in case anyone wants to check it out before I merge.

@castwide castwide self-assigned this Jan 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants