Skip to content

Bug: Cask artifact stanza fails on Linux after bd4eb5ed - Sorbet type mismatch in add_altname_metadata #21147

@bogdan-d

Description

@bogdan-d

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
end

After:

module OS::Linux::Pathname::ClassMethods
  def activate_extensions!
    super
    prepend(ELFShim)
  end
end

This 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

  1. Use Homebrew on Linux (Linuxbrew)
  2. Create/install a cask with an artifact stanza targeting a user directory:
    artifact "source.desktop", target: "\#{Dir.home}/.local/share/applications/target.desktop"
  3. Run: brew install --cask <cask_name>
  4. 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.

Related

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions