roo-rb / roo

Roo provides an interface to spreadsheets of several sorts.
MIT License
2.78k stars 503 forks source link

Not compatible with Ruby 3 #551

Closed dcangulo closed 2 years ago

dcangulo commented 3 years ago

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:

jonspalmer commented 3 years ago

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

donv commented 3 years ago

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

tasiorsky commented 3 years ago

any chances of releasing update soon?

pioz commented 3 years ago

Same problem here!

larskanis commented 3 years ago

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

uzian commented 3 years ago

@larskanis please pardon my ignorance, but where is the fix 'on the master branch' that you are mentioning? At this moment I can use anything, to be honest, this issue is impacting live services of my application :(

larskanis commented 3 years ago

@uzian Commit https://github.com/roo-rb/roo/commit/22d99302b34c5a38acfc2806daaf94a449f1e821 fixes compatibility with Ruby-3.0.

erikbrannstrom commented 3 years ago

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"
diam commented 3 years ago

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

erikbrannstrom commented 3 years ago

@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.

diam commented 3 years ago

Thanks Erik, I didn't know the specific_install gem extension! So the following commands solved the problem:

  gem uninstall roo
  gem install specific_install
  gem specific_install -l https://github.com/roo-rb/roo.git -r 868d4

-- Maurice

Edit: but I don't know what would happen if I did a gem update or something like that. So an update to the official gem would be welcome ;-)

jasonperrone commented 2 years ago

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

svoop commented 2 years ago

@simonoff Any chance you could initiate a patchlevel release containing the fix mentioned above? It's sad to see this useful have test suites turn red for so many – even more so since the fix will soon celebrate it's first anniversary. Thanks a bunch!

simonoff commented 2 years ago

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.

svoop commented 2 years ago

OT: I feel you, been working all week on our little studio to prep it for war refugees from UA.

simonoff commented 2 years ago

@svoop Done!

svoop commented 2 years ago

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