lms-clean icon indicating copy to clipboard operation
lms-clean copied to clipboard

LMS unable to move headers to correct directory (C codegen)

Open reikdas opened this issue 2 years ago • 0 comments

If I use the C backend in a project that inherits lms-clean, and use sbt from the command line to execute my code, I get the error -

[info] running Main 
[error] java.nio.file.NoSuchFileException: file:/home/reikdas/lmshdfs/target/bg-jobs/sbt_97ef2bde/target/4b87683e/5ecc7a79/lms-clean_2.12-0.0.1-SNAPSHOT.jar!/headers
[error] 	at sun.nio.fs.UnixException.translateToIOException(UnixException.java:86)
[error] 	at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102)
[error] 	at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107)
[error] 	at sun.nio.fs.UnixFileAttributeViews$Basic.readAttributes(UnixFileAttributeViews.java:55)
[error] 	at sun.nio.fs.UnixFileSystemProvider.readAttributes(UnixFileSystemProvider.java:144)
[error] 	at sun.nio.fs.LinuxFileSystemProvider.readAttributes(LinuxFileSystemProvider.java:99)
[error] 	at java.nio.file.Files.readAttributes(Files.java:1737)
[error] 	at java.nio.file.FileTreeWalker.getAttributes(FileTreeWalker.java:219)
[error] 	at java.nio.file.FileTreeWalker.visit(FileTreeWalker.java:276)
[error] 	at java.nio.file.FileTreeWalker.walk(FileTreeWalker.java:322)
[error] 	at java.nio.file.FileTreeIterator.<init>(FileTreeIterator.java:72)
[error] 	at java.nio.file.Files.walk(Files.java:3574)
[error] 	at java.nio.file.Files.walk(Files.java:3625)
[error] 	at lms.core.ExtendedCCodeGen.prepareHeaders(c_codegen.scala:259)
[error] 	at lms.core.ExtendedCCodeGen.emitAll(c_codegen.scala:656)
[error] 	at lms.core.stub.Adapter$.$anonfun$emitCommon$4(stub.scala:85)
[error] 	at lms.core.utils$.time(utils.scala:20)
[error] 	at lms.core.stub.Adapter$.emitCommon(stub.scala:78)
[error] 	at lms.core.stub.Adapter$.emitCommon1(stub.scala:50)
[error] 	at lms.core.stub.DslGenC.emitSource(stub.scala:1442)
[error] 	at lms.core.stub.DslGenC.emitSource$(stub.scala:1441)
[error] 	at Main$$anon$1$$anon$2.emitSource(Main.scala:11)

But I do not face the same error when executing my code from an IDE such as Intellij Idea.

This seems like a common issue - https://stackoverflow.com/questions/53543460/scala-issue-with-reading-file-from-resources-directory

Since I don't need the headers for now, a simple work around that I am using is to comment out the prepareHeaders() invocation here - https://github.com/TiarkRompf/lms-clean/blob/master/src/main/scala/lms/core/codegen/c_codegen.scala#L656

cc: @Kraks

reikdas avatar Oct 17 '22 13:10 reikdas