pear

PEAR:but it is not a valid package archiveとなってしまう時の対処

More than 3 years have passed since last update.

背景

pearでpackageをインストールしようと思ったらコケた

環境

# cat /etc/system-release
CentOS release 6.6 (Final)
# pear version
PEAR Version: 1.9.4
PHP Version: 5.6.5
Zend Engine Version: 2.6.0
Running on: Linux xxx.yyy.zzz.jp.internal 2.6.32-504.1.3.el6.x86_64 #1 SMP Tue Nov 11 17:57:25 UTC 2014 x86_64

結果

アップグレード失敗するpearのArchive/Tar.phpを手動でコピーしたらupgrade、installできた

# pear upgrade Archive_Tar
downloading Archive_Tar-1.3.13.tgz ...
Starting to download Archive_Tar-1.3.13.tgz (19,891 bytes)
.......done: 19,891 bytes
could not extract the package.xml file from "/tmp/pear/download/Archive_Tar-1.3.13.tgz"
Download of "pear/Archive_Tar" succeeded, but it is not a valid package archive
Error: cannot download "pear/Archive_Tar"
Download failed
upgrade failed
# cd /tmp/pear/download/
# tar -zxvf Archive_Tar-1.3.13.tgz
package.xml
Archive_Tar-1.3.13/Archive/Tar.php
Archive_Tar-1.3.13/docs/Archive_Tar.txt
# mv /usr/share/pear/Archive/Tar.php /usr/share/pear/Archive/Tar.php.org
# cp /tmp/pear/download/Archive_Tar-1.3.13/Archive/Tar.php /usr/share/pear/Archive/

やったことの手順

PHP_CodeSnifferのインストール

# pear install PHP_CodeSniffer
WARNING: channel "pear.php.net" has updated its protocols, use "pear channel-update pear.php.net" to update
downloading PHP_CodeSniffer-2.2.0.tgz ...
Starting to download PHP_CodeSniffer-2.2.0.tgz (460,611 bytes)
.............................................................................................done: 460,611 bytes
could not extract the package.xml file from "/tmp/pear/download/PHP_CodeSniffer-2.2.0.tgz"
Download of "pear/PHP_CodeSniffer" succeeded, but it is not a valid package archive
Error: cannot download "pear/PHP_CodeSniffer"
Download failed
install failed

ファイルはダウンロード出来たが、Archiveファイルの解凍?でこけてるっぽい

ちなみにtarもzipもインストールされている

pearを最新にしてみる

phpを5.6にしているせいかと思ってpearを更新してみる

# yum update --enablerepo=remi-php56 php-pear
読み込んだプラグイン:fastestmirror, presto
更新処理の設定をしています
Loading mirror speeds from cached hostfile
 * base: ftp.tsukuba.wide.ad.jp
 * epel: s3-mirror-ap-northeast-1.fedoraproject.org
 * extras: ftp.tsukuba.wide.ad.jp
 * remi-php56: remi.kazukioishi.net
 * updates: ftp.tsukuba.wide.ad.jp
更新と設定されたパッケージがありません。

はい。最新でした。

pear の更新状況を確認する

# pear list-upgrades
WARNING: channel "pear.php.net" has updated its protocols, use "pear channel-update pear.php.net" to update
PEAR.PHP.NET AVAILABLE UPGRADES (STABLE):
=========================================
CHANNEL      PACKAGE        LOCAL          REMOTE          SIZE
pear.php.net Archive_Tar    1.3.7 (stable) 1.3.13 (stable) 19.5kB
pear.php.net Console_Getopt 1.2.3 (stable) 1.4.0 (stable)  4.5kB
pear.php.net PEAR           1.9.4 (stable) 1.9.5 (stable)  284kB
pear.php.net XML_RPC        1.5.4 (stable) 1.5.5 (stable)  32kB
pear.php.net XML_Util       1.2.1 (stable) 1.2.3 (stable)  16.8kB

いろいろアップデートがある!あやしいArchive_Tarも!!

pearのpackageを全てアップグレードしてみる

# pear upgrade
WARNING: "pear/XML_RPC" is deprecated in favor of "pear/XML_RPC2"
WARNING: "pear/Console_Getopt" is deprecated in favor of "pear/Console_GetoptPlus"
downloading XML_Util-1.2.3.tgz ...
Starting to download XML_Util-1.2.3.tgz (17,134 bytes)
......done: 17,134 bytes
could not extract the package.xml file from "/tmp/pear/download/XML_Util-1.2.3.tgz"
Download of "pear/xml_util" succeeded, but it is not a valid package archive
Error: cannot download "pear/XML_Util"
downloading Archive_Tar-1.3.13.tgz ...
Starting to download Archive_Tar-1.3.13.tgz (19,891 bytes)
...done: 19,891 bytes
could not extract the package.xml file from "/tmp/pear/download/Archive_Tar-1.3.13.tgz"
Download of "pear/archive_tar" succeeded, but it is not a valid package archive
Error: cannot download "pear/Archive_Tar"
downloading PEAR-1.9.5.tgz ...
Starting to download PEAR-1.9.5.tgz (290,006 bytes)
...done: 290,006 bytes
could not extract the package.xml file from "/tmp/pear/download/PEAR-1.9.5.tgz"
Download of "pear/pear" succeeded, but it is not a valid package archive
Error: cannot download "pear/PEAR"
downloading XML_RPC-1.5.5.tgz ...
Starting to download XML_RPC-1.5.5.tgz (31,862 bytes)
...done: 31,862 bytes
could not extract the package.xml file from "/tmp/pear/download/XML_RPC-1.5.5.tgz"
Download of "pear/xml_rpc" succeeded, but it is not a valid package archive
Error: cannot download "pear/XML_RPC"
downloading Console_Getopt-1.4.0.tgz ...
Starting to download Console_Getopt-1.4.0.tgz (4,534 bytes)
...done: 4,534 bytes
could not extract the package.xml file from "/tmp/pear/download/Console_Getopt-1.4.0.tgz"
Download of "pear/console_getopt" succeeded, but it is not a valid package archive
Error: cannot download "pear/Console_Getopt"
Download failed
upgrade failed

全てコケた。。。 PHP_CodeSnifferをインストールした時と同じエラー

Archive/Tar.phpを手動でおきかえちゃう

アーカイブのダウンロードは成功しているので手動で解凍、配置しちゃう

元のファイルは念のためバックアップしておく

# cd /tmp/pear/download/
# tar -zxvf Archive_Tar-1.3.13.tgz
package.xml
Archive_Tar-1.3.13/Archive/Tar.php
Archive_Tar-1.3.13/docs/Archive_Tar.txt
# mv /usr/share/pear/Archive/Tar.php /usr/share/pear/Archive/Tar.php.org
# cp /tmp/pear/download/Archive_Tar-1.3.13/Archive/Tar.php /usr/share/pear/Archive/

再度pearのpackageをアップグレードしてみる


# pear upgrade
WARNING: "pear/XML_RPC" is deprecated in favor of "pear/XML_RPC2"
WARNING: "pear/Console_Getopt" is deprecated in favor of "pear/Console_GetoptPlus"
downloading PEAR-1.9.5.tgz ...
Starting to download PEAR-1.9.5.tgz (290,006 bytes)
............................................................done: 290,006 bytes
downloading XML_RPC-1.5.5.tgz ...
Starting to download XML_RPC-1.5.5.tgz (31,862 bytes)
.........done: 31,862 bytes
downloading Archive_Tar-1.3.13.tgz ...
Starting to download Archive_Tar-1.3.13.tgz (19,891 bytes)
...done: 19,891 bytes
downloading Console_Getopt-1.4.0.tgz ...
Starting to download Console_Getopt-1.4.0.tgz (4,534 bytes)
...done: 4,534 bytes
downloading XML_Util-1.2.3.tgz ...
Starting to download XML_Util-1.2.3.tgz (17,134 bytes)
...done: 17,134 bytes
upgrade ok: channel://pear.php.net/Archive_Tar-1.3.13
upgrade ok: channel://pear.php.net/Console_Getopt-1.4.0
upgrade ok: channel://pear.php.net/XML_Util-1.2.3
upgrade ok: channel://pear.php.net/PEAR-1.9.5
upgrade ok: channel://pear.php.net/XML_RPC-1.5.5
PEAR: Optional feature webinstaller available (PEAR's web-based installer)
PEAR: Optional feature gtkinstaller available (PEAR's PHP-GTK-based installer)
PEAR: Optional feature gtk2installer available (PEAR's PHP-GTK2-based installer)
PEAR: To install optional features use "pear install pear/PEAR#featurename"

アップグレード出来た!

再度PHP_CodeSnifferのインストール

# pear install PHP_CodeSniffer
downloading PHP_CodeSniffer-2.2.0.tgz ...
Starting to download PHP_CodeSniffer-2.2.0.tgz (460,611 bytes)
.............................................................................................done: 460,611 bytes
install ok: channel://pear.php.net/PHP_CodeSniffer-2.2.0

インストールできた!

根本の解決にはなっていないし

他にいい方法があるかもしれないけど、そこはプロに任せます

pearのアップグレード時にdeprecatedのworning出てたけど開発環境だし今回は無視

気になる人はちゃんとインストールしよう

# pear install XML_RPC2
downloading XML_RPC2-1.1.2.tgz ...
Starting to download XML_RPC2-1.1.2.tgz (67,331 bytes)
.................done: 67,331 bytes
downloading HTTP_Request2-2.2.1.tgz ...
Starting to download HTTP_Request2-2.2.1.tgz (107,339 bytes)
...done: 107,339 bytes
downloading Cache_Lite-1.7.16.tgz ...
Starting to download Cache_Lite-1.7.16.tgz (32,997 bytes)
...done: 32,997 bytes
downloading Net_URL2-2.1.1.tgz ...
Starting to download Net_URL2-2.1.1.tgz (19,848 bytes)
...done: 19,848 bytes
install ok: channel://pear.php.net/Cache_Lite-1.7.16
install ok: channel://pear.php.net/Net_URL2-2.1.1
install ok: channel://pear.php.net/HTTP_Request2-2.2.1
install ok: channel://pear.php.net/XML_RPC2-1.1.2

# pear install Console_GetoptPlus-1.0.0RC1
downloading Console_GetoptPlus-1.0.0RC1.tgz ...
Starting to download Console_GetoptPlus-1.0.0RC1.tgz (22,565 bytes)
........done: 22,565 bytes
install ok: channel://pear.php.net/Console_GetoptPlus-1.0.0RC1

参考にさせて頂いたURL

http://phpobenkyo.seesaa.net/article/410455059.html