dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
15.28k stars 4.74k forks source link

Environment.OSVersion returns the incorrect value for macOS 12 Monterey #58575

Open al-cheb opened 3 years ago

al-cheb commented 3 years ago

[Environment]::OSVersion.Version.ToString() should return 12.0.0.

Current behavior:

PS > [Environment]::OSVersion

Platform ServicePack Version VersionString
-------- ----------- ------- -------------
    Unix             11.0.0  Unix 11.0.0

PS > sw_vers
ProductName:    macOS
ProductVersion: 12.0
BuildVersion:   21A5304g

PS >  sysctl -a| grep -e release -e version
user.posix2_version: 200112
kern.osrelease: 21.0.0
kern.version: Darwin Kernel Version 21.0.0: Mon Aug  2 00:18:11 PDT 2021; root:xnu-8019.30.9~9/RELEASE_X86_64
kern.posix1version: 200112
kern.osversion: 21A5304g
kern.iossupportversion: 15.0
kern.osproductversion: 12.0
kern.osproductversioncompat: 10.16
kern.osreleasetype: User
kern.system_version_compat: 0
vm.fault_resilient_media_release: 0
vm.shared_region_version: 3
net.inet.igmp.default_version: 3
net.inet.tcp.mptcp_preferred_version: 0
net.inet6.ip6.kame_version: 2009/apple-darwin
net.mpklog.version: 1
machdep.cpu.arch_perf.version: 1
machdep.cpu.microcode_version: 1070
security.mac.asp.active_rule_version: 10415043430518216312
security.mac.asp.stats.cache_release_count: 0

PS > dotnet --info
.NET SDK (reflecting any global.json):
 Version:   5.0.400
 Commit:    d61950f9bf

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  11.0
 OS Platform: Darwin
 RID:         osx-x64
 Base Path:   /Users/runner/.dotnet/sdk/5.0.400/

Host (useful for support):
  Version: 5.0.9
  Commit:  208e377a53

Expected value:

PS > [Environment]::OSVersion

Platform ServicePack Version VersionString
-------- ----------- ------- -------------
    Unix             12.0.0  Unix 12.0.0
dotnet-issue-labeler[bot] commented 3 years ago

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

KalleOlaviNiemitalo commented 3 years ago

I guess it comes from https://github.com/dotnet/runtime/blob/208e377a5329ad6eb1db5e5fb9d4590fa50beadd/src/libraries/Common/src/Interop/OSX/Interop.libobjc.cs#L54-L61.

Does this mean the .NET Runtime is not yet built "with updated SDK"?

dotnet-issue-labeler[bot] commented 3 years ago

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

ghost commented 3 years ago

Tagging subscribers to this area: @dotnet/area-system-runtime See info in area-owners.md if you want to be subscribed.

Issue Details
[Environment]::OSVersion.Version.ToString() should return 12.0.0. Current behavior: ``` PS > [Environment]::OSVersion Platform ServicePack Version VersionString -------- ----------- ------- ------------- Unix 11.0.0 Unix 11.0.0 PS > sw_vers ProductName: macOS ProductVersion: 12.0 BuildVersion: 21A5304g PS > sysctl -a| grep -e release -e version user.posix2_version: 200112 kern.osrelease: 21.0.0 kern.version: Darwin Kernel Version 21.0.0: Mon Aug 2 00:18:11 PDT 2021; root:xnu-8019.30.9~9/RELEASE_X86_64 kern.posix1version: 200112 kern.osversion: 21A5304g kern.iossupportversion: 15.0 kern.osproductversion: 12.0 kern.osproductversioncompat: 10.16 kern.osreleasetype: User kern.system_version_compat: 0 vm.fault_resilient_media_release: 0 vm.shared_region_version: 3 net.inet.igmp.default_version: 3 net.inet.tcp.mptcp_preferred_version: 0 net.inet6.ip6.kame_version: 2009/apple-darwin net.mpklog.version: 1 machdep.cpu.arch_perf.version: 1 machdep.cpu.microcode_version: 1070 security.mac.asp.active_rule_version: 10415043430518216312 security.mac.asp.stats.cache_release_count: 0 PS > dotnet --info .NET SDK (reflecting any global.json): Version: 5.0.400 Commit: d61950f9bf Runtime Environment: OS Name: Mac OS X OS Version: 11.0 OS Platform: Darwin RID: osx-x64 Base Path: /Users/runner/.dotnet/sdk/5.0.400/ Host (useful for support): Version: 5.0.9 Commit: 208e377a53 ``` Expected value: ``` PS > [Environment]::OSVersion Platform ServicePack Version VersionString -------- ----------- ------- ------------- Unix 12.0.0 Unix 12.0.0 ```
Author: al-cheb
Assignees: -
Labels: `area-System.Runtime`, `untriaged`
Milestone: 6.0.0
vcsjones commented 3 years ago

I can't reproduce this in .NET 6, I think this is something that only applies to .NET 5 and 3.1.

Both the API and and dotnet --info are seem correct for 6.0 on my M1 Mac.

image image
vcsjones commented 3 years ago

This is interesting - it seems that macOS freezes the version you get depending on what SDK you build it with. Based on the code above, it seems that it's getting 10.16 from the OS. It isn't "updating its lie" as 10.17 or similar.

If I tell macOS to not lie about the version, PowerShell starts working accordingly.

image

If what I said about the version being fixed based on the SDK, then #41012 may need to be revisited.

chucker commented 3 years ago

I guess it comes from

https://github.com/dotnet/runtime/blob/208e377a5329ad6eb1db5e5fb9d4590fa50beadd/src/libraries/Common/src/Interop/OSX/Interop.libobjc.cs#L54-L61

. Does this mean the .NET Runtime is not yet built "with updated SDK"?

Can’t .NET simply set SYSTEM_VERSION_COMPAT = 0 and get rid of the above code altogether?

wfurt commented 3 years ago

Since this is global the real question is what else is impacted. I'll check if we can get the real version via sysctl. Also I'm not sure what is oldest version we need to support @danmoseley. Perhaps it is also time to update the SDK we use.

wfurt commented 3 years ago

I got VM up and @vcsjones was right. 6.0 works as expeced and return 12.0 as it it should. This is probably because we use updated SDK and OS does not lie to us. So we should service 5.0 (and perhaps 3.1) @danmoseley but this should not impact 6.0 as far as I can tell.

danmoseley commented 3 years ago

Minimum supported versions are documented here

https://github.com/dotnet/core/blob/main/os-lifecycle-policy.md

6.0 : 10.14 3.1 and 5.0 : 10.13

Highest supported macOS versions are not documented there but historically I believe we have aimed for .NET versions still in support to support the latest released macOS as generally folks upgrade macOS eagerly. @leecow is that right?

jeffhandley commented 3 years ago

Moved to 7.0.0 milestone to reflect that this does not affect 6.0. Even though it also won't affect 7.0.0, we'll want to service 5.0 and possibly 3.1 for this if there's enough justification, so this will be on the radar during the 7.0.0 milestone.

ghost commented 2 years ago

Due to lack of recent activity, this issue has been marked as a candidate for backlog cleanup. It will be closed if no further activity occurs within 14 more days. Any new comment (by anyone, not necessarily the author) will undo this process.

This process is part of our issue cleanup automation.