-
Notifications
You must be signed in to change notification settings - Fork 236
fix macos architecture check #1162
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
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -37,6 +37,7 @@ import java.io.File | |
| import java.nio.file.Paths | ||
| import java.util.Locale | ||
| import kotlin.io.path.name | ||
| import kotlin.jvm.optionals.getOrNull | ||
|
|
||
| /** View rendering. */ | ||
| internal class Renderer( | ||
|
|
@@ -188,12 +189,28 @@ internal class Renderer( | |
| } | ||
|
|
||
| private fun getNativeLibDir(): String { | ||
| val osName = System.getProperty("os.name").toLowerCase(Locale.US) | ||
| val osName = System.getProperty("os.name").lowercase(Locale.US) | ||
| val osLabel = when { | ||
| osName.startsWith("windows") -> "win" | ||
| osName.startsWith("mac") -> { | ||
| val osArch = System.getProperty("os.arch").lowercase(Locale.US) | ||
| if (osArch.startsWith("x86")) "mac" else "mac-arm" | ||
| // System.getProperty("os.arch") returns the os of the jre, not necessarily of the platform we are running on, | ||
| // try /usr/bin/arch to get the actual architecture | ||
| val osArch = ProcessBuilder("/usr/bin/arch") | ||
|
||
| .start() | ||
| .inputStream | ||
| .bufferedReader() | ||
| .lines() | ||
| .findFirst() | ||
| .getOrNull() | ||
| ?.lowercase(Locale.US) | ||
|
|
||
| if (osArch != null) { | ||
| if (osArch.startsWith("i386")) "mac" else "mac-arm" | ||
| } else { | ||
| // fallback to jre arch and cross fingers it's correct | ||
| val jreArch = System.getProperty("os.arch").lowercase(Locale.US) | ||
| if (jreArch.startsWith("x86")) "mac" else "mac-arm" | ||
| } | ||
| } | ||
| else -> "linux" | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to my earlier feedback, can we revert this method/Renderer, and instead move the osArch check to
EnvironmentundercheckInstalledJvm? My rationale is that it seems more appropriate to have this logic live in Environment, and leaving Renderer to assume things are set up correctly.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
my hope with this was to not just give a better error message but to actually make it work
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I get that, but I think trying to make it work can lead to other weird behaviors if the native lib artifact downloaded via dependency resolution isn't the expected one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thoughts?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah fair, was trying to spend some time verifying if it would actually work or not, but hadn't reproduced the original issue, at least by running the tests in the repo. Will try to spend more time on if if I can, otherwise, not against your suggestion as a backup, at least makes the issue more clear.