Skip to content

Fix File.open Ruby 3.2 regression in FileSystem::Uniquefile#450

Merged
Sharpie merged 1 commit into
OpenVoxProject:mainfrom
JonasVerhofste:main
Jun 9, 2026
Merged

Fix File.open Ruby 3.2 regression in FileSystem::Uniquefile#450
Sharpie merged 1 commit into
OpenVoxProject:mainfrom
JonasVerhofste:main

Conversation

@JonasVerhofste

Copy link
Copy Markdown
Contributor

Short description

Ruby 3.2 changed the method call of File.open() such that it always requires perm as an argument if you want to pass other opts. It also started requiring opts to be splatted, instead of passed as a hash.

I didn't go through the whole codebase to see if there are other places where this regression (can) happen(s). I just ran into this one when working on an older internal provider that uses Puppet::FileSystem::Uniquefile.new() directly (not through the open_tmp() method).

Old method definition:

open(filename, mode="r" [, opt]) → file
open(filename [, mode [, perm]] [, opt]) → file
open(filename, mode="r" [, opt]) {|file| block } → obj
open(filename [, mode [, perm]] [, opt]) {|file| block } → obj

New method definition:

open(path, mode = 'r', perm = 0666, **opts) → file
open(path, mode = 'r', perm = 0666, **opts) {|f| ... } → object

Checklist

I have:

@JonasVerhofste JonasVerhofste force-pushed the main branch 2 times, most recently from 9f19720 to b5a1ef1 Compare May 19, 2026 02:06
@JonasVerhofste JonasVerhofste force-pushed the main branch 2 times, most recently from c996399 to ff6cb9c Compare June 1, 2026 23:48
JonasVerhofste added a commit to UGent-DICT/puppet-openssl that referenced this pull request Jun 3, 2026
JonasVerhofste added a commit to UGent-DICT/puppet-openssl that referenced this pull request Jun 3, 2026
Ruby 3.2 changed the method call of File.open() such that it always
requires `perm` as an argument if you want to pass other `opts`.
It also started requiring opts to be splatted, instead of passed as a hash.

Old method definition:
```
open(filename, mode="r" [, opt]) → file
open(filename [, mode [, perm]] [, opt]) → file
open(filename, mode="r" [, opt]) {|file| block } → obj
open(filename [, mode [, perm]] [, opt]) {|file| block } → obj
```

New method definition:
```
open(path, mode = 'r', perm = 0666, **opts) → file
open(path, mode = 'r', perm = 0666, **opts) {|f| ... } → object
```

Signed-off-by: Jonas Verhofsté <jonas@verhofste.tech>
@bastelfreak bastelfreak added the bug Something isn't working label Jun 9, 2026
@Sharpie Sharpie enabled auto-merge June 9, 2026 18:53
@Sharpie Sharpie merged commit 7bd1148 into OpenVoxProject:main Jun 9, 2026
18 checks passed
@Sharpie Sharpie added the backport 8.x backports the merged PR to the 8.x branch label Jun 9, 2026
@OpenVoxProjectBot

Copy link
Copy Markdown
Contributor

Successfully created backport PR for 8.x:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport 8.x backports the merged PR to the 8.x branch bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants