Bug #20611
closedRuby 3.3: Tempfile#size returns 0 when file is not empty
Description
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