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

mill init is not Windows compatible #4672

Open
joshuakfarrar opened this issue Mar 8, 2025 · 0 comments
Open

mill init is not Windows compatible #4672

joshuakfarrar opened this issue Mar 8, 2025 · 0 comments

Comments

@joshuakfarrar
Copy link
Contributor

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)
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant