kmath
kmath copied to clipboard
Can't Build With Gradle On Mac M1
I've pulled the repo and tried to build without success.
Current environment:
- MacBook Pro M1 with Monterey 12.4
- OpenJDK 17.0.1+12
- Kotlin 1.7.0
- Gradle 7.4.2 (downgraded from 8.x using sdk)
- node 14.17.0 (downgraded from 16.14.1 using nvm)
I open a terminal shell, navigate to the root of the project, and execute
./gradlew build
The build fails with this message:
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':kotlinNodeJsSetup'.
> Could not resolve all files for configuration ':detachedConfiguration1'.
> Could not find org.nodejs:node:14.17.0.
Searched in the following locations:
- https://repo.kotlin.link/org/nodejs/node/14.17.0/node-14.17.0.pom
- https://oss.sonatype.org/content/repositories/snapshots/org/nodejs/node/14.17.0/node-14.17.0.pom
- https://repo.maven.apache.org/maven2/org/nodejs/node/14.17.0/node-14.17.0.pom
- https://nodejs.org/dist/v14.17.0/node-v14.17.0-darwin-arm64.tar.gz
Required by:
project :
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
* Get more help at https://help.gradle.org
Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
See https://docs.gradle.org/7.4.2/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 2s
7 actionable tasks: 7 up-to-date
Adding flags isn't providing any new insights.
I have node 14.17.0 installed. Are there build files that need version upgrades?
I think that you need to force gradle to use existing node distribution. Try adding this to the root project.
Hi Alex,
Thank you for your response.
I modified my build.gradle.kts as follows:
// see https://youtrack.jetbrains.com/issue/KT-49109#focus=Comments-27-5381158.0-0 rootProject.plugins.withType<org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootPlugin> { rootProject.the<org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension>().nodeVersion = "15.14.0" rootProject.the<org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension>().download = false }
When I run a grade clean build I get another error, this time for yarn:
Task :kotlinNpmInstall error An unexpected error occurred: "https://registry.yarnpkg.com/mocha/-/mocha-9.1.2.tgz: incorrect data check".
Task :kmath-stat:compileKotlinIosArm64 w: /Users/michaelduffy/Code/java/kmath/kmath-stat/src/commonMain/kotlin/space/kscience/kmath/stat/Sampler.kt: (42, 30): This API is unstable and could change in future
Task :kotlinNpmInstall FAILED
FAILURE: Build failed with an exception.
- What went wrong: Execution failed for task ':kotlinNpmInstall'.
Process 'Resolving NPM dependencies using yarn' returns 1
yarn install v1.22.10
info No lockfile found. [1/4] Resolving packages... [2/4] Fetching packages... info If you think this is a bug, please open a bug report with the information provided in "/Users/michaelduffy/Code/java/kmath/build/js/yarn-error.log". info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
- Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
- Get more help at https://help.gradle.org
Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
See https://docs.gradle.org/7.4.2/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 12s 184 actionable tasks: 89 executed, 95 up-to-date
I’ve got yarn version 1.22.19 installed on my Mac:
(base) @.*** kmath % yarn --version 1.22.19
What’s my next step? I apologize in advance for being a bother. - Michael
On Jun 24, 2022, at 3:15 AM, Alexander Nozik @.***> wrote:
I think that you need to force gradle to use existing node distribution. Try adding this https://kotlinlang.org/docs/js-project-setup.html#node-js to the root project.
— Reply to this email directly, view it on GitHub https://github.com/mipt-npm/kmath/issues/493#issuecomment-1165276940, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAI77GW6EESE2YNGSP7B76TVQVOAXANCNFSM5ZE3TB7A. You are receiving this because you authored the thread.
The problem is not in KMath, but in NodeJS and yart interacting with M1. I can try to give several suggestions, but I can't test them since I do not use Mac, so it will be like trial and error. It is currently not possible to turn off JS part without a lot of work.
So suggestions:
- Clean before build to ensure that downloaded node is purged.
- Make sure to delete
kotlin-js-storedirectory in the root of project. It stores versions for JS dependencies, they could cause conflicts. - Install newer node. LTS seems to be 16.15.1.
- Try to clear system yarn cache.
Feel free to contact me in kotlin slack in mathematics for more interactive solution.
According to https://youtrack.jetbrains.com/issue/KT-49109/, you need at least nodejs 16 on Apple-M1