无法删除部分子项。这可能是因为进程打开了文件或将其工作目录设置在目标目录中
Posted
技术标签:
【中文标题】无法删除部分子项。这可能是因为进程打开了文件或将其工作目录设置在目标目录中【英文标题】:Failed to delete some children. This might happen because a process has files open or has its working directory set in the target directory 【发布时间】:2021-02-20 08:51:42 【问题描述】:由于某种未知原因,每当我在启动笔记本后运行gradle clean build
时,它都会按预期工作。当我第二次尝试时,我总是得到
Unable to delete directory 'C:\_d\mycompany\WSs\demo\build'
Failed to delete some children. This might happen because a process has files open or has its working directory set in the target directory.
- C:\_d\mycompany\WSs\demo\build\classes\kotlin\main\com\mybank
- C:\_d\mycompany\WSs\demo\build\classes\kotlin\main\com
- C:\_d\mycompany\WSs\demo\build\classes\kotlin\main
- C:\_d\mycompany\WSs\demo\build\classes\kotlin\test\com
- C:\_d\mycompany\WSs\demo\build\classes\kotlin\test
- C:\_d\mycompany\WSs\demo\build\classes\kotlin
- C:\_d\mycompany\WSs\demo\build\classes
- C:\_d\mycompany\WSs\demo\build\generated\source\kapt
- C:\_d\mycompany\WSs\demo\build\generated\source\kaptKotlin\main
- C:\_d\mycompany\WSs\demo\build\generated\source\kaptKotlin\test
- C:\_d\mycompany\WSs\demo\build\generated\source\kaptKotlin
- C:\_d\mycompany\WSs\demo\build\generated\source
- C:\_d\mycompany\WSs\demo\build\generated
- C:\_d\mycompany\WSs\demo\build\kotlin\compileKotlin\caches-jvm\inputs
- C:\_d\mycompany\WSs\demo\build\kotlin\compileKotlin\caches-jvm\jvm\kotlin
- C:\_d\mycompany\WSs\demo\build\kotlin\compileKotlin\caches-jvm\jvm
- and more ...
New files were found. This might happen because a process is still writing to the target directory.
- C:\_d\mycompany\WSs\demo\build\kotlin\compileKotlin
我发现有人在使用 android Studio/Ubuntu(我正在使用 IntelliJ Community/Windows 10)时遇到了非常相似的问题:other question
我仔细尝试了所有建议,但没有一个能解决我的问题。如果我重新启动我的 Windows 并且只工作一次,我只会让它恢复工作。
一些建议是:
1 - 关闭工作室并转到问题所在的路径并删除那里的文件夹。 我尝试关闭 IntelliJ,但无法直接删除文件夹
2 - 文件 > 设置 > 构建、执行、部署 > 即时运行 > 取消选中此复选框(启用即时运行以热交换代码) 我的 IntelliJ 中没有这样的可选项
IntelliJ IDEA 2020.2.3 (Community Edition)
Build #IC-202.7660.26, built on October 6, 2020
Runtime version: 11.0.8+10-b944.34 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Windows 10 10.0
GC: ParNew, ConcurrentMarkSweep
Memory: 1963M
Cores: 8
Non-Bundled Plugins: Lombook Plugin, org.jetbrains.kotlin
3 - gradlew 清洁 同样的问题
4 - 右键单击目录,单击将出现的上下文菜单上的属性,然后取消选中“只读”属性。之后,单击“应用”以应用更改。 我是管理员,但我无法更改此类文件夹属性。
5 - 在 Windows 中以管理员身份运行 android studio 对我有用。 同样的问题
这是我的 build.gradle
plugins
id "org.jetbrains.kotlin.jvm" version "1.4.10"
id "org.jetbrains.kotlin.kapt" version "1.4.10"
id "org.jetbrains.kotlin.plugin.allopen" version "1.4.10"
id "com.github.johnrengelman.shadow" version "6.1.0"
id "io.micronaut.application" version '1.0.5'
id "com.gorylenko.gradle-git-properties" version "2.2.2"
version "0.1"
group "com.mybank"
repositories
mavenCentral()
jcenter()
micronaut
runtime "netty"
testRuntime "junit5"
processing
incremental true
annotations "com.mybank.*"
dependencies
implementation("io.micronaut:micronaut-validation")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlinVersion")
implementation("org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion")
implementation("io.micronaut.kotlin:micronaut-kotlin-runtime")
implementation("io.micronaut:micronaut-runtime")
implementation("javax.annotation:javax.annotation-api")
implementation("io.micronaut:micronaut-http-client")
implementation("io.micronaut:micronaut-management")
implementation("io.micronaut.sql:micronaut-jdbc-hikari")
implementation("io.micronaut.sql:micronaut-hibernate-jpa")
runtimeOnly("com.h2database:h2")
runtimeOnly("ch.qos.logback:logback-classic")
runtimeOnly("com.fasterxml.jackson.module:jackson-module-kotlin")
mainClassName = "com.mybank.ApplicationKt"
java
sourceCompatibility = JavaVersion.toVersion('11')
compileKotlin
kotlinOptions
jvmTarget = '11'
compileTestKotlin
kotlinOptions
jvmTarget = '11'
gradle.properties
micronautVersion=2.1.3
kotlinVersion=1.4.10
以及在 IntelliJ 中看到的构建文件夹
***已编辑
我没有找到如何解决它。现在正在发生一个我刚刚从micronaut克隆的项目
虽然我是 Windows 管理员,但我无法删除构建文件夹
PS C:\_d\toLearn\micronaut-grpc\examples\hello-world-kotlin> gradle clean build
> Task :clean FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':clean'.
> java.io.IOException: Unable to delete directory 'C:\_d\toLearn\micronaut-grpc\examples\hello-world-kotlin\build'
Failed to delete some children. This might happen because a process has files open or has its working directory set in
the target directory.
- C:\_d\toLearn\micronaut-grpc\examples\hello-world-kotlin\build\generated\source\kaptKotlin\main
- C:\_d\toLearn\micronaut-grpc\examples\hello-world-kotlin\build\generated\source\kaptKotlin\test
- C:\_d\toLearn\micronaut-grpc\examples\hello-world-kotlin\build\generated\source\kaptKotlin
- C:\_d\toLearn\micronaut-grpc\examples\hello-world-kotlin\build\generated\source
- C:\_d\toLearn\micronaut-grpc\examples\hello-world-kotlin\build\generated
- C:\_d\toLearn\micronaut-grpc\examples\hello-world-kotlin\build\tmp\kapt3\incApCache\main
- C:\_d\toLearn\micronaut-grpc\examples\hello-world-kotlin\build\tmp\kapt3\incApCache\test
- C:\_d\toLearn\micronaut-grpc\examples\hello-world-kotlin\build\tmp\kapt3\incApCache
- C:\_d\toLearn\micronaut-grpc\examples\hello-world-kotlin\build\tmp\kapt3\stubs\main
- C:\_d\toLearn\micronaut-grpc\examples\hello-world-kotlin\build\tmp\kapt3\stubs\test
- C:\_d\toLearn\micronaut-grpc\examples\hello-world-kotlin\build\tmp\kapt3\stubs
- C:\_d\toLearn\micronaut-grpc\examples\hello-world-kotlin\build\tmp\kapt3
- C:\_d\toLearn\micronaut-grpc\examples\hello-world-kotlin\build\tmp
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.7/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 13s
1 actionable task: 1 executed
PS C:\_d\toLearn\micronaut-grpc\examples\hello-world-kotlin> gradle stop
FAILURE: Build failed with an exception.
* What went wrong:
Task 'stop' not found in root project 'hello-world-kotlin'.
* Try:
Run gradle tasks to get a list of available tasks. Run with --stacktrace option to get the stack trace. Run with --info or
--debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.7/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 2s
PS C:\_d\toLearn\micronaut-grpc\examples\hello-world-kotlin>
【问题讨论】:
【参考方案1】:问题是您有多个 Gradle 进程仍在锁定您的文件。
您可以尝试运行gradle --stop
,当这种情况发生时会停止在后台运行的任何守护程序(这通常会有所帮助)。
您还可以通过运行gradle --status
检查您的守护进程的状态。对我来说,这个输出:
No Gradle daemons are running.
Only Daemons for the current Gradle version are displayed.
See https://docs.gradle.org/6.5/userguide/gradle_daemon.html#sec:status
如果你在那里看到什么,那可能是个问题。
使用--no-daemon
和--no-parallel
可能会有所帮助,但它们只会隐藏根本问题。
在发生这种情况时,我意识到我有进程在后台运行,因为测试从未完成。检查您的所有线程和/或协程使用情况是否有未关闭/未完成的进程。
当我使用 ProcessBuilder
启动另一个 Java 进程但它没有退出时,我遇到了另一种情况。
【讨论】:
谢谢,但它仍在发生。有趣的是,以前从未发生过相同的笔记本和 gradle 安装。它开始只发生在 micronaut 项目中 那么很可能是Micronaut资源泄露导致某些进程无法停止。 完全不知道出了什么问题。我的公司笔记本电脑遇到了这个问题,我无法以管理员身份登录。今天我的个人笔记本电脑也遇到了同样的问题,显然我是管理员。我安装了一个免费工具,以找出哪个进程阻止了这个文件夹,它指向 java.exe 我杀死了这个进程,但我仍然无法删除该文件夹。只有在我关闭 IntelliJ 和 Visual Studio Code 之后,我才终于设法删除了该文件夹。很奇怪的问题。顺便说一句,我只对包含 micronaut 依赖项的 gradle 项目有这个问题。 哦,如果你在IDEA中开启了增量编译,就会出现这个问题。【参考方案2】:尝试重新启动系统。有时没有其他问题,但会出现上述错误
【讨论】:
对我来说是它的作品。尝试接受答案后,所以我发布了。【参考方案3】:我转到我的文件系统并手动删除了该文件。重启了我的安卓
【讨论】:
以上是关于无法删除部分子项。这可能是因为进程打开了文件或将其工作目录设置在目标目录中的主要内容,如果未能解决你的问题,请参考以下文章