After upgrading the bosh/integration image from Ruby 3.2 to 3.3, the shellout types unit spec began frequently failing with errors like:
expected RuntimeError with "group 65627 does not exist", got #<RuntimeError:"stat: cannot statx 'a-file20240815-267-utzwlo': No such file or directory\n">
It seems that Ruby 3.3 is much more aggressive about garbage collection. Several of the Tempfiles created in this spec were referenced only locally in a let definition, merely passing their path to the actual object returned by the let. Since the Tempfile object itself was no longer being referenced, it would be garbage collected and the file on disk deleted. Other lets that returned the Tempfile directly did not have this problem.
Now, all usages of Tempfile are defined in their own let, allowing the file to exist until after the test has finished running.
After upgrading the bosh/integration image from Ruby 3.2 to 3.3, the shellout types unit spec began frequently failing with errors like:
It seems that Ruby 3.3 is much more aggressive about garbage collection. Several of the Tempfiles created in this spec were referenced only locally in a
let
definition, merely passing their path to the actual object returned by thelet
. Since the Tempfile object itself was no longer being referenced, it would be garbage collected and the file on disk deleted. Otherlet
s that returned the Tempfile directly did not have this problem.Now, all usages of Tempfile are defined in their own
let
, allowing the file to exist until after the test has finished running.