
Issue #20611 has been updated by jbw (Jerry W). Sorry there is a double pipe on the tap call of the first code block - that was a mis-paste by me & I'm unable to edit to correct it. The code I used was the same everywhere (but no double || :-) ):: ff = Tempfile.new('foo'); puts "Size now: #{ff.size}"; File.open(ff.path, "a").tap {|f| f.write('moredata'); f.close } ; ff.size; puts "Finish size: #{ff.size} vs actual: #{File.size(ff.path)}" ---------------------------------------- Bug #20611: Ruby 3.3: Tempfile#size returns 0 when file is not empty https://bugs.ruby-lang.org/issues/20611#change-108995 * Author: jbw (Jerry W) * Status: Open * ruby -v: 3.3.3 * Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN ---------------------------------------- Hi I searched to see if this was reported already, or if it was somehow intentional but I'm having an issue with Ruby 3.3.3. I run under rbenv 2.7.6 on amd64 linux (debian 6.6.13-1 kernel). For me, ruby 3.3.3 exhibits some oddness with the Tempfile class whereas Ruby 3.2 and older does not. I have only tested ruby 3.3.3 not other 3.3.x releases: ff = Tempfile.new('foo'); puts "Size now: #{ff.size}"; File.open(ff.path, "a").tap {|f|| f.write('moredata'); f.close } ; puts "Finish size: #{ff.size} vs actual: #{File.size(ff.path)}" Size now: 0 Finish size: 0 vs actual: 8 As you can see, ff.size should have returned 8. If i try the same code on ruby 3.2.2 for example it works as expected: ff = Tempfile.new('foo'); puts "Size now: #{ff.size}"; File.open(ff.path, "a").tap {|f| f.write('moredata'); f.close } ; ff.size; puts "Finish size: #{ff.size} vs actual: #{File.size(ff.path)}" Size now: 0 Finish size: 8 vs actual: 8 -- https://bugs.ruby-lang.org/