When installing software via a .pkg file downloaded from the Internet, macOS may display the following error:

"xxx.pkg" cannot be opened because Apple cannot check it for malicious software.

This behavior is caused by Gatekeeper, a macOS security feature. Starting with macOS Catalina (macOS 10.15), Apple requires all .pkg packages to be signed and notarized by its services. However, many applications available on the Internet do not pass this validation — even if they are legitimate.

In this article, we use the installation of PowerShell 7.5.1 as an example, but the same method applies to any other software showing the same warning message.

1. Finder solution (classic method, often non-functional)

This method used to work but no longer functions reliably with recent versions of some software.
  1. Open the folder containing the .pkg file in Finder.
  2. Hold the CTRL key and click the file.
  3. Select Open.
  4. In the warning dialog, click Open again.

macOS adds a com.apple.quarantine attribute to files downloaded via a browser. You can remove it using the Terminal:

sudo xattr -rd com.apple.quarantine xxx.pkg

For our example of unblocking PowerShell 7.5.1 :

sudo xattr -rd com.apple.quarantine ~/Downloads/powershell-7.5.1-osx-arm64.pkg 

This command recursively removes all quarantine attributes from the file and its associated metadata.
Then, launch the .pkg file normally (by double-clicking it or using the open command).

3. Alternative solution: unblock via PowerShell

If you already have a working version of PowerShell installed on your Mac, you can unblock the file using:

Unblock-File -Path xxx.pkg

For our example to unblock PowerShell 7.5.1:

Unblock-File -Path ~/Downloads/powershell-7.5.1-osx-arm64.pkg

Comments

banner-Bastien Perez
Bastien Perez's avatar

Freelance Microsoft 365 - Active Directory - Modern Workplace

France