当前位置: 首页 > 知识库问答 >
问题:

删除某些子进程失败。这可能是因为进程打开了文件或将其工作目录设置在目标目录中

于飞飙
2023-03-14

出于某种未知的原因,每当我在启动笔记本电脑后运行gradle清洁构建时,它都会按预期工作。当我第二次尝试时,我总是得到

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社区/Windows 10):其他问题

我仔细尝试了所有的建议,但没有一个能解决我的问题。只有重新启动Windows并只工作一次,我才能让它恢复工作。

其中一些建议是:

1-关闭工作室并转到问题所在的路径并删除那里的文件夹。我尝试关闭IntelliJ,但无法直接删除文件夹

2-文件

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

格拉德尔。属性

micronautVersion=2.1.3
kotlinVersion=1.4.10

以及IntelliJ中的build文件夹

***编辑

我不知道该怎么修。现在,我刚刚从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> 

共有3个答案

濮阳安澜
2023-03-14

在我的例子中,我在Linux中以root用户身份运行Gradle命令后遇到了这个错误。

在切换回普通用户后,Gradle给了我上述错误。当我试图使用rm-rf build删除生成目录时,我收到了一个“权限被拒绝”错误。您可以通过将生成目录作为根用户删除来解决此问题。

贡念
2023-03-14

只需重命名“构建”文件夹。

田修为
2023-03-14

问题是,您有多个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

如果你在那里看到什么,那可能是个问题。

使用无守护进程和无并行程序可能会有所帮助,但它们只会隐藏潜在的问题。

在我的例子中,当这种情况发生时,我意识到我有进程在后台运行,因为测试永远不会完成。检查所有线程和/或协程使用情况,以查找未关闭/未完成的进程。

另一种情况是,当我使用ProcessBuilder启动另一个Java进程时,它没有退出。

 类似资料:
  • 问题内容: 正如标题所示,我们正在编写一个Unix风格的shell实用程序 U ,该实用程序应该从bash中调用(在大多数情况下)。 U 到底如何更改bash(或一般来说是父级)的工作目录? PS Shell实用程序 chdir 成功完成了相同的工作,因此必须有一种编程的方法来达到这种效果。 问题答案: 不要这样 尽管注意Bash的命令已缓存并且不会注意到,但它 可能会 起作用。

  • 问题内容: 我无法弄清楚这里出了什么问题…我试图更简洁地写这篇文章,但没有用。阅读有关此问题的其他建议后,我输入了所有额外的字符串。没有帮助。不知道发生了什么事。可能与权限相关吗?AFAIK我正在尝试写入内部存储器,并且不需要特殊权限? 每次,目录未完成或出现某种情况时,它都会“制作目录”。当到达myFile.createNewFile();时 它给出错误信息“打开失败:ENOENT(没有这样的文

  • 我有一个错误: 警告:require_once(../questionTypes/Question.php):无法打开流:第25行的/home/u949913003/public_html/includes/essential.php中没有此类文件或目录 致命错误:require_once():无法在/home/u949913003/public_html/includes/essential.p

  • null 我在用这个代码 但我一直得到这个错误

  • 方法总是给出这样的错误: 打开失败:ENOENT(没有这样的文件或目录)

  • 我正在尝试编写一个Android应用程序,它将解析一个. owl文件(OWL文件)并显示类和子类。当我尝试打开文件时,我一直得到以下异常。 以下是我的Android代码: 我在项目的父目录中有文件“antiminaties.owl”。我正在模拟器上运行这个项目。 我如何摆脱这个异常并解析OWL文件?我仍然是Android编程的初学者。