将 PEAR 从 1.9.0 升级到 1.9.1 失败

将 PEAR 从 1.9.0 升级到 1.9.1 失败

我愿意安装带有 MAMP 1.9 的 phpunit 5.3,因此我需要将 PEAR 升级到版本 1.9.1。当前安装的版本是 1.9.0。

当我尝试升级时,出现以下信息:

sudo pear channel-update pear.php.net
sudo pear upgrade pear
Could not get contents of package "/Applications/MAMP/bin/php5.3/bin/pear". Invalid tgz file.
upgrade failed

当我强制升级时它仍然不起作用:

sudo pear upgrade --force PEAR
downloading PEAR-1.9.1.tgz ...
Starting to download PEAR-1.9.1.tgz (293,587 bytes)
.............................................................done: 293,587 bytes
upgrade ok: channel://pear.php.net/PEAR-1.9.1
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"

sudo pear -V
PEAR Version: 1.9.0

正如 bindbn 所建议的:

sudo pear install --offline /Users/tom/Downloads/PEAR-1.9.1.tgz 
Ignoring installed package pear/PEAR
Nothing to install

sudo pear upgrade --force --alldeps PEAR
downloading PEAR-1.9.1.tgz ...
Starting to download PEAR-1.9.1.tgz (293,587 bytes)
.............................................................done: 293,587 bytes
upgrade ok: channel://pear.php.net/PEAR-1.9.1
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"
pear -V
PEAR Version: 1.9.0

希望有人能解决这个问题!谢谢!

答案1

我遇到了同样的问题。您必须重新配置它才能找到 PEAR 包。

将 Mac OS X 的 php 版本替换为 MAMP 的版本

$ cd /usr/bin
$ cp php php.bak (Backup the old version)
$ ln -s /Application/MAMP/bin/php5.3/bin/php (link to the version of MAMP php)
$ sudo chmod 0554 /Application/MAMP/bin/php5.3/bin/* (makes all the scripts executable)

$ php -v
PHP 5.3.2 (cli) (built: Mar  5 2010 16:45:34) 
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
    with XCache v1.3.0, Copyright (c) 2005-2009, by mOo

配置PEAR:

 $ cd /Application/MAMP/bin/php5.3/bin
 $ pear -V
 PEAR Version: 1.9.0
 PHP Version: 5.3.2
 Zend Engine Version: 2.3.0
 Running on: 
 Darwin mbp.local 9.8.0 
 Darwin Kernel Version 9.8.0: Wed Jul 15 16:55:01 PDT 2009; 
 root:xnu-1228.15.4~1/RELEASE_I386 i386

$ pear config-show

修改以下键以指向 /Applications/MAMP/bin/php5.3/lib/php 中的文件夹

$ pear config-set [key] [path]

PEAR documentation directory   doc_dir          /Applications/MAMP/bin/php5.3/lib/php/doc
PHP extension directory        ext_dir          /Applications/MAMP/bin/php5.3/lib/php/extensions
PEAR directory                 php_dir          /Applications/MAMP/bin/php5.3/lib/php/PEAR
PHP CLI/CGI binary             php_bin          /Applications/MAMP/bin/php5.3/bin/php
php.ini location               php_ini          /Applications/MAMP/conf/php5.3/php.ini
Signature Key Directory        sig_keydir       /Applications/MAMP/conf/php5.3/pearkeys

更新频道:

$ pear channel-update pear.php.net

升级 PEAR:

$ pear upgrade pear
downloading PEAR-1.9.1.tgz ...
Starting to download PEAR-1.9.1.tgz (293,587 bytes)
.............................................................done: 293,587 bytes
downloading Archive_Tar-1.3.7.tgz ...
Starting to download Archive_Tar-1.3.7.tgz (17,610 bytes)
...done: 17,610 bytes
downloading Structures_Graph-1.0.3.tgz ...
Starting to download Structures_Graph-1.0.3.tgz (30,191 bytes)
...done: 30,191 bytes
downloading Console_Getopt-1.2.3.tgz ...
Starting to download Console_Getopt-1.2.3.tgz (4,011 bytes)
...done: 4,011 bytes
downloading XML_Util-1.2.1.tgz ...
Starting to download XML_Util-1.2.1.tgz (17,729 bytes)
...done: 17,729 bytes
upgrade ok: channel://pear.php.net/Archive_Tar-1.3.7
upgrade ok: channel://pear.php.net/Structures_Graph-1.0.3
upgrade ok: channel://pear.php.net/Console_Getopt-1.2.3
upgrade ok: channel://pear.php.net/XML_Util-1.2.1
upgrade ok: channel://pear.php.net/PEAR-1.9.1
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"

$ pear -V
PEAR Version: 1.9.1
PHP Version: 5.3.2
Zend Engine Version: 2.3.0
Running on: 
Darwin mbp.local 9.8.0 
Darwin Kernel Version 9.8.0: Wed Jul 15 16:55:01 PDT 2009; root:xnu-1228.15.4~1/RELEASE_I386 i386

答案2

尝试:

sudo pear upgrade --force --alldeps PEAR

或者

sudo pear install --offline /Applications/MAMP/bin/php5.3/bin/pear/PEAR-1.9.1.tgz

答案3

经过几个小时的搜索,我的 PEAR 密钥指向的是 php 5,而不是 php 5.2,后者是我路径中的 php 版本。

如上所述,使用以下方式列出梨键

$ pear config-show

然后设置按键

pear config-set [key] [path]

PEAR documentation directory   doc_dir          /Applications/MAMP/bin/php5.x/lib/php/doc
PHP extension directory        ext_dir          /Applications/MAMP/bin/php5.x/lib/php/extensions
PEAR directory                 php_dir          /Applications/MAMP/bin/php5.x/lib/php/PEAR
PHP CLI/CGI binary             php_bin          /Applications/MAMP/bin/php5.x/bin/php
php.ini location               php_ini          /Applications/MAMP/conf/php5.x/php.ini
Signature Key Directory        sig_keydir       /Applications/MAMP/conf/php5.x/pearkeys

确保您使用的 php 版本为 5.x。要了解您的 php 版本

$ php -i

现在我只能安装 php 单元测试 * 叹息 *

答案4

我正在尝试为 MAMP 安装 phpunit,因此下面是我采取的步骤(按照上面链接的教程)。

$ cd /usr/bin
$ sudo rm ./php
$ sudo rm ./pear
$ sudo ln -s /Applications/MAMP/bin/php5.3/bin/pear
$ sudo ln -s /Applications/MAMP/bin/php5.3/bin/php

在您的网络浏览器中,打开:http://pear.php.net/go-pear

将代码保存到 /Applications/MAMP/bin/php5.3/go-pear.php

$ cd /Applications/MAMP/bin/php5.3
$ php ./go-pear.php

按照屏幕上的提示操作,当出现要安装的软件包列表时选择 Y。您可能会看到以下消息:

警告!当前使用的 php.ini 中定义的 include_path 不包含您刚刚指定的 PEAR PHP 目录:如果指定的目录也不在您的脚本使用的 include_path 中,则您将无法使用任何 PEAR 包。

您想修改 php.ini 吗?[Y/n]:

输入 Y 继续。现在应该显示:

php.ini include_path 已更新。

当前包含路径:.:/Applications/MAMP/bin/php5.3/lib/php

配置目录:/Applications/MAMP/bin/php5.3/PEAR

当前使用的 php.ini(猜测):/Applications/MAMP/conf/php5.3/php.ini

按 Enter 继续:

按下回车键,您就可以开始了。

现在,为了确保你有 pea 1.9.1,请运行

$ pear version

现在您可以按照说明安装 phpunit。安装 phpunit 后,它将放置在 /Applications/MAMP/bin/php5.3/PEAR/PHP/

相关内容