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

26,312

Solution 1

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

Solution 2

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

Solution 3

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

Share:
26,312
Towen
Author by

Towen

Updated on March 06, 2020

Comments

  • Towen
    Towen about 4 years

    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?

    • vuryss
      vuryss over 7 years
      Also please do show us the code where those errors are on. We cannot guess.
    • DaGhostman Dimitrov
      DaGhostman Dimitrov over 7 years
      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)
    • DaGhostman Dimitrov
      DaGhostman Dimitrov over 7 years
      @vuryss wut? These errors are shown when the OP is issuing pear command from terminal. There is no code involved in the question
    • Towen
      Towen over 7 years
      @DaGhostmanDimitrov Yes I'm getting this error while using this command : "sudo pecl install redis".
    • vuryss
      vuryss over 7 years
      Yea I overlooked the lines. My bad. I doubt most of the pear libs are updated for php7.
    • DaGhostman Dimitrov
      DaGhostman Dimitrov over 7 years
      @vuryss 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 PHP7
    • Towen
      Towen over 7 years
      Also reinstalling pear doesnt work so it has to be a php error I think
    • cweiske
      cweiske over 7 years
      Make sure the pear version is 1.10.x
  • Chris
    Chris almost 7 years
    Running Ubuntu 16.04 LTS with the same issue. Removed "-n" from pecl file and warnings were fixed. Thank you richp10!
  • leymannx
    leymannx over 6 years
    That is mucho O_o
  • EthraZa
    EthraZa almost 6 years
    Thank you... it worked in Ubuntu 16.04.4 with PHP 7.1 (+deb.sury.org).
  • Jackie
    Jackie about 5 years
    Current PHP version: 7.2.16-1+ubuntu18.10.1+deb.sury.org+1. doesn't work for me :(
  • raghu777
    raghu777 about 4 years
    Thanks. This worked on CentOS Linux release 7.7.1908 (Core)