I've been able to install drush on my vps account at inmotionhosting, but when I try to run any drush command (status, help, etc), I get the error above (drupal-library-8NUMBERS depending on the command).

I thought it might be permissions in the drush/lib directory, but after setting them to 777 still wouldn't run the command.

Then I found this in drush.inc :

function drush_tarball_extract($path, $destination = FALSE, $listing = FALSE) {
  // Check if tarball is supported.
  if (!drush_file_is_tarball($path)) {
    return drush_set_error('TARBALL_EXTRACT_UNKNOWN_FORMAT', dt('Unable to extract !path. Unknown archive format.', array('!path' => $path)));
  }

Not sure why that error would be thrown. I just did the pear install this morning. I doubt it is a bug, but wonder if anyone might have some ideas for me as to where I should look to get drush working.

Thanks.

Comments

stewart.adam’s picture

I have this error too, running drush with the -v argument in my case revealed that it downloads the file correctly and the checksum is verified, but for some reason it doesn't extract it. Manually using "tar xfz" results in a perfect extraction but then I get this error whenever attempting to download a module too.

jonhattan’s picture

The code involved here changed in #1706738: Clean up mime type detection and tarball management.

What php version and os are you using? @stewart.adam are you also in the same hosting provider as @stevebab?

It seems to me that the mime detection libraries are missing and the fallback mechanisms are unable to guess the mime type of the library compressed file (Console_Table - a tar.gz without proper extension). It could be nice if you can report the value of $content_type in drush_file_is_tarball() and also trace the execution of drush_mime_content_type and report where it fails.

stewart.adam’s picture

I'm not using the same host, but it's quite possible that the setups are similar. I am using a CentOS 5.8 cPanel host with PHP 5.2.14, so the same setup is bound to be found elsewhere too.

jonhattan’s picture

StatusFileSize
new4.63 KB

It seems php 5.2.x shipped with CentOS is compiled without mime magic support. It can be fixed by recompiling php, or enabling mime support in php.ini or installing fileinfo. Perhaps cpanel has a checkbox for that.

Anyway, if fileinfo / mime magic support is not available drush examines file headers to guess the file type. This is done in above mentioned drush_mime_content_type(). For some reason it doesn't get to this point or this check is failing for your envorinment.

The attached patch adds several debug statements to this function. Please apply it and report back the --debug output.

jonhattan’s picture

StatusFileSize
new5.88 KB

So I managed to install CentOS 5.8 and upgrade to php 5.2.17 and I'm unable to reproduce this. php is compiled --without-mime-magic and examining file headers does work.

Here's my debug output:

[root@centos drush]# php drush.php -d status 
Bootstrap to phase 0. [0 sec, 2.92 MB]                               [bootstrap]
Executing: which wget
  sh: which: command not found
Executing: curl --fail -s -L --connect-timeout 30 -o /tmp/download_filezDN5IN http://download.pear.php.net/package/Console_Table-1.1.3.tgz
Calling is_readable(/tmp/download_filezDN5IN) [0.61 sec, 2.93 MB]        [debug]
Calling is_writable(/usr/src/drush/lib) [0.62 sec, 2.93 MB]              [debug]
Calling rename(/tmp/download_filezDN5IN,                                 [debug]
/usr/src/drush/lib/drush-library-1336433407) [0.62 sec, 2.93 MB]
No fileinfo or mime_magic support available. [0.62 sec, 2.93 MB]         [debug]
Examining file headers. [0.62 sec, 2.93 MB]                              [debug]
Calling chdir(/usr/src/drush/lib) [0.62 sec, 2.94 MB]                    [debug]
Executing: tar -C /usr/src/drush/lib -xzf drush-library-1336433407
...

Attached a slightly different version of the same patch.

jonhattan’s picture

StatusFileSize
new5.28 KB

Are you getting the same error output as #1722304: Error after update: finfo::finfo(): Failed to load magic database ?

I was able to reproduce #1722304 by installing pecl's fileinfo.

New patch including a fix for the aforementioned issue.

stewart.adam’s picture

PHP was compiled with mime magic support, I don't have the PECL fileinfo extension installed.

Here's the result with debugging enabled, after applying the patch:

$ drush --debug
Bootstrap to phase 0. [0.01 sec, 2.96 MB]    [bootstrap]
Executing: which wget
  /usr/bin/wget
Executing: wget -q --timeout=30 -O /tmp/download_filemUUExh http://download.pear.php.net/package/Console_Table-1.1.3.tgz
Calling is_readable(/tmp/download_filemUUExh) [0.51 sec, 2.97 MB]        [debug]
Calling is_writable(/home/username/drush/lib) [0.51 sec, 2.97 MB]   [debug]
Calling rename(/tmp/download_filemUUExh,         [debug]
/home/username/drush/lib/drush-library-1324029338) [0.51 sec, 2.98 MB]
Unable to extract /home/username/drush/lib/drush-library-1324029338.    [error]
Unknown archive format. [0.51 sec, 2.98 MB]

After manually unpacking Console_Table, attempting to download a module does this:

$ drush dl views --debug
Bootstrap to phase 0. [0.01 sec, 2.96 MB]    [bootstrap]
Drush bootstrap phase : _drush_bootstrap_drush() [0.01 sec, 3.17 MB] [bootstrap]
Cache HIT cid: 5.5-commandfiles-0-10a89d7d8fe1e3a64b9d21b76509bcb9 [0.02 sec, 3.18 MB]    [debug]
Bootstrap to phase 0. [0.11 sec, 7.27 MB]             [bootstrap]
Found command: pm-download (commandfile=pm) [0.15 sec, 7.32 MB]       [bootstrap]
Loading version_control engine. [0.21 sec, 7.44 MB]      [notice]
Loading package_handler engine. [0.22 sec, 7.48 MB]      [notice]
Executing: wget --version
Loading release_info engine. [0.23 sec, 7.51 MB]         [notice]
Including /home/username/drush/commands/pm/download.pm.inc [0.23 sec, 7.67 MB]           [bootstrap]
Downloading release history from http://updates.drupal.org/release-history/views/7.x [0.24 sec, 7.82 MB]         [notice]
Executing: which wget
  /usr/bin/wget
Executing: wget -q --timeout=30 -O /tmp/download_filejIH7uY http://updates.drupal.org/release-history/views/7.x
Calling drush_delete_dir(/tmp/viewsNKph8Y, 1) [0.49 sec, 7.82 MB]         [debug]
Calling is_readable(/tmp/download_filejIH7uY) [0.49 sec, 7.82 MB]         [debug]
Calling is_writable(/tmp) [0.49 sec, 7.82 MB]             [debug]
Calling rename(/tmp/download_filejIH7uY, /tmp/viewsNKph8Y) [0.49 sec, 7.82 MB]    [debug]
Downloading project views to /tmp/drush_tmp_1344612759_5025299747531 ... [0.51 sec, 7.82 MB]     [notice]
Executing: wget -q --timeout=30 -O /tmp/download_filezPTwuY http://ftp.drupal.org/files/projects/views-7.x-3.3.tar.gz
Calling is_readable(/tmp/download_filezPTwuY) [1.5 sec, 7.83 MB]          [debug]
Calling is_writable(/tmp/drush_tmp_1344612759_5025299747531) [1.5 sec, 7.83 MB]           [debug]
Calling rename(/tmp/download_filezPTwuY, /tmp/drush_tmp_1344612759_5025299747531/views-7.x-3.3.tar.gz) [1.5 sec, 7.83 MB]         [debug]
Downloading views-7.x-3.3.tar.gz was successful. [1.5 sec, 7.83 MB]      [notice]
Calling md5_file(/tmp/drush_tmp_1344612759_5025299747531/views-7.x-3.3.tar.gz) [1.5 sec, 7.83 MB]         [debug]
Md5 checksum of views-7.x-3.3.tar.gz verified. [1.53 sec, 7.83 MB]       [notice]
Unable to extract /tmp/drush_tmp_1344612759_5025299747531/views-7.x-3.3.tar.gz. Unknown archive format. [1.53 sec, 7.84 MB]   [error]
Verifying signature for svn version control engine. [1.53 sec, 7.85 MB]           [debug]
Executing: svn info /home/username
  sh: svn: command not found
Verifying signature for bzr version control engine. [1.54 sec, 7.85 MB]           [debug]
Executing: bzr root /home/username
  sh: bzr: command not found
Calling _drush_recursive_copy(/tmp/drush_tmp_1344612759_5025299747531/views, /home/username/views) [1.55 sec, 7.85 MB]       [debug]
copy(/tmp/drush_tmp_1344612759_5025299747531/views): failed to open stream: No such file or directory filesystem.inc:224 [1.55 sec, 7.85 MB]  [warning]
Project views (7.x-3.3) could not be downloaded to /home/username/views. [1.55 sec, 7.85 MB]     [error]
Command dispatch complete [1.55 sec, 7.8 MB]             [notice]
Peak memory usage was 8.66 MB [1.55 sec, 7.8 MB]

Edit: not sure why the copy/pasting the terminal output directly makes the formatting very bizarre ("MB" wraps on a second line while [debug[ is still displayed on the first). Reduced the number of spaces preceding the message type to have it display properly.

jonhattan’s picture

Component: Core Commands » Base system (internal API)

Sorry it seems to me you didn't apply the patch. There should be some debug line before "Unable to extract ..."

If you're willing to chat I'm at #drush in freenode now.

jonhattan’s picture

Or perhaps $content_type = mime_content_type($filename); in line 922 of includes/drush.inc return a value we don't expect.

jonhattan’s picture

Status: Active » Fixed
StatusFileSize
new7.62 KB

so mime_content_type() for @stewart.adam's hosting returns:

output is string(25) "application/octet-stream " (that tab is not a typo)

so we need to just trim it.

Committing patch attached.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

bu5hm4nn’s picture

Just a note to anyone that still gets "Unknown archive format". I was missing the pear package Console_Color, after installing it with "pear install Console_Color" drush worked fine.

graceman9’s picture

Issue summary: View changes

Just another note:
I fixed it by adding 'application/gzip' line in drush_file_is_tarball() in drush/includes/drush.inc
Perhaps it's a problem with php7.4, not sure.

tadejk’s picture

#13 worked fine for me.

flotsam’s picture

#13 also worked for me. Thanks, graceman9! I'm also running php7.4.

Tilo Schumann’s picture

Issue tags: +#13 worked for me, +thank you

#13 worked for me, thank you

marcoka’s picture

Issue tags: -

Thank you sooooooo much #13. Works.
So many problems these days making me crazy.

kendouglass’s picture

#13 worked for me. I'm running PHP 7.4.3

Epoxyde’s picture

#13 worked for me (PHP 7.4.3) Thanks!

ccarnnia’s picture

Same issue.
i am on php 7.4.3
fixed by upgrading drush from 8.1.17 to 8.3.3 (https://docs.drush.org/en/8.x/install/)

hermann77’s picture

Same issue.
i am on php 7.4.5
fixed by upgrading drush from 8.1.15 to 8.3.3:

changed (updated to 8.3.3) Drush-Version in
~/.composer/composer.json

and

composer update

bburg’s picture

I had to do the fix in #13, and I'm supposedly using 8.4.5

slim ch’s picture

#13 worked for me !
Thanks a lot

Acha2019’s picture

If you are using drush version 6.7.0 you can add ‘application/gzip' in drush.inc

Before :

/**
 * Check whether a file is a supported tarball.
 *
 * @return mixed
 *   The file content type if it's a tarball. FALSE otherwise.
 */
function drush_file_is_tarball($path) {
  $content_type = drush_mime_content_type($path);
  $supported = array(
    'application/x-bzip2',
    'application/x-gzip',
    'application/x-tar',
    'application/x-zip',
    'application/zip',
  );
  if (in_array($content_type, $supported)) {
    return $content_type;
  }
  return FALSE;
}

After

/**
 * Check whether a file is a supported tarball.
 *
 * @return mixed
 *   The file content type if it's a tarball. FALSE otherwise.
 */
function drush_file_is_tarball($path) {
  $content_type = drush_mime_content_type($path);
  $supported = array(
    'application/x-bzip2',
    'application/x-gzip',
    'application/x-tar',
    'application/x-zip',
    'application/zip',
    'application/gzip',
  );
  if (in_array($content_type, $supported)) {
    return $content_type;
  }
  return FALSE;
}

If it can help

rivki zipori’s picture

#13 worked for me!
I need these changes in a patch.
But a patch will not work since the Drupal core cannot extract...the original problem.
I have a rebuild bash script that also runs the
drush make command,
I can add bash commands that will run these changes before the drush make command.
But I want a better solution, a Drupal/ Drush solution, not a system solution....

audetcameron’s picture

can confirm #13 worked for me as well (note Drush was installed manually) and not from composer
Cent OS 7x
Drush Version : 9.0-dev
php 7.4.29

yaach’s picture

Same issue, #21 fixed it.

My environment:
* PHP 7.4
* Drush 7.4.2 (before upgrade to 8.3.3)