Last Updated: February 25, 2016
· billagee

Capistrano workaround to avoid untarring errors when deploying from OSX to Linux

If you see errors like this when capistrano is deploying from OSX to Linux:

tar: Ignoring unknown extended header keyword `'

In your capistrano task, use the line below to change the default tar program to /usr/bin/gnutar:

set :copy_local_tar, "/usr/bin/gnutar" if `uname` =~ /Darwin/

This makes Capistrano use gnutar (rather than the default OSX /usr/bin/tar) when creating the tar archive to deploy. With that change, your Linux target should be able to untar the archive without issues.

2 Responses
Add your response

This problem has me curious. It used to be that back in the day, you had to set this environment variable to build proper tarbals for CPAN/Perl, deploy to cap, etc:


Now, for a few people, this error popped up in capistrano, even after plenty of successful deploys in the past.

Why now? Did an OSX update tar lately or something to cause this?

over 1 year ago ·

It looks like GNU tar is not included with OS X Mavericks. To work around this, we've been checking whether /usr/bin/gnutar exists rather than checking the operating system name:

set :gnu_tar_path, "/usr/bin/gnutar"
set :copy_local_tar, gnu_tar_path if File.exist?(gnu_tar_path)
over 1 year ago ·