You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

执行mvn install package时遭遇cannot overwrite directory错误求助

Apache Pinot编译错误解决(Windows 11 Git Bash环境)

问题场景

在Windows 11的Git Bash中执行以下Maven命令编译Apache Pinot:

mvn install package -DskipTests -Pbin-dist -Drat.numUnapprovedLicenses=1000 -Dcheckstyle.skip -rf :pinot-distribution

错误信息

[INFO] --- maven-assembly-plugin:3.1.1:single (binary-release-assembly-pinot) @ pinot-distribution ---
[INFO] Reading assembly descriptor: pinot-assembly.xml
[INFO] Building tar: C:\GitHubProjects\pinot\pinot-distribution\target\apache-pinot-1.1.0-SNAPSHOT-bin.tar.gz
[INFO] Copying files to C:\GitHubProjects\pinot\pinot-distribution\target\apache-pinot-1.1.0-SNAPSHOT-bin
[WARNING] Assembly file: C:\GitHubProjects\pinot\pinot-distribution\target\apache-pinot-1.1.0-SNAPSHOT-bin is not a regular file (it may be a directory). It cannot be attached to the project build for installation or deployment.
[INFO]
[INFO] --- exec-maven-plugin:1.5.0:exec (create-build-directory) @ pinot-distribution ---
/usr/bin/ln: 'C:\GitHubProjects\pinot\pinot-distribution/../build/apache-pinot-1.1.0-SNAPSHOT-bin': cannot overwrite directory
[ERROR] Command execution failed.
org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1)
    at org.apache.commons.exec.DefaultExecutor.executeInternal (DefaultExecutor.java:404)
    at org.apache.commons.exec.DefaultExecutor.execute (DefaultExecutor.java:166)
    at org.codehaus.mojo.exec.ExecMojo.executeCommandLine (ExecMojo.java:764)
    at org.codehaus.mojo.exec.ExecMojo.executeCommandLine (ExecMojo.java:711)
    at org.codehaus.mojo.exec.ExecMojo.execute (ExecMojo.java:289)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)

错误原因

Git Bash中的ln命令无法直接覆盖已存在的目录,而构建脚本尝试创建符号链接到已存在的build/apache-pinot-1.1.0-SNAPSHOT-bin目录,导致命令执行失败。

解决方案

  • 清理旧构建文件:删除项目根目录下的build文件夹,以及pinot-distribution/target目录下的apache-pinot-1.1.0-SNAPSHOT-bin文件夹,然后重新执行编译命令。这是最稳妥的方案,避免残留文件干扰。
  • 修改构建脚本参数:编辑pinot-distribution模块的pom.xml,找到exec-maven-plugin的create-build-directory执行配置,给ln命令添加-f参数强制覆盖目录。注意此操作会直接替换旧目录内容,需确认无重要文件。
  • 切换到WSL2环境:Windows下推荐使用WSL2(如Ubuntu发行版)执行编译,完全兼容Unix文件系统和命令,避免Git Bash的跨环境兼容性问题。

内容的提问来源于stack exchange,提问作者Aditya Mahajan

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.07 20:17:09