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

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

Open
Tracked by #64603
al-cheb opened this issue Sep 1, 2021 · 12 comments
Open
Tracked by #64603

Comments

@al-cheb
Copy link

al-cheb commented Sep 1, 2021

[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
Copy link

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
Copy link

I guess it comes from

if (major == 10 && minor == 16)
{
// We get "compat" version for 11.0 unless we build with updated SDK.
// Hopefully that will be before 11.x comes out
// For now, this maps 10.16 to 11.0.
major = 11;
minor = 0;
}
.

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

@danmoseley danmoseley transferred this issue from dotnet/sdk Sep 2, 2021
@dotnet-issue-labeler
Copy link

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.

@dotnet-issue-labeler dotnet-issue-labeler bot added the untriaged New issue has not been triaged by the area owner label Sep 2, 2021
@danmoseley danmoseley added this to the 6.0.0 milestone Sep 2, 2021
@ghost
Copy link

ghost commented Sep 2, 2021

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

@jeffschwMSFT jeffschwMSFT removed the untriaged New issue has not been triaged by the area owner label Sep 2, 2021
@vcsjones
Copy link
Member

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
Copy link
Member

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
Copy link

chucker commented Sep 10, 2021

I guess it comes from

if (major == 10 && minor == 16)
{
// We get "compat" version for 11.0 unless we build with updated SDK.
// Hopefully that will be before 11.x comes out
// For now, this maps 10.16 to 11.0.
major = 11;
minor = 0;
}

.
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
Copy link
Member

wfurt commented Sep 10, 2021

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
Copy link
Member

wfurt commented Sep 13, 2021

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
Copy link
Member

danmoseley commented Sep 13, 2021

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
Copy link
Member

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
Copy link

ghost commented Jul 9, 2022

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.

@ghost ghost added the no-recent-activity label Jul 9, 2022
@jeffhandley jeffhandley modified the milestones: 7.0.0, Future Jul 10, 2022
@ghost ghost removed the no-recent-activity label Jul 10, 2022
@ghost ghost removed the backlog-cleanup-candidate An inactive issue that has been marked for automated closure. label Jul 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants