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

multiple errors like "bad path element "... ": no such file or directory when building Apache Kafka #2303

Open
edoardocomar opened this issue Mar 25, 2024 · 4 comments
Labels
bug A defect or misbehaviour. gradle java Pull requests that update Java code

Comments

@edoardocomar
Copy link

Using VSCode with the Scala(Metals) extension on the codebase of Apache Kafka (mixed Java/Scala codebase built with Gradle).
Metals doctor shows lots of compilation status errors due to errors like this (from the metals log):

024.03.22 16:25:04 WARN  Unexpected javac output: warning: [path] bad path element "../kafka/.bloop/core-test/build/classes-empty-core-test": no such file or directory
warning: [path] bad path element ".../kafka/storage/api/src/test/resources": no such file or directory
error: warnings found and -Werror specified
1 error
2 warnings.
2024.03.22 16:25:04 WARN  javac exited with exit code 1
2024.03.22 16:25:04 INFO  time: compiled core-test in 29s

If the directories are created manually, then the status goes green.
As there are many such errors, it takes a long time to manually 'fix' the project

Note : I created an issue for Metals and it was reviewed as a bloop problem, so I am trying to get it fixed here
scalameta/metals#6249

@Arthurm1
Copy link
Contributor

I assume you have the -Xlint:path or -Xlint:all option set?

If this works in Gradle then I can only guess that Gradle is filtering out empty directories, which seems to cheat the whole point of adding that warning. I.e. why aren't you getting the same error on gradlew testclasses?

As a workaround for now you could change your Gradle project(s) to blank out resource directories that don't exist...

test {
  resources {
    srcDirs = []
  }
}

@edoardocomar
Copy link
Author

edoardocomar commented Mar 26, 2024

@Arthurm1 The issue is not just with resource directories.
I had only included a small snippet of the log previously, please find here attached a full metals log
after opening vscode on a clean kafka trunk git clone and loading a core scala source file.

Please note that I had also installed the java extension for vscode and I found that I need to disable them for the workspace, in order for them not to take over when a Java file is open.

metals.log

@Arthurm1
Copy link
Contributor

@edoardocomar Ah - it looks like there is also a Bloop issue in that it creates empty directories classes-empty-ProjectName. I have no idea why it does this.

A workaround for that would be to disable the xlint:path by changing the build.gradle and re-exporting.

Add line to Gradle build like this...

  tasks.withType(JavaCompile) {
    options.encoding = 'UTF-8'
    options.compilerArgs << "-Xlint:all"
    options.compilerArgs << "-Xlint:-path"    // ADD THIS LINE

@edoardocomar
Copy link
Author

Thanks @Arthurm1 that does the trick (I also disabled the -Werror option)
although the result is that the build proceeds where it never arrived before and encounters submodules (jmh-benchmarks) where it hangs. But that is an altogether different problem ... I will have to disable those or open another issue

@tgodzik tgodzik added bug A defect or misbehaviour. gradle java Pull requests that update Java code labels Aug 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A defect or misbehaviour. gradle java Pull requests that update Java code
Projects
None yet
Development

No branches or pull requests

3 participants