The path is correct, the proof is that the former issue with #read is not happening anymore.
I'm running the code with : bundle exec ruby main.rb
Ruby version : 3.1.2p20
Steps to reproduce the issue :
Open a csv file with CSV.open('file.csv')
Call #pos on it, it returns 0
Call #eof? on it, it returns false
Call #each, #map, or #filter on it
Call #pos on it, it returns the last position
Call #eof? on it, it returns false when it should be true
main.rb
require 'csv'
# it returns true on the second call of #eof? as expected only if
# I comment the 4th line, starting from the line below this
puts 'csv'
csv = CSV.open('event_attendees.csv')
puts "pos : #{csv.pos}" # expecting 0, getting 0
puts "eof? : #{csv.eof?}" # expecting false, getting false
csv.each { |row| row }
puts "pos : #{csv.pos}" # expecting 1814, getting 1814
puts "eof? : #{csv.eof?}" # expecting true, getting false
puts
# no issue when using File.open
puts 'File'
file = File.open('event_attendees.csv')
puts "pos : #{file.pos}" # expecting 0, getting 0
puts "eof? : #{file.eof?}" # expecting false, getting false
file.each { |row| row }
puts "pos : #{file.pos}" # expecting 1814, getting 1814
puts "eof? : #{file.eof?}" # expecting true, getting true
This is almost the same bug I mentioned in this issue https://github.com/ruby/csv/issues/258 (which got fixed), but instead of reading the file with #read, I'm using the #each method on the csv file, #map and #filter also cause the issue.
For reference : I cloned this repository on my local machine, then in my Gemfile I put :
The path is correct, the proof is that the former issue with #read is not happening anymore. I'm running the code with :
bundle exec ruby main.rb
Ruby version : 3.1.2p20 Steps to reproduce the issue :
main.rb
This is almost the same bug I mentioned in this issue https://github.com/ruby/csv/issues/258 (which got fixed), but instead of reading the file with #read, I'm using the #each method on the csv file, #map and #filter also cause the issue.
event_attendees.csv