-
-
Notifications
You must be signed in to change notification settings - Fork 10.7k
Description
Bug Description
After commit bd4eb5edc679f3c444e43e36784febcb6cb28af5 ("Only use MachOShim/ELFShim when required", Nov 29 2025), installing casks that use the artifact stanza on Linux fails with a Sorbet type validation error.
Error Message
Error: Parameter 'file': Expected type OS::Linux::Pathname, got type Pathname with value #<Pathname:/home/user/.local/share/applications/example.desktop>
Caller: .../cask/artifact/moved.rb:134
Definition: .../extend/os/linux/cask/artifact/relocated.rb:14 (OS::Linux::Cask::Artifact::Relocated#add_altname_metadata)
Root Cause
The commit changed how ELFShim is applied to Pathname on Linux for performance reasons:
Before:
class Pathname
prepend ELFShim
endAfter:
module OS::Linux::Pathname::ClassMethods
def activate_extensions!
super
prepend(ELFShim)
end
endThis means some Pathname objects now have ELFShim mixed in (becoming OS::Linux::Pathname) while others don't. When post_move in moved.rb:134 calls add_altname_metadata(target, source.basename, command:), there's a type mismatch between what Sorbet expects and what's actually passed.
The type signature in extend/os/linux/cask/artifact/relocated.rb declares:
sig { params(file: Pathname, altname: Pathname, command: T.class_of(SystemCommand)).returns(T.nilable(SystemCommand::Result)) }But the actual target variable being passed is a different Pathname variant.
Steps to Reproduce
- Use Homebrew on Linux (Linuxbrew)
- Create/install a cask with an
artifactstanza targeting a user directory:artifact "source.desktop", target: "\#{Dir.home}/.local/share/applications/target.desktop"
- Run:
brew install --cask <cask_name> - Installation fails with the Sorbet type mismatch error
Expected Behavior
The artifact stanza should work correctly on Linux without type validation errors.
System Information
Homebrew 5.0.3-62-ga766abe
Linux (Linuxbrew)
Workaround
Cask authors can replace the artifact stanza with manual file copy operations in preflight/uninstall_preflight blocks.