Skip to content

mill init is not Windows compatible #4672

@joshuakfarrar

Description

@joshuakfarrar

When attempting to run mill init <Giter8 template> on Windows 11, I get the following:

PS C:\Users\joshua\g\test> mill init scalalib/web/3-scalajs-module
[1/1] init
[1] Downloading example from https://github.com/com-lihaoyi/mill/releases/download/0.12.5/0.12.5-example-scalalib-web-3-scalajs-module.zip...
[1] Unpacking example...
[1] .mill-version
[1] build.mill
[1] foo
[1] foo/src
[1] foo/src/Foo.scala
[1] foo/test
[1] foo/test/src
[1] foo/test/src/FooTests.scala
[1] mill
[1] mill.bat
[1] null
[1/1] ================== init scalalib/web/3-scalajs-module =================
1 tasks failed
init java.lang.Exception: 1 tasks failed
mill.init.InitModule.init java.lang.UnsupportedOperationException
    java.base/java.nio.file.Files.setPosixFilePermissions(Files.java:2168)
    os.perms$set$.apply(PermsOps.scala:28)
    mill.init.InitModule.$anonfun$init$3(InitModule.scala:80)
    mill.init.InitModule.$anonfun$usingExamples$2(InitModule.scala:102)
    scala.util.Using$.apply(Using.scala:296)
    mill.init.InitModule.usingExamples(InitModule.scala:98)
    mill.init.InitModule.$anonfun$init$2(InitModule.scala:34)
    mill.main.MainModule.$anonfun$init$1(MainModule.scala:575)
    mill.define.Task$TraverseCtx.evaluate(Task.scala:219)

There's a line of code which sets permissions to 777 on the downloaded copy of mill... under the hood, is this calling setPosixFilePermissions?

os.perms.set(Task.workspace / "mill", "rwxrwxrwx")

I see elsewhere (mill.util.jvm) where setPosixFilePermissions is guarded behind a check for isWin:

def createLauncher(mainClass: String, classPath: Seq[os.Path], jvmArgs: Seq[String])(implicit
ctx: Ctx.Dest
): PathRef = {
val isWin = scala.util.Properties.isWin
val isBatch =
isWin && !(org.jline.utils.OSUtils.IS_CYGWIN || org.jline.utils.OSUtils.IS_MSYSTEM)
val outputPath = ctx.dest / (if (isBatch) "run.bat" else "run")
val classPathStrs = classPath.map(_.toString)
os.write(outputPath, launcherUniversalScript(mainClass, classPathStrs, classPathStrs, jvmArgs))
if (!isWin) {
val perms = Files.getPosixFilePermissions(outputPath.toNIO)
perms.add(PosixFilePermission.GROUP_EXECUTE)
perms.add(PosixFilePermission.OWNER_EXECUTE)
perms.add(PosixFilePermission.OTHERS_EXECUTE)
Files.setPosixFilePermissions(outputPath.toNIO, perms)
}
PathRef(outputPath)
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions