如何使用 gem Roo 修复 srb irb 更新错误?或任何选项如何从类型检查中跳过 roo ?

How to fix srb irb update error using gem Roo? or any option how to skip roo from type checking?

我有需要使用 excel xls 的数据管道。我使用 gem roo 读取 xlsx 并推送到某些 API 端点。我开始使用 gem 冰糕的项目。执行 srb init 就可以了。但是当我添加 gem roo 时,它就变成了错误。

如何让 sorbet 只跳过检查 roo gem?或者我该如何解决这个错误?

这是我的 Gemfile 列表。

# frozen_string_literal: true

# typed: ignore

source 'https://rubygems.org'

gem 'activesupport', '< 5.1'
gem 'aws-record', '~> 2'
gem 'aws-sdk-s3', '~> 1'
gem 'faraday'
gem 'pry'
gem 'roo', '2.7.1'
gem 'rspec', group: :development
gem 'rubocop', group: :development
gem 'sorbet', group: :development
gem 'sorbet-runtime'
gem 'uuidtools'

这是冰糕的错误回溯

Generating: sorbet/config
Reusing existing config file: sorbet/config
Generating: sorbet/rbi/sorbet-typed/
Generating: sorbet/rbi/gems/
Traceback (most recent call last):
    14: from /Users/ruby/.rvm/gems/ruby-2.5.1/gems/sorbet-0.4.4540/bin/srb-rbi:234:in `<main>'
    13: from /Users/ruby/.rvm/gems/ruby-2.5.1/gems/sorbet-0.4.4540/bin/srb-rbi:196:in `main'
    12: from /Users/ruby/.rvm/gems/ruby-2.5.1/gems/sorbet-0.4.4540/bin/srb-rbi:118:in `init'
    11: from /Users/ruby/.rvm/gems/ruby-2.5.1/gems/sorbet-0.4.4540/bin/srb-rbi:229:in `block in make_step'
    10: from /Users/ruby/.rvm/gems/ruby-2.5.1/gems/sorbet-0.4.4540/lib/gem-generator-tracepoint.rb:38:in `main'
     9: from /Users/ruby/.rvm/gems/ruby-2.5.1/gems/sorbet-0.4.4540/lib/gem-generator-tracepoint/tracer.rb:70:in `trace'
     8: from /Users/ruby/.rvm/gems/ruby-2.5.1/gems/sorbet-0.4.4540/lib/gem-generator-tracepoint.rb:39:in `block in main'
     7: from /Users/ruby/.rvm/gems/ruby-2.5.1/gems/sorbet-0.4.4540/lib/require_everything.rb:19:in `require_everything'
     6: from /Users/ruby/.rvm/gems/ruby-2.5.1/gems/sorbet-0.4.4540/lib/require_everything.rb:39:in `load_bundler'
     5: from /Users/ruby/.rvm/gems/ruby-2.5.1/gems/sorbet-0.4.4540/lib/gem_loader.rb:579:in `require_all_gems'
     4: from /Users/ruby/.rvm/gems/ruby-2.5.1/gems/sorbet-0.4.4540/lib/gem_loader.rb:579:in `each'
     3: from /Users/ruby/.rvm/gems/ruby-2.5.1/gems/sorbet-0.4.4540/lib/gem_loader.rb:581:in `block in require_all_gems'
     2: from /Users/ruby/.rvm/gems/ruby-2.5.1/gems/sorbet-0.4.4540/lib/gem_loader.rb:557:in `require_gem'
     1: from /Users/ruby/.rvm/gems/ruby-2.5.1/gems/sorbet-0.4.4540/lib/gem_loader.rb:208:in `block in <class:GemLoader>'
/Users/ruby/.rvm/gems/ruby-2.5.1/gems/roo-2.7.1/lib/roo.rb:24:in `const_missing': Excel support has been extracted to roo-xls due to its dependency on the GPL'd spreadsheet gem. Install roo-xls to use Roo::Excel. (RuntimeError)

这是我的 lambda_function.rb

# frozen_string_literal: true

# typed: true
require 'aws-sdk-s3'
require 'json'
require 'pry'
require 'roo'

def lambda_handler(event:, context:)
  response = {
    statusCode: 200,
    body: {
      event: event['filename'],
      context: context
    }
  }

  response
end

event = {
  event: {
    operation: 'echo',
    message: 'Hello world!',
    filename: './penjualan_per_barang_190612145614.xlsx'
  },
  context: {}
}

lambda_handler(event)

我希望 srb 初始化 return 成功。如果有帮助那就太好了。

这看起来像是 Sorbet 中的错误。我在这里创建了一个修复程序:

https://github.com/sorbet/sorbet/pull/1454

除了不依赖 'roo'

,我不确定你应该如何同时解决它