英文:
Gradle build failing with Java IOException
问题
我在尝试执行gradle.bat文件或任何gradle命令(例如gradle -version)时遇到以下错误:
构建失败:发生异常。
* 出现了什么问题:
java.io.IOException:文件名、目录名或卷标语法不正确
Gradle版本:4.10.2
JDK:"1.8.0_261"
操作系统:Windows 10(x64)
可能出了什么问题?
附言:我还尝试了更新的Gradle版本(6.6.1)。它生成了类似的错误:
构建失败:发生异常。
* 出现了什么问题:
java.io.IOException:文件名、目录名或卷标语法不正确
* 尝试:
使用--info或--debug选项运行以获取更多日志输出。使用--scan运行以获得完整见解。
* 异常信息:
org.gradle.api.UncheckedIOException:java.io.IOException:文件名、目录名或卷标语法不正确
at org.gradle.internal.FileUtils.canonicalize(FileUtils.java:204)
at org.gradle.initialization.BuildLayoutParameters.findGradleUserHomeDir(BuildLayoutParameters.java:51)
at org.gradle.initialization.BuildLayoutParameters.<init>(BuildLayoutParameters.java:39)
at org.gradle.launcher.cli.converter.BuildLayoutConverter.defaultValues(BuildLayoutConverter.java:42)
at org.gradle.launcher.cli.DefaultCommandLineActionFactory$WithLogging.execute(DefaultCommandLineActionFactory.java:205)
at org.gradle.launcher.Main.doAction(Main.java:35)
at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:50)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:60)
at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:37)
at org.gradle.launcher.GradleMain.main(GradleMain.java:31)
Caused by: java.io.IOException: 文件名、目录名或卷标语法不正确
at java.io.WinNTFileSystem.canonicalize0(Native Method)
at java.io.WinNTFileSystem.canonicalize(WinNTFileSystem.java:428)
at java.io.File.getCanonicalPath(File.java:618)
at java.io.File.getCanonicalFile(File.java:643)
at org.gradle.internal.FileUtils.canonicalize(FileUtils.java:202)
... 13 more
英文:
I'm getting the following error when I'm trying to execute the gradle.bat file, or any gradle command for that matter (eg. gradle -version).
FAILURE: Build failed with an exception.
* What went wrong:
java.io.IOException: The filename, directory name, or volume label syntax is incorrect
Gradle Version: 4.10.2
JDK: "1.8.0_261"
OS: Windows 10 (x64)
What could have possibly gone wrong?
P.S: I have also tried the same with a newer gradle version (6.6.1). It generated a similar error.
FAILURE: Build failed with an exception.
* What went wrong:
java.io.IOException: The filename, directory name, or volume label syntax is incorrect
* Try:
Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Exception is:
org.gradle.api.UncheckedIOException: java.io.IOException: The filename, directory name, or volume label syntax is incorrect
at org.gradle.internal.FileUtils.canonicalize(FileUtils.java:204)
at org.gradle.initialization.BuildLayoutParameters.findGradleUserHomeDir(BuildLayoutParameters.java:51)
at org.gradle.initialization.BuildLayoutParameters.<init>(BuildLayoutParameters.java:39)
at org.gradle.launcher.cli.converter.BuildLayoutConverter.defaultValues(BuildLayoutConverter.java:42)
at org.gradle.launcher.cli.DefaultCommandLineActionFactory$WithLogging.execute(DefaultCommandLineActionFactory.java:205)
at org.gradle.launcher.Main.doAction(Main.java:35)
at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:50)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:60)
at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:37)
at org.gradle.launcher.GradleMain.main(GradleMain.java:31)
Caused by: java.io.IOException: The filename, directory name, or volume label syntax is incorrect
at java.io.WinNTFileSystem.canonicalize0(Native Method)
at java.io.WinNTFileSystem.canonicalize(WinNTFileSystem.java:428)
at java.io.File.getCanonicalPath(File.java:618)
at java.io.File.getCanonicalFile(File.java:643)
at org.gradle.internal.FileUtils.canonicalize(FileUtils.java:202)
... 13 more
答案1
得分: 0
通过将GRADLE_USER_HOME环境变量添加到“用户变量”而不是“系统变量”下,简单地解决了这个问题。
英文:
Solved the problem simply by adding the GRADLE_USER_HOME environment variable under User Variables instead of System Variables.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论