Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect version returned for macOS Big Sur #10

Closed
aguynamedben opened this issue Dec 2, 2020 · 5 comments
Closed

Incorrect version returned for macOS Big Sur #10

aguynamedben opened this issue Dec 2, 2020 · 5 comments

Comments

@aguynamedben
Copy link

aguynamedben commented Dec 2, 2020

First, thank you for all the amazing open source libraries you've provided and supported over the years. You're a hero.

I think this repo needs to be updated for proper Big Sur support. I'm getting 10.16.0 as macOS version while running Big Sur 11.0.1. I can look into making a PR later tonight but just wanted to point it out first and make sure I wasn't missing something simple.

code

import macosRelease from 'macos-release';
import macosVersion from 'macos-version';

//...

log.info(`macOS Release: ${macosRelease().name} ${macosRelease().version}`);
log.info(`macOS Version: ${macosVersion()}`);

output

macOS Release: Big Sur 11
macOS Version: 10.16.0

versions
macos-release: 2.4.1
macos-version: 5.2.0

my computer
image

@aguynamedben
Copy link
Author

Looking at how this works, I'm not sure how this could be happening given what my plist file has.

cat /System/Library/CoreServices/SystemVersion.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
        <key>ProductBuildVersion</key>
        <string>20B50</string>
        <key>ProductCopyright</key>
        <string>1983-2020 Apple Inc.</string>
        <key>ProductName</key>
        <string>macOS</string>
        <key>ProductUserVisibleVersion</key>
        <string>11.0.1</string>
        <key>ProductVersion</key>
        <string>11.0.1</string>
        <key>iOSSupportVersion</key>
        <string>14.2</string>
</dict>
</plist>

🤔

@aguynamedben
Copy link
Author

aguynamedben commented Dec 2, 2020

Marketing

  • Catalina: macOS 10.15
  • Big Sur: macOS 11

Plist file

  • Catalina: macOS 10.15
  • Big Sur: macOS 10.16

macos-release seems to use os.version(), then correctly maps the kernel version to the marketing version.

macos-version uses the plist file. I don't know why the plist file has 10.16. 🤷‍♂️

@sindresorhus
Copy link
Owner

AFAIK, it has that for compatibility reasons. We can just do the 10.16 to 11 mapping ourselves.

@aguynamedben
Copy link
Author

It seems like 10.16 is a historical artifact of the Big Sur release and Apple preparing for the M1/ARM processor. https://appleinsider.com/inside/macos-10.16 From my read, it seems like 10.16 became Big Sur.

Doing the mapping ourselves is fine, but then we kind of have the problem of which value to map to for the PATCH version (semver). i.e. should we map 10.16 to 11.0.0, 11.0.1, etc. That data is no longer in the plist file for the Big Sur release.

For my use, just knowing 'Big Sur' is fine so I think macos-release is a better alternative.

@sindresorhus
Copy link
Owner

From what I can remember, the plist given depends on whether the binary opening it has been compiled with the latest SDK or not. For older binaries, I think it will forever stay as 10.16, so I think it should be safe to just do a simple swap of exactly 10.16.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants