Pear error "XML Extension not found" on Ubuntu 14.04 after installing php-xml & php-xml7.0
Asked Answered
P

5

16

I wanna use the pecl command to install redis to my php on Ubuntu 14.04. But my Pear is giving me a list of warnings:

Warning: Invalid argument supplied for foreach() in Command.php on line 249

Warning: Invalid argument supplied for foreach() in /usr/share/php/PEAR/Command.php on line 249

Warning: Invalid argument supplied for foreach() in Command.php on line 249

Warning: Invalid argument supplied for foreach() in /usr/share/php/PEAR/Command.php on line 249

Warning: Invalid argument supplied for foreach() in Command.php on line 249

Warning: Invalid argument supplied for foreach() in /usr/share/php/PEAR/Command.php on line 249

Warning: Invalid argument supplied for foreach() in Command.php on line 249

Warning: Invalid argument supplied for foreach() in /usr/share/php/PEAR/Command.php on line 249

Warning: Invalid argument supplied for foreach() in Command.php on line 249

Warning: Invalid argument supplied for foreach() in /usr/share/php/PEAR/Command.php on line 249

Warning: Invalid argument supplied for foreach() in Command.php on line 249

Warning: Invalid argument supplied for foreach() in /usr/share/php/PEAR/Command.php on line 249

Warning: Invalid argument supplied for foreach() in Command.php on line 249

Warning: Invalid argument supplied for foreach() in /usr/share/php/PEAR/Command.php on line 249

Warning: Invalid argument supplied for foreach() in Command.php on line 249

Warning: Invalid argument supplied for foreach() in /usr/share/php/PEAR/Command.php on line 249

Warning: Invalid argument supplied for foreach() in Command.php on line 249

Warning: Invalid argument supplied for foreach() in /usr/share/php/PEAR/Command.php on line 249

Warning: Invalid argument supplied for foreach() in Command.php on line 249

Warning: Invalid argument supplied for foreach() in /usr/share/php/PEAR/Command.php on line 249

Warning: Invalid argument supplied for foreach() in Command.php on line 249

Warning: Invalid argument supplied for foreach() in /usr/share/php/PEAR/Command.php on line 249

Notice: Undefined index: honorsbaseinstall in Role.php on line 173

Notice: Undefined index: honorsbaseinstall in Role.php on line 173

Notice: Undefined index: honorsbaseinstall in Role.php on line 173

Notice: Undefined index: honorsbaseinstall in Role.php on line 173

Notice: Undefined index: honorsbaseinstall in Role.php on line 173

Notice: Undefined index: honorsbaseinstall in Role.php on line 173

Notice: Undefined index: honorsbaseinstall in Role.php on line 173

Notice: Undefined index: honorsbaseinstall in Role.php on line 173

Notice: Undefined index: honorsbaseinstall in Role.php on line 173

Notice: Undefined index: honorsbaseinstall in Role.php on line 173

Notice: Undefined index: installable in Role.php on line 139

Notice: Undefined index: installable in Role.php on line 139

Notice: Undefined index: installable in Role.php on line 139

Notice: Undefined index: installable in Role.php on line 139

Notice: Undefined index: installable in Role.php on line 139

Notice: Undefined index: installable in Role.php on line 139

Notice: Undefined index: installable in Role.php on line 139

Notice: Undefined index: installable in Role.php on line 139

Notice: Undefined index: installable in Role.php on line 139

Notice: Undefined index: installable in Role.php on line 139

Notice: Undefined index: phpfile in Role.php on line 204

Notice: Undefined index: phpfile in Role.php on line 204

Notice: Undefined index: phpfile in Role.php on line 204

Notice: Undefined index: phpfile in Role.php on line 204

Notice: Undefined index: phpfile in Role.php on line 204

Notice: Undefined index: phpfile in Role.php on line 204

Notice: Undefined index: phpfile in Role.php on line 204

Notice: Undefined index: phpfile in Role.php on line 204

Notice: Undefined index: phpfile in Role.php on line 204

Notice: Undefined index: phpfile in Role.php on line 204

Notice: Undefined index: config_vars in Role.php on line 46

Notice: Undefined index: config_vars in Role.php on line 46

Notice: Undefined index: config_vars in Role.php on line 46

Notice: Undefined index: config_vars in Role.php on line 46

Notice: Undefined index: config_vars in Role.php on line 46

Notice: Undefined index: config_vars in Role.php on line 46

Notice: Undefined index: config_vars in Role.php on line 46

Notice: Undefined index: config_vars in Role.php on line 46

Notice: Undefined index: config_vars in Role.php on line 46

Notice: Undefined index: config_vars in Role.php on line 46

Warning: Invalid argument supplied for foreach() in PEAR/Command.php on line 249

Warning: Invalid argument supplied for foreach() in /usr/share/php/PEAR/Command.php on line 249

Warning: Invalid argument supplied for foreach() in PEAR/Command.php on line 249

Warning: Invalid argument supplied for foreach() in /usr/share/php/PEAR/Command.php on line 249

Warning: Invalid argument supplied for foreach() in PEAR/Command.php on line 249

Warning: Invalid argument supplied for foreach() in /usr/share/php/PEAR/Command.php on line 249

Warning: Invalid argument supplied for foreach() in PEAR/Command.php on line 249

Warning: Invalid argument supplied for foreach() in /usr/share/php/PEAR/Command.php on line 249

Warning: Invalid argument supplied for foreach() in PEAR/Command.php on line 249

Warning: Invalid argument supplied for foreach() in /usr/share/php/PEAR/Command.php on line 249

Warning: Invalid argument supplied for foreach() in PEAR/Command.php on line 249

Warning: Invalid argument supplied for foreach() in /usr/share/php/PEAR/Command.php on line 249

Warning: Invalid argument supplied for foreach() in PEAR/Command.php on line 249

Warning: Invalid argument supplied for foreach() in /usr/share/php/PEAR/Command.php on line 249

Warning: Invalid argument supplied for foreach() in PEAR/Command.php on line 249

Warning: Invalid argument supplied for foreach() in /usr/share/php/PEAR/Command.php on line 249

Warning: Invalid argument supplied for foreach() in PEAR/Command.php on line 249

Warning: Invalid argument supplied for foreach() in /usr/share/php/PEAR/Command.php on line 249

Warning: Invalid argument supplied for foreach() in PEAR/Command.php on line 249

Warning: Invalid argument supplied for foreach() in /usr/share/php/PEAR/Command.php on line 249

Warning: Invalid argument supplied for foreach() in PEAR/Command.php on line 249

Warning: Invalid argument supplied for foreach() in /usr/share/php/PEAR/Command.php on line 249
XML Extension not found

Last line gives me this message

XML Extension not found

, although I installed #sudo apt-get install php-xml php7.0-xml. But the same problem still occurs.

What could be the problem?

Progressist answered 6/12, 2016 at 16:5 Comment(8)
Also please do show us the code where those errors are on. We cannot guess.Combine
I have encountered this issue recently on my local machine, I think it is related to incompatibilities between hte php7.0 package and php5-pear (I was using the 'dotdeb' repository and had pretty similar problems)Depopulate
@Combine wut? These errors are shown when the OP is issuing pear command from terminal. There is no code involved in the questionDepopulate
@DaGhostmanDimitrov Yes I'm getting this error while using this command : "sudo pecl install redis".Progressist
Yea I overlooked the lines. My bad. I doubt most of the pear libs are updated for php7.Combine
@Combine it is an error with pear itself, also redis extension builds just fine for PHP7 (use it in a deployed docker image) also many(majority of popular ones) of the extensions are compatible with PHP7Depopulate
Also reinstalling pear doesnt work so it has to be a php error I thinkProgressist
Make sure the pear version is 1.10.xPhenomenalism
C
20

On some installations, there is a bug in pecl. Find this line;

exec $PHP -C -n -q $INCARG -d date.timezone=UTC -d output_buffering=1 -d variables_order=EGPCS -d safe_mode=0 -d register_argc_argv="On" $INCDIR/peclcmd.php "$@" 

remove the -n

If you want to script it, try:

sed -i "$ s|\-n||g" /usr/bin/pecl
Concierge answered 2/1, 2017 at 15:10 Comment(4)
Running Ubuntu 16.04 LTS with the same issue. Removed "-n" from pecl file and warnings were fixed. Thank you richp10!Fluter
Thank you... it worked in Ubuntu 16.04.4 with PHP 7.1 (+deb.sury.org).Gredel
Current PHP version: 7.2.16-1+ubuntu18.10.1+deb.sury.org+1. doesn't work for me :(Damico
Thanks. This worked on CentOS Linux release 7.7.1908 (Core)Gona
L
32

Install this list and everything will work fine :)

sudo apt-get install php-pear pkg-config libbson-1.0 libmongoc-1.0-0 php-xml php7.0-xml php-dev
Lighten answered 26/3, 2017 at 22:55 Comment(1)
That is mucho O_oAllegiance
C
20

On some installations, there is a bug in pecl. Find this line;

exec $PHP -C -n -q $INCARG -d date.timezone=UTC -d output_buffering=1 -d variables_order=EGPCS -d safe_mode=0 -d register_argc_argv="On" $INCDIR/peclcmd.php "$@" 

remove the -n

If you want to script it, try:

sed -i "$ s|\-n||g" /usr/bin/pecl
Concierge answered 2/1, 2017 at 15:10 Comment(4)
Running Ubuntu 16.04 LTS with the same issue. Removed "-n" from pecl file and warnings were fixed. Thank you richp10!Fluter
Thank you... it worked in Ubuntu 16.04.4 with PHP 7.1 (+deb.sury.org).Gredel
Current PHP version: 7.2.16-1+ubuntu18.10.1+deb.sury.org+1. doesn't work for me :(Damico
Thanks. This worked on CentOS Linux release 7.7.1908 (Core)Gona
R
16

Was Facing this issue, i just needed to install php-xml

sudo apt-get install php-xml

Credits: Taha EL BOUFFI

Full Explanation as to why can be found here

Rivulet answered 6/3, 2019 at 7:20 Comment(0)
P
0

Note: this is not exactly an answer to the original questions, but this might be more relevant now and in the future.

One of the possible reasons for this kind of error in more modern Ubuntu versions (like 20.04) is the possibility of having more than one version of PHP installed in the system.

Even if you install only 7.x version, and 7.x plugins and f.ex. some HTTP server like Apache it does not mean that there won't be another PHP installed. It might be installed either initially (for example in docker base image) or as a dependency of something else.

I've had such a problem in a legacy docker container which used to build and work before.

The solution was to remove PHP 8.x just before PEAR install.

sudo apt-get purge -y `apt list --installed | cut -d/ -f1 | grep php8 | awk '{print $1}' |tr "\n" " "`

or

sudo apt-get purge -y `dpkg -l | grep php8 | awk '{print $2}' |tr "\n" " "`
Podgorica answered 25/6, 2022 at 12:45 Comment(0)
M
0

There are two ways I have done to fix this error,

1. Try to install php-xml

sudo apt-get install php-xml

If the first method does not solve the problem then try the second method

2. Change the code in the pecl executable file

First find the location of of the pecl executable file,

which pecl

In my case the pecl executable file is located in /usr/bin/pecl. Then replace the exec code at the bottom of the pecl file with the following code

exec $PHP -C -q $INCARG -d date.timezone=UTC -d output_buffering=1 -d variables_order=EGPCS -d safe_mode=0 -d register_argc_argv="On" $INCDIR/peclcmd.php "$@"
Merwin answered 21/6 at 7:22 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.