.tar.gz untar is broken in 2.4

It is working fine with older versions of gradle (for example 2.3).
Here is command:
copy {
from tarTree(resources.gzip(ruby_file.toFile()))
into build_dir.toFile()
}

and here is stack:
Caused by: org.gradle.api.GradleException: Unable to expand TAR ‘/usr/src/jruby-bin-9.0.0.0.pre2.tar.gz’
The tar might be corrupted or it is compressed in an unexpected way.
By default the tar tree tries to guess the compression based on the file extension.
If you need to specify the compression explicitly please refer to the DSL reference.
at org.gradle.api.internal.file.archive.TarFileTree.visit(TarFileTree.java:79)
at org.gradle.api.internal.file.collections.FileTreeAdapter.visit(FileTreeAdapter.java:96)
at org.gradle.api.internal.file.AbstractFileTree$FilteredFileTree.visit(AbstractFileTree.java:136)
at org.gradle.api.internal.file.CompositeFileTree.visit(CompositeFileTree.java:54)
at org.gradle.api.internal.file.copy.CopySpecActionImpl.execute(CopySpecActionImpl.java:37)
at org.gradle.api.internal.file.copy.CopySpecActionImpl.execute(CopySpecActionImpl.java:24)
at org.gradle.api.internal.file.copy.DefaultCopySpec$DefaultCopySpecResolver.walk(DefaultCopySpec.java:498)
at org.gradle.api.internal.file.copy.DefaultCopySpec.walk(DefaultCopySpec.java:322)
at org.gradle.api.internal.file.copy.DelegatingCopySpecInternal.walk(DelegatingCopySpecInternal.java:206)
at org.gradle.api.internal.file.copy.CopySpecBackedCopyActionProcessingStream.process(CopySpecBackedCopyActionProcessingStream.java:36)
at org.gradle.api.internal.file.copy.DuplicateHandlingCopyActionDecorator$1.process(DuplicateHandlingCopyActionDecorator.java:44)
at org.gradle.api.internal.file.copy.NormalizingCopyActionDecorator$1.process(NormalizingCopyActionDecorator.java:56)
at org.gradle.api.internal.file.copy.FileCopyAction.execute(FileCopyAction.java:35)
at org.gradle.api.internal.file.copy.NormalizingCopyActionDecorator.execute(NormalizingCopyActionDecorator.java:52)
at org.gradle.api.internal.file.copy.DuplicateHandlingCopyActionDecorator.execute(DuplicateHandlingCopyActionDecorator.java:42)
at org.gradle.api.internal.file.copy.CopyActionExecuter.execute(CopyActionExecuter.java:38)
at org.gradle.api.internal.file.copy.FileCopier.doCopy(FileCopier.java:64)
at org.gradle.api.internal.file.copy.FileCopier.copy(FileCopier.java:49)
at org.gradle.api.internal.file.DefaultFileOperations.copy(DefaultFileOperations.java:128)
at org.gradle.api.internal.project.AbstractProject.copy(AbstractProject.java:753)
at org.gradle.groovy.scripts.DefaultScript.copy(DefaultScript.java:168)
at org.gradle.groovy.scripts.DefaultScript.copy(DefaultScript.java:164)
at build_5b3eync7rhzgvllllv3tathvf$_run_closure8.doCall(/root/IdeaProjects/ami-packager/build.gradle:140)
at org.gradle.api.internal.AbstractTask$ClosureTaskAction.execute(AbstractTask.java:558)
at org.gradle.api.internal.AbstractTask$ClosureTaskAction.execute(AbstractTask.java:539)
at org.gradle.api.internal.tasks.TaskMutator$1.execute(TaskMutator.java:77)
at org.gradle.api.internal.tasks.TaskMutator$1.execute(TaskMutator.java:73)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61)
… 46 more
Caused by: java.io.IOException: Error detected parsing the header
at org.apache.tools.tar.TarInputStream.getNextEntry(TarInputStream.java:292)
at org.gradle.api.internal.file.archive.TarFileTree.visitImpl(TarFileTree.java:87)
at org.gradle.api.internal.file.archive.TarFileTree.visit(TarFileTree.java:70)
… 74 more
Caused by: java.lang.IllegalArgumentException: Invalid byte 32 at offset 7 in ’ {NUL}’ len=8
at org.apache.tools.tar.TarUtils.parseOctal(TarUtils.java:134)
at org.apache.tools.tar.TarUtils.parseOctalOrBinary(TarUtils.java:172)
at org.apache.tools.tar.TarEntry.parseTarHeader(TarEntry.java:912)
at org.apache.tools.tar.TarEntry.parseTarHeader(TarEntry.java:899)
at org.apache.tools.tar.TarEntry.(TarEntry.java:323)
at org.apache.tools.tar.TarInputStream.getNextEntry(TarInputStream.java:290)
… 76 more

Hi,

This is not enough to reproduce this issue. Would you be able to put together some instructions that we could follow in order to reproduce?

Not sure what kind of instructions else i could write… here is software/system versions I’m running and actual file:
File link: https://s3.amazonaws.com/jruby.org/downloads/9.0.0.0.pre2/jruby-bin-9.0.0.0.pre2.tar.gz
# java -version
openjdk version "1.8.0_45"
OpenJDK Runtime Environment (build 1.8.0_45-b13)
OpenJDK 64-Bit Server VM (build 25.45-b02, mixed mode)

# gradle -version


Gradle 2.4

Build time: 2015-05-05 08:09:24 UTC
Build number: none
Revision: 5c9c3bc20ca1c281ac7972643f1e2d190f2c943c

Groovy: 2.3.10
Ant: Apache Ant™ version 1.9.4 compiled on April 29 2014
JVM: 1.8.0_11 (Oracle Corporation 25.11-b03)
OS: Linux 3.19.5-200.fc21.x86_64 amd64

short proof:
# gvm use gradle 2.4

Using gradle version 2.4 in this shell.
# gradle mpuppet_rpm
:pre_init
:mpuppet_build FAILED

FAILURE: Build failed with an exception.

* Where:
Build file ‘/root/IdeaProjects/ami-packager/build.gradle’ line: 193

* What went wrong:
Execution failed for task ‘:mpuppet_build’.
> Unable to expand TAR '/usr/src/jruby-bin-9.0.0.0.pre2.tar.gz’
The tar might be corrupted or it is compressed in an unexpected way.
By default the tar tree tries to guess the compression based on the file extension.
If you need to specify the compression explicitly please refer to the DSL reference.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 19.332 secs
# gvm use gradle 2.3

Using gradle version 2.3 in this shell.
# gradle mpuppet_rpm
:pre_init
:mpuppet_build
:mpuppet_rpm UP-TO-DATE
:mpuppet_clean

BUILD SUCCESSFUL

Total time: 36.133 secs

*****************************
from previous post:
copy {
from tarTree(resources.gzip(ruby_file.toFile()))
into build_dir.toFile()
}
this is command I use to extract … ruby_file and build_dir is java.nio.files.Path
****************************

Let me know if you need something else to reproduce.

p.s.
I just replaced ant-1.9.4 and ant-launcher-1.9.4 with 1.9.3 version and it worked fine. So - i guess it is some kind of new ant library problem introduced in version 1.9.4.

It looks like this is indeed an issue introduced in Ant 1.9.4. I’ve raised GRADLE-3304 to track this. Also I’ve started a discussion on the gradle-dev list to determine the next course of action.

https://groups.google.com/forum/#!topic/gradle-dev/QvUZXh8Jo-4

This has been fixed in Gradle 2.5. Can you please try this with the latest 2.5 snapshot to see if your issue is resolved?

I’ve different errors … here is test:
Using gradle version 2.3 in this shell.
laptop amipacker # gradle sync_repo --stacktrace
:pre_init
:mpuppet_build* ← passed*

Building 40% > :mpuppet_rpm^C

Using gradle version 2.5-snap1 in this shell.
laptop amipacker # gradle sync_repo --stacktrace
:pre_init
:mpuppet_build FAILED

FAILURE: Build failed with an exception.

  • Where:
    Build file ‘/root/source/amipacker/build.gradle’ line: 254

  • What went wrong:
    Execution failed for task ‘:mpuppet_build’.

Cannot expand TAR ‘/usr/src/ami_build/jruby-bin-9.0.0.0.pre2.tar.gz’.

  • Try:
    Run with --info or --debug option to get more log output.

  • Exception is:
    org.gradle.api.tasks.TaskExecutionException: Execution failed for task
    ‘:mpuppet_build’.
    at
    org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:69)
    at
    org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46)
    at
    org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35)
    at
    org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:64)
    at
    org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
    at
    org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:52)
    at
    org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
    at
    org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:53)
    at
    org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
    at
    org.gradle.api.internal.AbstractTask.executeWithoutThrowingTaskFailure(AbstractTask.java:310)
    at
    org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.executeTask(AbstractTaskPlanExecutor.java:85)
    at
    org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:66)
    at
    org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:54)
    at
    org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(DefaultTaskPlanExecutor.java:23)
    at
    org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:94)
    at
    org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:37)
    at
    org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:62)
    at
    org.gradle.execution.DefaultBuildExecuter.access$200(DefaultBuildExecuter.java:23)
    at
    org.gradle.execution.DefaultBuildExecuter$2.proceed(DefaultBuildExecuter.java:68)
    at
    org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:32)
    at
    org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:62)
    at
    org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:55)
    at
    org.gradle.initialization.DefaultGradleLauncher$7.create(DefaultGradleLauncher.java:198)
    at
    org.gradle.initialization.DefaultGradleLauncher$7.create(DefaultGradleLauncher.java:195)
    at
    org.gradle.initialization.DefaultGradleLauncher.runBuildOperation(DefaultGradleLauncher.java:227)
    at
    org.gradle.initialization.DefaultGradleLauncher.runBuildOperation(DefaultGradleLauncher.java:216)
    at
    org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:195)
    at
    org.gradle.initialization.DefaultGradleLauncher.access$200(DefaultGradleLauncher.java:37)
    at
    org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradleLauncher.java:118)
    at
    org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradleLauncher.java:111)
    at
    org.gradle.initialization.DefaultGradleLauncher.runBuildOperation(DefaultGradleLauncher.java:227)
    at
    org.gradle.initialization.DefaultGradleLauncher.runRootBuildOperation(DefaultGradleLauncher.java:210)
    at
    org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:111)
    at
    org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:94)
    at
    org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:93)
    at
    org.gradle.tooling.internal.provider.ExecuteBuildActionRunner.run(ExecuteBuildActionRunner.java:28)
    at
    org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
    at
    org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:44)
    at
    org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:28)
    at
    org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:68)
    at
    org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:42)
    at
    org.gradle.launcher.exec.DaemonUsageSuggestingBuildActionExecuter.execute(DaemonUsageSuggestingBuildActionExecuter.java:50)
    at
    org.gradle.launcher.exec.DaemonUsageSuggestingBuildActionExecuter.execute(DaemonUsageSuggestingBuildActionExecuter.java:27)
    at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:40)
    at
    org.gradle.internal.Actions$RunnableActionAdapter.execute(Actions.java:170)
    at
    org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:237)
    at
    org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:210)
    at
    org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:35)
    at
    org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:24)
    at
    org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:206)
    at
    org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:169)
    at
    org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33)
    at
    org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22)
    at org.gradle.launcher.Main.doAction(Main.java:33)
    at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
    at
    org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:54)
    at
    org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:35)
    at org.gradle.launcher.GradleMain.main(GradleMain.java:23)
    Caused by: org.gradle.api.InvalidUserDataException: Cannot expand TAR
    ‘/usr/src/ami_build/jruby-bin-9.0.0.0.pre2.tar.gz’.
    at
    org.gradle.api.internal.file.archive.TarFileTree.visit(TarFileTree.java:69)
    at
    org.gradle.api.internal.file.collections.FileTreeAdapter.visit(FileTreeAdapter.java:108)
    at
    org.gradle.api.internal.file.AbstractFileTree$FilteredFileTree.visit(AbstractFileTree.java:137)
    at
    org.gradle.api.internal.file.CompositeFileTree.visit(CompositeFileTree.java:55)
    at
    org.gradle.api.internal.file.copy.CopySpecActionImpl.execute(CopySpecActionImpl.java:37)
    at
    org.gradle.api.internal.file.copy.CopySpecActionImpl.execute(CopySpecActionImpl.java:24)
    at
    org.gradle.api.internal.file.copy.DefaultCopySpec$DefaultCopySpecResolver.walk(DefaultCopySpec.java:498)
    at
    org.gradle.api.internal.file.copy.DefaultCopySpec.walk(DefaultCopySpec.java:322)
    at
    org.gradle.api.internal.file.copy.DelegatingCopySpecInternal.walk(DelegatingCopySpecInternal.java:206)
    at
    org.gradle.api.internal.file.copy.CopySpecBackedCopyActionProcessingStream.process(CopySpecBackedCopyActionProcessingStream.java:36)
    at
    org.gradle.api.internal.file.copy.DuplicateHandlingCopyActionDecorator$1.process(DuplicateHandlingCopyActionDecorator.java:44)
    at
    org.gradle.api.internal.file.copy.NormalizingCopyActionDecorator$1.process(NormalizingCopyActionDecorator.java:56)
    at
    org.gradle.api.internal.file.copy.FileCopyAction.execute(FileCopyAction.java:35)
    at
    org.gradle.api.internal.file.copy.NormalizingCopyActionDecorator.execute(NormalizingCopyActionDecorator.java:52)
    at
    org.gradle.api.internal.file.copy.DuplicateHandlingCopyActionDecorator.execute(DuplicateHandlingCopyActionDecorator.java:42)
    at
    org.gradle.api.internal.file.copy.CopyActionExecuter.execute(CopyActionExecuter.java:38)
    at
    org.gradle.api.internal.file.copy.FileCopier.doCopy(FileCopier.java:64)
    at org.gradle.api.internal.file.copy.FileCopier.copy(FileCopier.java:49)
    at
    org.gradle.api.internal.file.DefaultFileOperations.copy(DefaultFileOperations.java:134)
    at
    org.gradle.api.internal.project.AbstractProject.copy(AbstractProject.java:754)
    at org.gradle.groovy.scripts.DefaultScript.copy(DefaultScript.java:189)
    at org.gradle.groovy.scripts.DefaultScript.copy(DefaultScript.java:184)
    at
    build_8sfhc6lcmdgfvrux4zosnxnpv$_run_closure8_closure25.doCall(/root/source/amipacker/build.gradle:254)
    at
    org.gradle.api.internal.AbstractTask$ClosureTaskAction.execute(AbstractTask.java:558)
    at
    org.gradle.api.internal.AbstractTask$ClosureTaskAction.execute(AbstractTask.java:539)
    at
    org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80)
    at
    org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61)
    … 57 more
    Caused by: org.gradle.api.resources.ResourceException: Unable to create
    gzip input stream for resource
    /usr/src/ami_build/jruby-bin-9.0.0.0.pre2.tar.gz.
    at
    org.gradle.api.internal.file.archive.compression.GzipArchiver.read(GzipArchiver.java:64)
    at
    org.gradle.api.internal.file.MaybeCompressedFileResource.read(MaybeCompressedFileResource.java:46)
    at
    org.gradle.api.internal.file.archive.TarFileTree.visit(TarFileTree.java:67)
    … 83 more
    Caused by: java.util.zip.ZipException: Not in GZIP format
    at
    org.gradle.api.internal.file.archive.compression.GzipArchiver.read(GzipArchiver.java:61)
    … 85 more

BUILD FAILED

This is likely due to the additional regressions introduced in Ant 1.9.5. We’ve rolled back to 1.9.3 again.