Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Composer doesn't see all installed PHP extensions #5749

Closed
mnabialek opened this issue Oct 3, 2016 · 19 comments
Closed

Composer doesn't see all installed PHP extensions #5749

mnabialek opened this issue Oct 3, 2016 · 19 comments
Labels

Comments

@mnabialek
Copy link

I'm using Docker and have installed GD in recommended way as showed in official PHP Docker repository. My Dockerfile looks like this:

When I run:

php -m

I'm getting:

[PHP Modules]
Core
ctype
curl
date
dom
ereg
fileinfo
filter
ftp
gd
hash
iconv
json
libxml
mbstring
mysqlnd
openssl
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
posix
readline
Reflection
session
SimpleXML
SPL
sqlite3
standard
tokenizer
xdebug
xml
xmlreader
xmlwriter
zlib

[Zend Modules]
Xdebug

but when running composer show -p I'm getting:

ext-ctype           0        The ctype PHP extension (actual version: )
ext-curl            0        The curl PHP extension (actual version: )
ext-date            5.6.25   The date PHP extension
ext-dom             20031129 The dom PHP extension
ext-ereg            0        The ereg PHP extension (actual version: )
ext-fileinfo        1.0.5    The fileinfo PHP extension
ext-filter          0.11.0   The filter PHP extension
ext-ftp             0        The ftp PHP extension (actual version: )
ext-hash            1.0      The hash PHP extension
ext-iconv           0        The iconv PHP extension (actual version: )
ext-json            1.2.1    The json PHP extension
ext-libxml          0        The libxml PHP extension (actual version: )
ext-mbstring        0        The mbstring PHP extension (actual version: )
ext-mysqlnd         0        The mysqlnd PHP extension (actual version: mysqlnd 5.0.11-dev - 20120503 - $Id: 76b08b24596e12d4553bd41fc93cccd5bac2fe7a $)
ext-openssl         0        The openssl PHP extension (actual version: )
ext-pcre            0        The pcre PHP extension (actual version: )
ext-PDO             1.0.4dev The PDO PHP extension
ext-pdo_sqlite      1.0.1    The pdo_sqlite PHP extension
ext-Phar            2.0.2    The Phar PHP extension
ext-posix           0        The posix PHP extension (actual version: )
ext-readline        5.6.25   The readline PHP extension
ext-Reflection      0        The Reflection PHP extension (actual version: $Id: 5f15287237d5f78d75b19c26915aa7bd83dee8b8 $)
ext-session         0        The session PHP extension (actual version: )
ext-SimpleXML       0.1      The SimpleXML PHP extension
ext-SPL             0.2      The SPL PHP extension
ext-sqlite3         0.7-dev  The sqlite3 PHP extension
ext-tokenizer       0.1      The tokenizer PHP extension
ext-xml             0        The xml PHP extension (actual version: )
ext-xmlreader       0.1      The xmlreader PHP extension
ext-xmlwriter       0.1      The xmlwriter PHP extension
ext-zlib            2.0      The zlib PHP extension
lib-curl            7.38.0   The curl PHP library
lib-iconv           2.19     The iconv PHP library
lib-libxml          2.9.1    The libxml PHP library
lib-openssl         1.0.1.20 OpenSSL 1.0.1t  3 May 2016
lib-pcre            8.38     The pcre PHP library
php                 5.6.25   The PHP interpreter
php-64bit           5.6.25   The PHP interpreter, 64bit
php-ipv6            5.6.25   The PHP interpreter with IPv6 support

There's no GD here, so when I try to install for example barryvdh/laravel-dompdf I'm getting following error:

Problem 1
    - dompdf/dompdf v0.7.0 requires ext-gd * -> the requested PHP extension gd is missing from your system.
    - dompdf/dompdf v0.7.0 requires ext-gd * -> the requested PHP extension gd is missing from your system.
    - dompdf/dompdf v0.7.0 requires ext-gd * -> the requested PHP extension gd is missing from your system.
    - Installation request for dompdf/dompdf (locked at v0.7.0) -> satisfiable by dompdf/dompdf[v0.7.0].

The only way to install it is using --ignore-platform-reqs parameter but I need to use it each time and obviously it doesn't solve issue when my virtual machine misses some libs that are required and not installed.

Also when I run:

php -r 'print_r(get_loaded_extensions()); foreach (get_loaded_extensions() as $ext) echo $ext." ".phpversion($ext)."\n";'

in console I'm getting something like this:

Array
(
    [0] => Core
    [1] => date
    [2] => ereg
    [3] => libxml
    [4] => openssl
    [5] => pcre
    [6] => sqlite3
    [7] => zlib
    [8] => ctype
    [9] => curl
    [10] => dom
    [11] => fileinfo
    [12] => filter
    [13] => ftp
    [14] => hash
    [15] => iconv
    [16] => json
    [17] => mbstring
    [18] => SPL
    [19] => PDO
    [20] => session
    [21] => posix
    [22] => readline
    [23] => Reflection
    [24] => standard
    [25] => SimpleXML
    [26] => pdo_sqlite
    [27] => Phar
    [28] => tokenizer
    [29] => xml
    [30] => xmlreader
    [31] => xmlwriter
    [32] => mysqlnd
    [33] => gd
    [34] => pdo_mysql
    [35] => xdebug
)
Core 5.6.25
date 5.6.25
ereg
libxml
openssl
pcre
sqlite3 0.7-dev
zlib 2.0
ctype
curl
dom 20031129
fileinfo 1.0.5
filter 0.11.0
ftp
hash 1.0
iconv
json 1.2.1
mbstring
SPL 0.2
PDO 1.0.4dev
session
posix
readline 5.6.25
Reflection $Id: 5f15287237d5f78d75b19c26915aa7bd83dee8b8 $
standard 5.6.25
SimpleXML 0.1
pdo_sqlite 1.0.1
Phar 2.0.2
tokenizer 0.1
xml
xmlreader 0.1
xmlwriter 0.1
mysqlnd mysqlnd 5.0.11-dev - 20120503 - $Id: 76b08b24596e12d4553bd41fc93cccd5bac2fe7a $
gd
pdo_mysql 1.0.2
xdebug 2.4.1

For some extensions version is missing but for example for ctype it's missing but it's available in output of composer show -p and gd is not there at all.

I've already seen https://github.com/composer/composer/issues/4353 but it's not solving the issue. The question is - what's the reason that composer doesn't see GD extension? What's the way composer finds what extensions are available in system? Or maybe official way of installing GD is broken and it should be installed somehow else?

The strange thing is that GD is working without a problem after such installation, the only issue is that Composer doesn't see it.

I'm using Composer version 1.2.1 2016-09-12 11:27:19

@alcohol
Copy link
Member

alcohol commented Oct 3, 2016

Can you share some more about your docker setup? Does everything use the same container?

@alcohol alcohol added the Support label Oct 3, 2016
@mnabialek
Copy link
Author

No, I'm using 3 containers - one for PHP, one for webserver and one for database. My docker-compose looks like this and I'm using for the whole setup the code I've put on github. The same problem is for both PHP 5.6 installation and for PHP 7.

@alcohol
Copy link
Member

alcohol commented Oct 3, 2016

I think you are using the image that extends ubuntu stuff. It could be their fpm image has a separate php ini for fpm and cli. Did you try running php --ini ?

@mnabialek
Copy link
Author

When I run php --ini I'm getting:

Configuration File (php.ini) Path: /usr/local/etc/php
Loaded Configuration File:         /usr/local/etc/php/php.ini
Scan for additional .ini files in: /usr/local/etc/php/conf.d
Additional .ini files parsed:      /usr/local/etc/php/conf.d/20-gd.ini,
/usr/local/etc/php/conf.d/20-pdo_mysql.ini,
/usr/local/etc/php/conf.d/20-xdebug.ini

Content of /usr/local/etc/php/php.ini is:

max_execution_time = 180
memory_limit = 1024M
upload_max_filesize = 40M
post_max_size = 40M

and content of /usr/local/etc/php/conf.d/20-gd.ini is:

; configuration for php gd module
; priority=20
extension=gd.so

@alcohol
Copy link
Member

alcohol commented Oct 3, 2016

Can you show me how you run the command + output, both for php -m and composer show -p ?

@mnabialek
Copy link
Author

Exactly like this (I login via putty to PHP container) and:

root@somesite.app:/usr/share/nginx/html$php -m
[PHP Modules]
Core
ctype
curl
date
dom
ereg
fileinfo
filter
ftp
gd
hash
iconv
json
libxml
mbstring
mysqlnd
openssl
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
posix
readline
Reflection
session
SimpleXML
SPL
sqlite3
standard
tokenizer
xdebug
xml
xmlreader
xmlwriter
zlib

[Zend Modules]
Xdebug

root@somesite.app:/usr/share/nginx/html$composer show -p
composer-plugin-api 1.1.0    The Composer Plugin API
ext-ctype           0        The ctype PHP extension (actual version: )
ext-curl            0        The curl PHP extension (actual version: )
ext-date            5.6.25   The date PHP extension
ext-dom             20031129 The dom PHP extension
ext-ereg            0        The ereg PHP extension (actual version: )
ext-fileinfo        1.0.5    The fileinfo PHP extension
ext-filter          0.11.0   The filter PHP extension
ext-ftp             0        The ftp PHP extension (actual version: )
ext-hash            1.0      The hash PHP extension
ext-iconv           0        The iconv PHP extension (actual version: )
ext-json            1.2.1    The json PHP extension
ext-libxml          0        The libxml PHP extension (actual version: )
ext-mbstring        0        The mbstring PHP extension (actual version: )
ext-mysqlnd         0        The mysqlnd PHP extension (actual version: mysqlnd 5.0.11-dev - 20120503 - $Id: 76b08b24596e12d4553bd41fc93cccd5bac2fe7a $)
ext-openssl         0        The openssl PHP extension (actual version: )
ext-pcre            0        The pcre PHP extension (actual version: )
ext-PDO             1.0.4dev The PDO PHP extension
ext-pdo_sqlite      1.0.1    The pdo_sqlite PHP extension
ext-Phar            2.0.2    The Phar PHP extension
ext-posix           0        The posix PHP extension (actual version: )
ext-readline        5.6.25   The readline PHP extension
ext-Reflection      0        The Reflection PHP extension (actual version: $Id: 5f15287237d5f78d75b19c26915aa7bd83dee8b8 $)
ext-session         0        The session PHP extension (actual version: )
ext-SimpleXML       0.1      The SimpleXML PHP extension
ext-SPL             0.2      The SPL PHP extension
ext-sqlite3         0.7-dev  The sqlite3 PHP extension
ext-tokenizer       0.1      The tokenizer PHP extension
ext-xml             0        The xml PHP extension (actual version: )
ext-xmlreader       0.1      The xmlreader PHP extension
ext-xmlwriter       0.1      The xmlwriter PHP extension
ext-zlib            2.0      The zlib PHP extension
lib-curl            7.38.0   The curl PHP library
lib-iconv           2.19     The iconv PHP library
lib-libxml          2.9.1    The libxml PHP library
lib-openssl         1.0.1.20 OpenSSL 1.0.1t  3 May 2016
lib-pcre            8.38     The pcre PHP library
php                 5.6.25   The PHP interpreter
php-64bit           5.6.25   The PHP interpreter, 64bit
php-ipv6            5.6.25   The PHP interpreter with IPv6 support

If you need any more details, please tell me what commands should I type :)

@mnabialek
Copy link
Author

Just in case when I run php -i the part about GD looks like this:

ftp

FTP support => enabled

gd

GD Support => enabled
GD Version => bundled (2.1.0 compatible)
FreeType Support => enabled
FreeType Linkage => with freetype
FreeType Version => 2.5.2
GIF Read Support => enabled
GIF Create Support => enabled
JPEG Support => enabled
libJPEG Version => 6b
PNG Support => enabled
libPNG Version => 1.2.50
WBMP Support => enabled
XBM Support => enabled

Directive => Local Value => Master Value
gd.jpeg_ignore_warning => 0 => 0

hash

@alcohol
Copy link
Member

alcohol commented Oct 4, 2016

Can you run and share the output of

composer show -p
cat /tmp/*-php.ini

# replace <part> with the partial filename of the only file ending with -php.ini inside /tmp
php -c /tmp/<part>-php.ini -m

@stof
Copy link
Contributor

stof commented Oct 4, 2016

Can you past the output of this command too ?

php -r "echo (new ReflectionExtension('gd'))->getVersion();"

@mnabialek
Copy link
Author

@alcohol I don't have any .ini files in /tmp directory, I have ini files only in directories I showed yesterday:

$php --ini
Configuration File (php.ini) Path: /usr/local/etc/php
Loaded Configuration File:         /usr/local/etc/php/php.ini
Scan for additional .ini files in: /usr/local/etc/php/conf.d
Additional .ini files parsed:      /usr/local/etc/php/conf.d/20-gd.ini,
/usr/local/etc/php/conf.d/20-pdo_mysql.ini,
/usr/local/etc/php/conf.d/20-xdebug.ini

@stof The result of command is as below:

root@somesite.app:/usr/share/nginx/html$php -r "echo (new ReflectionExtension('gd'))->getVersion();"
root@somesite.app:/usr/share/nginx/html$

@mnabialek
Copy link
Author

@alcohol Any update on this?

@alcohol
Copy link
Member

alcohol commented Oct 28, 2016

I have no way to reproduce this, so, no.

But I can say with high confidence that this is probably related with the way you've setup your docker images. Also, the output of that php -r command shows that gd was not available in that container.

@maryo
Copy link

maryo commented Dec 1, 2016

I have the same problem on Windows. I've recently added 3 extension dependencies to composer.json primarily because of APCu.

It works fine on Linux dockerized CI server though.
php -m contains on my Windows machine:

fileinfo
gd
apcu
...

composer show -p does not and composer update complains:

Your requirements could not be resolved to an installable set of packages.
  Problem 1
    - The requested PHP extension ext-gd * is missing from your system. Install or enable PHP's gd extension.
  Problem 2
    - The requested PHP extension ext-fileinfo * is missing from your system. Install or enable PHP's fileinfo extension.
  Problem 3
    - The requested PHP extension ext-apcu * is missing from your system. Install or enable PHP's apcu extension.
php -r "echo (new ReflectionExtension('gd'))->getVersion();"
7.0.6

@alcohol
Copy link
Member

alcohol commented Dec 1, 2016

@maryo unless you show us the full output of the following commands run on your windows local host, we cannot help you:

php --version
php -m
composer show --platform

Please also include the lines that show how you run the command and in what directory you run the command. Do not hide anything that you might think is irrelevant, because it most likely is relevant.

@maryo
Copy link

maryo commented Dec 1, 2016

@RobLoach Sorry for taking your time. My fault. I forgot I created a batch file running composer with only some extensions enabled because of xdebug few years ago. How silly.
@php -n -d extension=ext\php_openssl.dll -d extension=ext\php_mbstring.dll -d extension=ext\php_curl.dll "%~dp0composer.phar" %*

@alcohol alcohol closed this as completed Dec 1, 2016
@mnabialek
Copy link
Author

@alcohol @maryo I had exact same problem. I've created alias like this:

alias composer="php -n /usr/local/bin/composer"

to not load Xdebug (but obviously all other extensions) and that's why Composer didn't see GD2 extension when installing packages.

Sorry for reporting. It was obviously not Composer fault but mine.

@Seldaek
Copy link
Member

Seldaek commented Feb 17, 2017

Note that latest composer (1.3+) disables xdebug automatically so you don't need to do such hacks like running it via php -n anymore.

@mnabialek
Copy link
Author

@Seldaek Didn't know about it. Thanks for sharing

@david-cefr
Copy link

In case this could help :

I ran into the same issue, I was running PHP locally with GD and composer thru a docker container.
the command composer show -p would not show "ext-gd".

To solve the problem, I've installed Composer locally and now it runs fine.
Another solution would've been to install GD on the Composer container.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants