kitlangton / zio-app

Quickly create and develop full-stack Scala apps with ZIO and Laminar.
124 stars 33 forks source link

[linux][bug] Can't move directory #6

Closed ex0ns closed 3 years ago

ex0ns commented 3 years ago

The java.nio.file.FileAlreadyExistsException raised when creating an new project on Linux is due to /tmp often being on another filesystem. The Files.move from NIO (https://docs.oracle.com/javase/7/docs/api/java/nio/file/Files.html#move%28java.nio.file.Path,%20java.nio.file.Path,%20java.nio.file.CopyOption...%29) will fail when call with a source and destination not on the same fs.

The simplest way of fixing it would be to replace

    tempdir <- Files.createTempDirectory(Some("zio-app-g8"), List.empty).orDie

By the creation of a directory in the current directory such as

  tempdir <- ZIO.succeed(Path("./.zio-app-g8"))
  _ <- Files.createDirectory(tempdir).orDie

Otherwise we would need to list the files and do a copy then delete of the files. Which solution do you think is best ? I can open a PR if need be

kitlangton commented 3 years ago

Thanks so much for looking into this! I think I can take care of it. I can’t today, but I can open up pr tomorrow. I’ll ping you when I have something, and if you can try it out on Linux that would be splendid!