4

Trying to install node.js via composer (for automation).

"repositories": [
  "type": "package",
    "package": {
        "name": "nodejs/nodejs",
        "version": "0.12.6",
        "dist": {
        "type": "gzip",
        "url": "https://nodejs.org/dist/v0.12.6/node-v0.12.6-linux-x64.tar.gz"
      }
    }
  }
],
"require": {
  "nodejs/nodejs": "0.12.*"
}

Problem is, I can either use tar or gzip to unpack the archieve.

Available types: git, svn, hg, perforce, zip, rar, tar, gzip, phar, file.

The nodejs package obviously uses both.

How can I unpack .tar.gz packed files using composer?

I know I could use post-update-cmd and post-install-cmd commands and manually execute untar/gunzip, but that's not the way composer is ment to be.

4
  • Doesn't it use tar with the -z flag?
    – Hennes
    Jul 6 '15 at 9:56
  • When using "tar", nothing gets unpacked, when I use "gzip", it does not untar.
    – Daniel W.
    Jul 6 '15 at 9:57
  • 'tar' just installed and unpacked a tar.gz from google code archive fine for me. good thing, too - no more repo access on google code and some projects have not yet moved elsewhere!
    – Joey T
    Aug 18 '16 at 22:47
  • The same use-case to install the Ace editor via composer from github.com/ajaxorg/ace/archive/v1.2.6.tar.gz Apr 14 '17 at 1:25
8

The "tar" option understands both bare .tar, .tar.gz, and even .tar.bz2 so just specify "type": "tar" and there is no need to specify the "gz". It figures out the decompression on it's own.

I ran into this issue, and was also initially confused, trying to auto-deploy a php app that used a proprietary library. However I tried just "tar", it worked! My repositories JSON part looks a little goofy because of the unusual structure of the tar archive, but it does work. It looked something like this:

"repositories": [
  {
    "type": "package",
    "package": {
      "name": "RocketShipIt/RocketShipIt",
      "version": "1.4.9.3",
      "dist": {
        "url": "https://secret-deployment-server/RocketShipIt.tar.gz",
        "type": "tar"
      },
      "autoload": {
        "files": [
          "RocketShipIt/RocketShipIt.php"
        ],
        "psr-0": {
          "RocketShipIt\\": "RocketShipIt/RocketShipIt/RocketShipIt/"
        }
      }
    }
  }
]

You can find, somewhat obscurely in the Composer API documentation (not the end-user manual) that the .tar, .tar.gz and .tar.bz2 are all three officially supported by "type": "tar". Apparently, it is handled internally by composer by the Composer\Downloader\TarDownloader class.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.