Hello, I'm trying to build ktor on my Windows PC, ...
# ktor
g
Hello, I'm trying to build ktor on my Windows PC, but can't get it to work properly Every build fails with following erros:
Copy code
e: file:///C:/Users/Gleb/repos/ktor/ktor-io/common/src/io/ktor/utils/io/ByteWriteChannelOperations.kt:129:23 Unresolved reference 'CoroutineContext'.
e: file:///C:/Users/Gleb/repos/ktor/ktor-io/common/src/io/ktor/utils/io/ByteWriteChannelOperations.kt:129:42 Unresolved reference 'EmptyCoroutineContext'.
e: file:///C:/Users/Gleb/repos/ktor/ktor-io/common/src/io/ktor/utils/io/ByteWriteChannelOperations.kt:136:23 Unresolved reference 'CoroutineContext'.
e: file:///C:/Users/Gleb/repos/ktor/ktor-io/common/src/io/ktor/utils/io/ByteWriteChannelOperations.kt:136:42 Unresolved reference 'EmptyCoroutineContext'.
e: file:///C:/Users/Gleb/repos/ktor/ktor-io/common/src/io/ktor/utils/io/ByteWriteChannelOperations.kt:140:15 Cannot access class 'kotlin.coroutines.CoroutineContext'. Check your module classpath for missing or conflicting dependencies.
e: file:///C:/Users/Gleb/repos/ktor/ktor-io/common/src/io/ktor/utils/io/ByteWriteChannelOperations.kt:141:31 Cannot access class 'kotlin.coroutines.CoroutineContext'. Check your module classpath for missing or conflicting dependencies.
...
This happens for fresh cloned project, clean gradle cache (I removed everything in ~/.gradle/caches), when I try to build with
--no-build-cache
option for some reason I though that some of the dependencies could not be downloaded, and there are results for
.\gradlew.bat dependencies
command:
Copy code
jvmTestRuntimeClasspath - Runtime classpath of 'jvm/test'.
+--- org.jetbrains.kotlinx:kotlinx-coroutines-core:1.8.1
|    \--- org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.8.1
....
|    \--- org.jetbrains.kotlinx:kotlinx-coroutines-bom:1.8.1 (*)
+--- org.slf4j:slf4j-api:2.0.16
+--- org.jetbrains.kotlin:kotlin-test:2.0.20 FAILED
Some modules could not resolve
org.jetbrains.kotlin:kotlin-test:2.0.20
dependency Did anyone stumble upon this error? How can I fix this?
I also tried to build project in my WSL2 environment (connecting through remote development) but it also was unsuccessful:
Copy code
A problem occurred configuring root project 'ktor'.
> =============================== Gradle Doctor Prescriptions ============================================
  | JAVA_HOME is not set.                                                                                |
  | Please set JAVA_HOME so that switching between Android Studio and the terminal does not trigger a fu |
  | ll rebuild.                                                                                          |
  | To set JAVA_HOME: (using bash)                                                                       |
  | echo "export JAVA_HOME=$(/usr/libexec/java_home)" >> ~/.bash_profile                                 |
  | or `~/.zshrc` if using zsh.                                                                          |
  |                                                                                                      |
  ========================================================================================================
Even though I can verify that I've set the JAVA_HOME environment, I can't see it in Gradle JVM options in Build Tools Would appreciate any help for building it either on windows or wsl 🙂
r
Those packages that the first error is saying it can't resolve look like they are apart of the kotlin stdlib
can you share your build.gradle file?
g
I didn't change it at all, it's the same as in main branch https://github.com/stokado/ktor/blob/main/build.gradle.kts
r
curious, why are you using a forked version of ktor?
g
I want to contribute 🙂 It is said to fork and then open a PR into the main repo on contributing guide
r
sorry, i'm understanding, you're not trying to run a ktor app, you're trying to contribute
g
yes
I was able to build ktor on my mac, but only the first build is successful but all subsequent builds are failed with java heap space out of memory (my laptop has 16 Gb)
I'm wondering if it is easier to buy a new hard drive, install any linux distro and build ktor there 🫠
r
kk, if i get on my personal laptop i can try to bulid as well and see what's up. but I feel like 16gb should be enough to build, i'm curious if you've figure out how much memory your mac build is actually using
a
I was able to successfully build Ktor from the latest main branch on Windows 11 with the JDK 17, JDK 11 and JDK 8 installed via WinGet.
What Gradle task do you execute?
g
I use
.\gradlew.bat assemble
Windows 11, JDK 17 Amazon Coretto, also tried JDK 17 by JetBrains
a
The
assemble
task completes successfully on my machine. Have you tried deleting the Maven cache?
g
omg, I was finally able to build ktor on my PC Thanks, @Aleksei Tirman [JB], clearing the maven cache solved my problem!🙂