google / google/ksp

[ksp] java.lang.IllegalArgumentException: this and base files have different roots

Open
#1,079 19 comments 15 reactions 1 assignee Claimed by @neetopia View on GitHub
bug P2
Dominant language
Kotlin
Stars
3.5k
Forks
415
Avg merge
1d 2h
Merged PRs (30d)
53

Description

KSP didn't respect gradle `buildDir` variable.

Using RAM disk (`Z:` drive) for build folders:

**USER_HOME/.gradle/init.gradle**
```
allprojects {
buildDir="Z:/build/$group/$name/"
}
```

**app/build.gradle**
```
android {
sourceSets {
androidTest.assets.srcDirs += files("$projectDir/schemas".toString())

main.kotlin.srcDirs += '$buildDir/generated/ksp/$name/kotlin/'
test.kotlin.srcDirs += '$buildDir/generated/ksp/$name/kotlin/'
}

buildTypes {
// https://github.com/InsertKoinIO/koin-annotations
applicationVariants.all { variant ->
variant.sourceSets.java.each {
it.srcDirs += "$buildDir/generated/ksp/${variant.name}/kotlin/"
}
}
}
}
```

But build failed with:

```
e: [ksp] java.lang.IllegalArgumentException: this and base files have different roots: Z:\build\ProjectX\app\generated\ksp\stagingDebug\java\cz\packagename\data\database\dao\UserOauthDao_Impl.java and D:\Projects\company\ProjectX\app.
at kotlin.io.FilesKt__UtilsKt.toRelativeString(Utils.kt:117)
at kotlin.io.FilesKt__UtilsKt.relativeTo(Utils.kt:128)
at com.google.devtools.ksp.processing.impl.CodeGeneratorImpl.associate(CodeGeneratorImpl.kt:119)
at com.google.devtools.ksp.processing.impl.CodeGeneratorImpl.createNewFile(CodeGeneratorImpl.kt:92)
at androidx.room.compiler.processing.ksp.KspFiler.createNewFile(KspFiler.kt:106)
at androidx.room.compiler.processing.ksp.KspFiler.write(KspFiler.kt:41)
at androidx.room.compiler.processing.XFilerKt.writeTo(XFiler.kt:44)
at androidx.room.compiler.processing.XFilerKt.writeTo$default(XFiler.kt:43)
at androidx.room.writer.ClassWriter.write(ClassWriter.kt:75)
at androidx.room.DatabaseProcessingStep.process(DatabaseProcessingStep.kt:111)
at androidx.room.DatabaseProcessingStep.process(DatabaseProcessingStep.kt:42)
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.