0

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

我怎样才能告诉冰糕只跳过检查 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 init 会返回成功。如果有任何帮助,那就太好了。

4

1 回答 1

0

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

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

我不确定除了不依赖于'roo'.

于 2019-08-01T02:57:44.253 回答