gay*_*vat 5 ruby ruby-3 rbs steep
Cannot find type `Sinatra::Base`
Run Code Online (Sandbox Code Playgroud)
红宝石文件
class StaticApp < Sinatra::Base
end
Run Code Online (Sandbox Code Playgroud)
.rbs 文件
class StaticApp < Sinatra::Base
end
Run Code Online (Sandbox Code Playgroud)
跑步
bundle exec steep check --log-level=fatal
Run Code Online (Sandbox Code Playgroud)
结果
[error] Cannot find type `Sinatra::Base`
Diagnostic ID: RBS::UnknownTypeName
Run Code Online (Sandbox Code Playgroud)
我用steep宝石。看来需要一些文件。但
library 'sinatra'
Run Code Online (Sandbox Code Playgroud)
不起作用。
#<RBS::EnvironmentLoader::UnknownLibraryError: Cannot find type definitions for library: sinatra ([nil])>
Run Code Online (Sandbox Code Playgroud)
我有什么错吗?谢谢。
但
library 'sinatra'不起作用..RBS::EnvironmentLoader::UnknownLibraryError
# Steepfile
target :app do
repo_path 'vendor/rbs'
Run Code Online (Sandbox Code Playgroud)
创建一个类似 的目录结构vendor/rbs/sinatra/0/sinatra.rbs。
如何编写或生成 的内容sinatra.rbs超出了本答案的范围,但请查看:
Steep 正在使用RBS::EnvironmentLoader.
# steep-0.47.0/lib/steep/project/target.rb:54
loader = RBS::EnvironmentLoader.new(core_root: core_root_path, repository: repo)
options.libraries.each do |lib|
name, version = lib.split(/:/, 2)
loader.add(library: name, version: version)
end
Run Code Online (Sandbox Code Playgroud)
可以在其中之一EnvironmentLoader(我认为这将是分布在 gem 中的文件夹)或.librarygem_sig_pathsigrepository
# rbs-1.7.1/lib/rbs/environment_loader.rb:68
def has_library?(library:, version:)
if self.class.gem_sig_path(library, version) || repository.lookup(library, version)
true
else
false
end
end
Run Code Online (Sandbox Code Playgroud)
在 a 中Steepfile,存储库是通过repo_path.
# Steepfile
repo_path 'vendor/rbs'
Run Code Online (Sandbox Code Playgroud)
对于存储库的目录结构,我以https://github.com/ruby/rbs/tree/master/stdlib为例。
ls -R vendor/rbs
activesupport
vendor/rbs/activesupport:
0
vendor/rbs/activesupport/0:
activesupport.rbs
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1004 次 |
| 最近记录: |