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

KSP does not handle symlinks for new files in followup rounds #948

Closed
yigit opened this issue Apr 9, 2022 · 2 comments · Fixed by #1002
Closed

KSP does not handle symlinks for new files in followup rounds #948

yigit opened this issue Apr 9, 2022 · 2 comments · Fixed by #1002
Assignees
Labels
bug Something isn't working
Milestone

Comments

@yigit
Copy link
Collaborator

yigit commented Apr 9, 2022

AOSP bug: https://b.corp.google.com/issues/213234559

To reproduce, you can run the XProcessingStepTest.kspProcessingEnvCaching in AndroidX on a mac machine (checkout repo, cd room && ./gradlew studio to open the project).

From my debugging, it seems to be failing on this line:

https://github.com/google/ksp/blob/main/compiler-plugin/src/main/kotlin/com/google/devtools/ksp/KotlinSymbolProcessingExtension.kt#L164

newFiles = ksFiles.filter {
                    when (it) {
                        is KSFileImpl -> it.file
                        is KSFileJavaImpl -> it.psi
                        else -> null
                    }?.virtualFile?.let { virtualFile ->
                        virtualFile.canonicalPath ?: virtualFile.path
                    } in newFileNames
                }

The path in newFileNames is

/private/var/folders/t8/5nj0qf254j99114y1y5v086w007_hl/T/junit853351931968675205/ksp/generatedJava/foo/bar/Main_Impl.java

Whereas, the VirtualFile's myIoFile field is: /var/folders/t8/5nj0qf254j99114y1y5v086w007_hl/T/junit853351931968675205/ksp/generatedJava/foo/bar/Main_Impl.java

(notice the lack of /private. In my system, /var is a symlink to /private/var

ls  -lah /var
lrwxr-xr-x@ 1 root  wheel    11B Feb 25 23:05 /var -> private/var

Unfortunately, I cannot debug what canonicalPath returns for that file but if I'm finding the source correctly, it seems to simply return the path:

https://upsource.jetbrains.com/idea-ce/file/idea-ce-6a856f22b82f6478cd6fbdc0f281c28d5c75b712/platform/core-api/src/com/intellij/openapi/vfs/VirtualFile.java?nav=11254:11270:focused&line=478&preview=false

@neetopia neetopia added this to the 1.0.6 milestone May 3, 2022
@neetopia neetopia added the bug Something isn't working label May 3, 2022
@jsjeon
Copy link
Member

jsjeon commented May 24, 2022

if I'm finding the source correctly, it seems to simply return the path

Note that that's the default impl behavior. It's supposed to resolve sym link like this: https://github.com/JetBrains/intellij-community/blob/master/platform/vfs-impl/src/com/intellij/openapi/vfs/newvfs/impl/VirtualFileSystemEntry.java#L542

@neetopia
Copy link
Collaborator

the files comes from compiler as this is a compiler extension, I guess KSP doesn't have control over what the underlying implementation will be?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants