csv: CSV.generate is not working with Rails 7

I currently updated my app to rails 7.0.2 and since unable to generate the CSV using this gem. I am getting the following error,

> CSV.generate(headers: true)
ArgumentError: Cannot parse nil as CSV
from /usr/local/bundle/gems/csv-3.2.3/lib/csv.rb:1893:in `initialize'

I have tested this and this is working fine with the previous version of rails.

Ruby version ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x86_64-linux]

Rails version Rails 7.0.2.3

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 18 (9 by maintainers)

Most upvoted comments

You can use local csv by using gem "csv", path: "/local/path/to/csv" in your Gemfile:

$ git clone https:///github.com/ruby/csv.git /tmp/csv
$ editor Gemfile
(Replace 'gem "csv"' with 'gem "csv", path: "/tmp/csv".)
$ bundle instlal
$ ...

Could you also show full backtrace of:

> CSV.generate(headers: true)
ArgumentError: Cannot parse nil as CSV
from /usr/local/bundle/gems/csv-3.2.3/lib/csv.rb:1893:in `initialize'

Can you provide an script to reproduce this issue? it will be easier to pip-point the issue. Probably this is not a CSV problem, specially if it’s noted only when you upgrade Rails - so I’d suggest to review with and without Rails in your bundle.