Search code examples
phplinuxinstallationphpunitpear

PHPUnit being installed to the wrong directory


I recently installed PHPUnit using the pear package installer as directed in the documentation. Pear is currently installed in /usr/local/lib/php/pear. However, PHPUnit seems to be installing itself into /usr/share/pear and therefore I get include errors when I try to run phpunit --version or phpunit --help.

I see three possible solutions, but I am afraid of running into problems later on if I choose the wrong one. Here are the possible solutions: (A) move the PHPUnit directory from /usr/share/pear/PHPUnit to /usr/local/lib/php/pear/PHPUnit, (B) move the PHPUnit directory to /usr/local/lib/php/pear/share/pear/PHPUnit, or (C) reinstall phpunit using some extra command or switch, to get it to install to the proper location?

Thanks in advance for your help.

UPDATE: Here is the output of pear config-show when run under my username:

Configuration (channel pear.php.net):
=====================================
Auto-discover new Channels     auto_discover    1
Default Channel                default_channel  pear.php.net
HTTP Proxy Server Address      http_proxy       <not set>
PEAR server [DEPRECATED]       master_server    pear.php.net
Default Channel Mirror         preferred_mirror pear.php.net
Remote Configuration File      remote_config    <not set>
PEAR executables directory     bin_dir          /usr/bin
PEAR documentation directory   doc_dir          /usr/local/lib/php/pear/docs
PHP extension directory        ext_dir          /usr/lib64/php/modules
PEAR directory                 php_dir          /usr/local/lib/php
PEAR Installer cache directory cache_dir        /tmp/pear/cache
PEAR configuration file        cfg_dir          /usr/share/pear/cfg
directory
PEAR data directory            data_dir         /usr/local/lib/php/pear/data
PEAR Installer download        download_dir     /tmp/pear/download
directory
PHP CLI/CGI binary             php_bin          /usr/bin/php
php.ini location               php_ini          <not set>
--program-prefix passed to     php_prefix       <not set>
PHP's ./configure
--program-suffix passed to     php_suffix       <not set>
PHP's ./configure
PEAR Installer temp directory  temp_dir         /tmp/pear/temp
PEAR test directory            test_dir         /usr/local/lib/php/pear/tests
PEAR www files directory       www_dir          /usr/share/pear/www
Cache TimeToLive               cache_ttl        3600
Preferred Package State        preferred_state  stable
Unix file mask                 umask            27
Debug Log Level                verbose          1
PEAR password (for             password         <not set>
maintainers)
Signature Handling Program     sig_bin          /usr/bin/gpg
Signature Key Directory        sig_keydir       /etc/pearkeys
Signature Key Id               sig_keyid        <not set>
Package Signature Type         sig_type         gpg
PEAR username (for             username         <not set>
maintainers)
User Configuration File        Filename         /home/webdeveloper/.pearrc
System Configuration File      Filename         /etc/pear.conf

And here is the output of pear config-show when run as root:

Configuration (channel pear.php.net):
=====================================
Auto-discover new Channels     auto_discover    1
Default Channel                default_channel  pear.php.net
HTTP Proxy Server Address      http_proxy       <not set>
PEAR server [DEPRECATED]       master_server    pear.php.net
Default Channel Mirror         preferred_mirror pear.php.net
Remote Configuration File      remote_config    <not set>
PEAR executables directory     bin_dir          /usr/bin
PEAR documentation directory   doc_dir          /usr/share/pear/docs
PHP extension directory        ext_dir          /usr/lib64/php/modules
PEAR directory                 php_dir          /usr/share/pear
PEAR Installer cache directory cache_dir        /tmp/pear/cache
PEAR configuration file        cfg_dir          /usr/share/pear/cfg
directory
PEAR data directory            data_dir         /usr/share/pear/data
PEAR Installer download        download_dir     /tmp/pear/download
directory
PHP CLI/CGI binary             php_bin          /usr/bin/php
php.ini location               php_ini          <not set>
--program-prefix passed to     php_prefix       <not set>
PHP's ./configure
--program-suffix passed to     php_suffix       <not set>
PHP's ./configure
PEAR Installer temp directory  temp_dir         /tmp/pear/temp
PEAR test directory            test_dir         /usr/share/pear/tests
PEAR www files directory       www_dir          /usr/share/pear/www
Cache TimeToLive               cache_ttl        3600
Preferred Package State        preferred_state  stable
Unix file mask                 umask            22
Debug Log Level                verbose          1
PEAR password (for             password         <not set>
maintainers)
Signature Handling Program     sig_bin          /usr/bin/gpg
Signature Key Directory        sig_keydir       /etc/pearkeys
Signature Key Id               sig_keyid        <not set>
Package Signature Type         sig_type         gpg
PEAR username (for             username         <not set>
maintainers)
User Configuration File        Filename         /root/.pearrc
System Configuration File      Filename         /etc/pear.conf

Solution

  • All right, seems we have found the issue (see the comments).

    I would assume PHPUnit was installed as root or pear is for some reason picking up the "roots" config dir.

    The path where the code is put is defined in:

     PEAR directory  php_dir /usr/share/pear
    

    So something in the pear config seems to be the issue.

    If possible I'd pear config-set php_dir $yourLocation and see if it works out then.


    It is possible to install multiple versions of PHPUnit using pear install --installroot /some/path/ like described in the post. So that should work out no matter what.