roo: Not compatible with Ruby 3

Steps to reproduce

test.csv

test,test
test2,test2

test.rb

require 'roo'
csv = Roo::CSV.new('test.csv')
puts csv.last_row

Issue

Works with Ruby 2.7.2.

Error with Ruby 3.0.0 Preview 1

/Users/davidangulo/.rbenv/versions/3.0.0-preview1/lib/ruby/3.0.0/csv.rb:1391:in `initialize': no implicit conversion of Hash into String (TypeError)
	from /Users/davidangulo/.rbenv/versions/3.0.0-preview1/lib/ruby/3.0.0/csv.rb:1391:in `open'
	from /Users/davidangulo/.rbenv/versions/3.0.0-preview1/lib/ruby/3.0.0/csv.rb:1391:in `open'
	from /Users/davidangulo/.rbenv/versions/3.0.0-preview1/lib/ruby/3.0.0/csv.rb:1175:in `foreach'
	from /Users/davidangulo/.rbenv/versions/3.0.0-preview1/lib/ruby/gems/3.0.0/gems/roo-2.8.3/lib/roo/csv.rb:96:in `each_row'
	from /Users/davidangulo/.rbenv/versions/3.0.0-preview1/lib/ruby/gems/3.0.0/gems/roo-2.8.3/lib/roo/csv.rb:71:in `read_cells'
	from /Users/davidangulo/.rbenv/versions/3.0.0-preview1/lib/ruby/gems/3.0.0/gems/roo-2.8.3/lib/roo/base.rb:119:in `block (2 levels) in <class:Base>'
	from test.rb:3:in `<main>'

System configuration

Roo version:

gem 'roo', '~> 2.8', '>= 2.8.3'

Ruby version:

  • ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-darwin19] (works)
  • ruby 3.0.0preview1 (2020-09-25 master 0096d2b895) [x86_64-darwin19] (doesn’t work)

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 15
  • Comments: 17 (3 by maintainers)

Most upvoted comments

Thanks for fixing this issue on the master branch! However could you please release a new bugfix version?

It seems master is compatible. Maybe release a new version?

Seconding the need for this fix now that Ruby 3.0 is released

This gem is a dependency of other gems like simple-spreadsheet so a proper release is in order.

Wow. Let me check please. I’m sorry I’m little bit get our due to the situation in Ukraine from where i’m originally.

In case this helps someone, you are able to use the patched code by fetching a specific commit rather than a released gem:

# Until Roo releases a new version containing a fix for Ruby 2.7 deprecation warnings,
# we need to fetch the source directly from GitHub. (https://github.com/roo-rb/roo)
gem "roo", git: "https://github.com/roo-rb/roo.git", ref: "868d4ea419cf393c9d8832838d96c82e47116d2f"

Thank you Erik, but how can I add this commit version of Roo (or the master one) to the global gem system with the unix gem command line tool? (from Ruby-3.0.2) – Maurice

In case this helps someone, you are able to use the patched code by fetching a specific commit rather than a released gem:

# Until Roo releases a new version containing a fix for Ruby 2.7 deprecation warnings,
# we need to fetch the source directly from GitHub. (https://github.com/roo-rb/roo)
gem "roo", git: "https://github.com/roo-rb/roo.git", ref: "868d4ea419cf393c9d8832838d96c82e47116d2f"

@simonoff Thanks a lot… and мир Україні зараз!

@diam I’ve never done that, but I’d try either to build the gem yourself and install it or use the specific_install gem.