JetBrains / compose-multiplatform

Compose Multiplatform, a modern UI framework for Kotlin that makes building performant and beautiful user interfaces easy and enjoyable.
https://jetbrains.com/lp/compose-multiplatform
Apache License 2.0
15.33k stars 1.11k forks source link

Cannot delete previous distribution on Windows #4302

Open Omico opened 4 months ago

Omico commented 4 months ago

Run createDistributable or createReleaseDistributable first.

Then, make some changes to the code.

Run createDistributable or createReleaseDistributable again.

Unable to delete directory 'G:\Git\Omico\xxx\xxx\desktop\build\compose\binaries\main-release\app'
  Failed to delete some children. This might happen because a process has files open or has its working directory set in the target directory.
  - G:\Git\Omico\xxx\xxx\desktop\build\compose\binaries\main-release\app\xxx-desktop\xxx-desktop.exe
  - G:\Git\Omico\xxx\xxx\desktop\build\compose\binaries\main-release\app\xxx-desktop

I can delete it manually in IDEA, but a Clear Read-Only Status dialog will pop up before the operation proceeds.

I only face this in Windows.

Schahen commented 4 months ago

Thank you for report, Omico, can you clarify which version of compose-multiplatform you are using in the project that causes this problem?

Omico commented 4 months ago

@Schahen I'm facing the same thing in 1.6.0-rc01, 1.6.0-beta02, 1.5.12, and 1.5.11; not sure about the other versions.

Schahen commented 4 months ago

Thanks @Omico that's enough for further investigation

badmannersteam commented 3 months ago

This issue is not related to the Compose, but we have 2 problems here:

  1. jpackage generates exe with readonly flag on Windows.
    • There is an old issue (https://bugs.openjdk.org/browse/JDK-8261845), it was fixed in 2021 and the fix is still presented in openjdk master branch, but the generated file is still readonly even with the last openjdk 17/19/21. Don't know why, looks like another regression.
  2. Gradle can't delete readonly file.

So for now to fix repeatable builds we can downgrade Gradle to 8.3 or upgrade it to 8.7-rc-1+ (8.7-rc-3 already released) .

Omico commented 3 months ago

Hi @badmannersteam, thanks for your info.

I realize that the latest Temurin 17 on Winget is only 17.0.9.9. When I checked the source code, I found that the patch you mentioned has been included. Then, I upgraded to the latest 17.10.7 from the official website, which can still be reproduced.

And yes, after I upgraded to 8.7-rc-1, the issue is gone.

Thanks again!