Opened 4 years ago

Last modified 2 years ago

#37683 new defect

pear-PHPUnit and friends: cmd executables have "/usr/bin/php" shebang

Reported by: zsnakevil@… Owned by: macports-tickets@…
Priority: Normal Milestone:
Component: ports Version: 2.1.2
Keywords: Cc: ryandesign (Ryan Schmidt), 66ton99@…, cooljeanius (Eric Gallager)
Port: pear-PHPUnit

Description

I've installed and activated the port 'php54'.

# port select php
Available versions for php:
	none
	php54 (active)

After installed 'php-pear', I found the PHP binary which used by PEAR is pointed to '/usr/bin/php'.

# pear version
PEAR Version: 1.9.4
PHP Version: 5.3.15
Zend Engine Version: 2.3.0

# cat /opt/local/bin/pear
     1	#!/bin/sh

     2	# first find which PHP binary to use
     3	if test "x$PHP_PEAR_PHP_BIN" != "x"; then
     4	  PHP="$PHP_PEAR_PHP_BIN"
     5	else
     6	  if test "/usr/bin/php" = '@'php_bin'@'; then
     7	    PHP=php
     8	  else
     9	    PHP="/usr/bin/php"
    10	  fi
    11	fi

Installed port 'php54' would not be used until I run PEAR as PHP_PEAR_PHP_BIN=php pear.

# PHP_PEAR_PHP_BIN=php pear version
PEAR Version: 1.9.4
PHP Version: 5.4.10
Zend Engine Version: 2.4.0

Change History (11)

comment:1 follow-up: Changed 4 years ago by pixilla (Bradley Giesbrecht)

I do not think any port installs /opt/local/bin/pear nor does "sudo port select php php54".

port provides /opt/local/bin/pear

In MacPorts, the pear ports have names that start with "pear-".

port echo name:^pear-

If you use MacPorts to manage your pear packages you are advised to not use the pear package manager directly.

Do you have a specific question?

Last edited 4 years ago by pixilla (Bradley Giesbrecht) (previous) (diff)

comment:2 in reply to: ↑ 1 ; follow-up: Changed 4 years ago by zsnakevil@…

Mixed PEAR packages, both from MacPorts and 3rd parties channels, would be used. Such as PHP_CompatInfo, phpDocumentor-alpha (phpdoc2) and PHPUnit (latest v3.7.13, fresher than the port).

In that case, for /usr/bin/php has been used by pear as default, all installed command-line utilities from 3rd parties would continue to use /usr/bin/php! EVEN my active PHP version is the port php54.

Replying to pixilla@…:

I do not think any port installs /opt/local/bin/pear nor does "sudo port select php php54".

port provides /opt/local/bin/pear

In MacPorts, the pear ports have names that start with "pear-".

port echo name:^pear-

If you use MacPorts to manage your pear packages you are advised to not use the pear package manager directly.

Do you have a specific question?

comment:3 Changed 4 years ago by zsnakevil@…

For a temporary solution, I have made an alias 'PHP_PEAR_PHP_BIN="/usr/bin/env php" pear' to resolve this issue.

comment:4 in reply to: ↑ 2 Changed 4 years ago by pixilla (Bradley Giesbrecht)

Replying to zsnakevil@…:

Mixed PEAR packages, both from MacPorts and 3rd parties channels, would be used. Such as PHP_CompatInfo, phpDocumentor-alpha (phpdoc2) and PHPUnit (latest v3.7.13, fresher than the port).

The MacPorts pear ports install packages from many channels, in fact, all the channels I could find when I created all the ports. Here is a list of the channels I used:

$ ls ~/misc/sandbox/pear/pear/
11abacus        crisscott       domain51        ezc             horde           pat             pearplex        phpspec         psx             sc              swift           typo3
agavi           deepend         dotsunited      firephp         indeyets        pdepend         phergie         phpuc           qubit           sikz            symfony         zend
arbit           digitalsandwich element-34      fluentdom       invenzzia       pear            phing           phpunit         querypath       smarty          symfony2        zero.mq
aws             docblox         erebot          funkatron       michelf         pearfarm        phpmd           piece           ragnaroek       solar           timj            zz
complexml       doctrine        eveyron         geometria-lab   openpear        pearhub         phpseclib       pirum           sabredav        sugar           twig

If ports need to be added or updated lets do that.

There is no MacPorts port that installs the pear package manager application with the intent that it be used by the end user outside a MacPorts port install. If you want to use pear manually on your own then you should install it using gopear, composer or some other method. MacPorts pear ports can depend on and be depended on by other ports and for this to work well MacPorts needs to be in control of the installed files and not have the pear command line package manager changing things out from under it's control by user calls to the pear package manager outside MacPorts.

In that case, for /usr/bin/php has been used by pear as default, all installed command-line utilities from 3rd parties would continue to use /usr/bin/php!

If this causes an issue with functionality then it should be fixed. Perhaps these few pear ports should have php version variants or subports. Are these command line ports depended on by other pear packages?

EVEN my active PHP version is the port php54.

The "port select" mechanism is for convenience and I do not believe that any MacPorts ports are supposed to depend on the "active" port as in the port selected by "port select". We will need to make variants or subports for these command line utilities.

Last edited 4 years ago by pixilla (Bradley Giesbrecht) (previous) (diff)

comment:5 Changed 4 years ago by zsnakevil@…

Thx for your reply!

I tried to install PHPUnit by the pear-PHPUnit port, but failed with a forgotten warning message :-( So I have no idea about that what would be written into the binary phpunit through the $PHP_PEAR_PHP_BIN environment variable.

The flow in my opinion is:

  1. $PHP_PEAR_PHP_BIN passes into pear command execution,
  1. or pear tries to detect the value itself,
  1. pear rewrites the first line of the installing binary to "#!" tailing with $PHP_PEAR_PHP_BIN.

The key step as I thought is the second, "/usr/bin/php" was hard coded into the pear binary.

So that was passed and hard coded into the ports binaries on porting?!

comment:6 Changed 4 years ago by pixilla (Bradley Giesbrecht)

  • Cc ryandesign@… added
  • Keywords php-pear bin removed
  • Owner changed from macports-tickets@… to pixilla@…
  • Port pear-* added
  • Priority changed from Low to Normal
  • Summary changed from [php-pear] Would PHP BIN be FORCED to 'php'? to pear-*: cmd executables have "/usr/bin/php" shebang

comment:7 Changed 4 years ago by pixilla (Bradley Giesbrecht)

  • Port pear-PHPUnit added; pear-* removed
  • Summary changed from pear-*: cmd executables have "/usr/bin/php" shebang to pear-PHPUnit and friends: cmd executables have "/usr/bin/php" shebang

comment:8 Changed 3 years ago by miken32 (Michael Newton)

This is a duplicate of ticket #37119?

comment:9 Changed 3 years ago by 66ton99@…

  • Cc 66ton99@… added

Cc Me!

comment:10 Changed 3 years ago by cooljeanius (Eric Gallager)

  • Cc egall@… added

Cc Me!

comment:11 Changed 2 years ago by mf2k (Frank Schima)

  • Owner changed from pixilla@… to macports-tickets@…

This port no longer has a maintainer.

Note: See TracTickets for help on using tickets.