MAMP: How to upgrade PEAR

浪尽此生 提交于 2019-12-29 18:39:07

问题


When trying to upgrade MAMP pear the following error is raised:

Notice: unserialize(): Error at offset 276 of 1133 bytes in Config.php on line 1050
ERROR: The default config file is not a valid config file or is corrupted.

Some suggestions how to fix this?

Steps to reproduce:

  • Installed MAMP (version 2.0.5)
  • cd /Applications/MAMP/bin/php/php5.3.6/bin
  • sudo ./pear upgrade pear
  • above mentioned error is thrown

Update (1):

Based on answer 8375349/420953 I tried 2 possibilities to fix this

  • A: delete pear.conf
    • rm /Applications/MAMP/bin/php/php5.3.6/conf/pear.conf
  • B: edit pear.conf
    • change "php_dir";s:44 to "php_dir";s:43

both resulted in error:

Could not get contents of package "/Applications/MAMP/bin/php/php5.3.6/bin/pear". Invalid tgz file.
upgrade failed

Update (2):

running

  • which pear

results in output

  • /usr/local/bin/pear

With this, I noticed that I was using the "local" version of PEAR.

I removed it with

  • sudo pear uninstall pear

and then tried to upgrade the MAMP version of PEAR with

  • /Applications/MAMP/bin/php/php5.3.6/bin/pear upgrade pear

this results in error

Cannot install, php_dir for channel "pear.php.net" is not writeable by the current user

upgrading with

  • sudo /Applications/MAMP/bin/php/php5.3.6/bin/pear upgrade pear

installs it locally (again).

running

  • which pear

outputs

  • /usr/local/bin/pear

this brings me back to the starting point of Update (2). Seems that I am not able to upgrade PEAR under a MAMP directory.

Update (3):

I posted question

  • MAMP PEAR configuration is pointing to local directories

because my assumption is that the root of this issue is related to MAMP PEAR config.

Update (4):

I did not install a local PEAR version and this was causing quite some issues. After also installing a local version (and not only the MAMP) version, upgarding the MAMP version worked perfectly.


回答1:


People with the your exact problem seem to has solved it in this MAMP forum thread.

You can either delete /Applications/MAMP/bin/php/php5.3.6/conf/pear.conf, or change a line in that file from "php_dir";s:44 to "php_dir";s:43.




回答2:


Edit the pear.conf: Adding a forward slash "/" to the end of the php_dir path, while keeping the s:44 solved the problem for me and a couple coworkers.




回答3:


I have XAMPP installed, and I just deleted /xampp/php/pear.ini and that solved the same problem




回答4:


Just chipping in with a late response for others finding this answer. My PEAR config had several issues and not just the php_dir config setting.

I had to go over all of my settings to verify that the count was correct. When all errors where fixed my PEAR was working fine again.

Seeing this message in the terminal:

Notice: unserialize(): Error at offset 276 of 1133 bytes in Config.php on line 1050
ERROR: The default config file is not a valid config file or is corrupted.
  1. Go to your PEAR Config file (probably located here /MAMP/bin/php/php7.0.10/conf/pear.conf)
  2. Go to the 276th character in that file and verify that the string length matches the s43 that's defined before the string.
  3. Run a PEAR command again (e.g. pear version)
  4. If you have more errors located at e.g. 317th character you count that string and write the length in the s:XX before the string.

Just for clarifying for others finding this issue. The PEAR Config file is a serialized object that is unserialized when running commands.

A serialized object looks like s:5:"value" with the s:5 defining the length the string.



来源:https://stackoverflow.com/questions/8375327/mamp-how-to-upgrade-pear

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!