mongodb / mongo-php-driver

The Official MongoDB PHP driver
https://pecl.php.net/package/mongodb
Apache License 2.0
889 stars 204 forks source link

Can't install with pickle #562

Closed rageshkrishna closed 7 years ago

rageshkrishna commented 7 years ago

Description

Running pickle install mongodb results in the following error:

root@00b966884cbc:~# pickle install mongodb
  - Installing mongodb (latest-stable): Downloading (100%)

  [Exception]
  Couldn't parse the version defined in the PHP_MONGODB_VERSION macro

install [--no-convert] [--defaults] [--source] [--with-configure-options WITH-CONFIGURE-OPTIONS] [--save-logs SAVE-LOGS] [--dry-run] [--php PHP] [--ini INI] [--tmp-dir TMP-DIR] [--] [<path>]

I suspect pickle is looking for PHP_MONGODB_VERSION but mongo-php-driver doesn't define it anywhere. To be honest, I'm not sure if this is a bug in mongo-php-driver or in pickle, but it looks like pickle is able to find it on several other extensions I am installing so is it some sort of standard approach that is not adopted by mongo-php-driver?

Environment

Ubuntu 16.04 docker container, PHP 7.1 installed with php-build and managed with phpenv.

Test Script

Fails on install with the command above. No other test script,

Expected and Actual Behavior

Expected the extension to be installed, but it did not.

jmikola commented 7 years ago

PHP_EXTNAME_VERSION is included PHP's skeleton header for extensions. I don't recall if we used that when creating this extension, but this is easy to address. I've opened PHPC-936 to add the missing macro.


@weltling, @pierrejoye: I believe the PHP_EXTNAME_VERSION convention dates back to https://github.com/php/php-src/commit/dcfd753104085d8337b8a5f4a21ce3b629ad4651, but can you explain why Pickle needs to derive a version from extension headers? I realize you need the version before building the extension, so phpversion('extname') is not an option, but Composer pulls version info from Git tags. Since you support both Git and HTTP sources (I assume that means PECL's index), wouldn't you simply pull version info from tags and PECL's database, respectively?

pierrejoye commented 7 years ago

Extension version in header is a norm. Used in phpinfo() or in extension versions constants.

We added this check to avoid releases without it.

On Mar 17, 2017 11:43 PM, "Jeremy Mikola" notifications@github.com wrote:

PHP_EXTNAME_VERSION is included PHP's skeleton header for extensions https://github.com/php/php-src/blob/php-7.1.3/ext/skeleton/php_skeleton.h#L9. I don't recall if we used that when creating this extension, but this is easy to address. I've opened PHPC-936 https://jira.mongodb.org/browse/PHPC-936 to add the missing macro.

@weltling https://github.com/weltling, @pierrejoye https://github.com/pierrejoye: I believe the PHP_EXTNAME_VERSION convention dates back to php/php-src@dcfd753 https://github.com/php/php-src/commit/dcfd753104085d8337b8a5f4a21ce3b629ad4651, but can you explain why Pickle needs to derive a version from extension headers? I realize you need the version before building the extension, so phpversion('extname') is not an option, but Composer pulls version info from Git tags. Since you support both Git and HTTP sources (I assume that means PECL's index), wouldn't you simply pull version info from tags and PECL's database, respectively?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/mongodb/mongo-php-driver/issues/562#issuecomment-287407326, or mute the thread https://github.com/notifications/unsubscribe-auth/AARPKGLrLWK6ka0m_eScC9n29OfgX4Crks5rmrgjgaJpZM4MgQmw .

pierrejoye commented 7 years ago

On top of it we make sure header matches with desired versions.

On Mar 17, 2017 11:49 PM, "Pierre Joye" pierre.php@gmail.com wrote:

Extension version in header is a norm. Used in phpinfo() or in extension versions constants.

We added this check to avoid releases without it.

On Mar 17, 2017 11:43 PM, "Jeremy Mikola" notifications@github.com wrote:

PHP_EXTNAME_VERSION is included PHP's skeleton header for extensions https://github.com/php/php-src/blob/php-7.1.3/ext/skeleton/php_skeleton.h#L9. I don't recall if we used that when creating this extension, but this is easy to address. I've opened PHPC-936 https://jira.mongodb.org/browse/PHPC-936 to add the missing macro.

@weltling https://github.com/weltling, @pierrejoye https://github.com/pierrejoye: I believe the PHP_EXTNAME_VERSION convention dates back to php/php-src@dcfd753 https://github.com/php/php-src/commit/dcfd753104085d8337b8a5f4a21ce3b629ad4651, but can you explain why Pickle needs to derive a version from extension headers? I realize you need the version before building the extension, so phpversion('extname') is not an option, but Composer pulls version info from Git tags. Since you support both Git and HTTP sources (I assume that means PECL's index), wouldn't you simply pull version info from tags and PECL's database, respectively?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/mongodb/mongo-php-driver/issues/562#issuecomment-287407326, or mute the thread https://github.com/notifications/unsubscribe-auth/AARPKGLrLWK6ka0m_eScC9n29OfgX4Crks5rmrgjgaJpZM4MgQmw .

jmikola commented 7 years ago

@pierrejoye: Thanks for the quick reply.

@rageshkrishna: 1.2.8 has been released with the change, so I will close this.

I attempted to install the extension using pickle install mongodb and there appears to be a configure error emanating from PHP_SETUP_OPENSSL() on my system. The headers are not being found as they normally are through a pecl install. I'm unsure if this is just specific to my OS environment or a widespread issue, but it's beyond the scope of PHPC-936 so please open a new issue if problems persist for you. Unfortunately, I'm not sure how to attempt installation with pickle before creating the PECL release, so I was unable to catch this before the release.

pierrejoye commented 7 years ago

On Tue, Mar 21, 2017 at 1:01 AM, Jeremy Mikola notifications@github.com wrote:

@pierrejoye https://github.com/pierrejoye: Thanks for the quick reply.

@rageshkrishna https://github.com/rageshkrishna: 1.2.8 https://github.com/mongodb/mongo-php-driver/releases/tag/1.2.8 has been released with the change, so I will close this.

I attempted to install the extension using pickle install mongodb and there appears to be a configure error emanating from PHP_SETUP_OPENSSL() https://github.com/php/php-src/blob/php-7.1.3/acinclude.m4#L2313 on my system. The headers are not being found as they normally are through a pecl install. I'm unsure if this is just specific to my OS environment or a widespread issue, but it's beyond the scope of PHPC-936 https://jira.mongodb.org/browse/PHPC-936 so please open a new issue if problems persist for you. Unfortunately, I'm not sure how to attempt installation with pickle before creating the PECL release, so I was unable to catch this before the release.

Either specify the git repo and branch/tag or runs it from the src root directory, that should do it :)

-- Pierre

@pierrejoye | http://www.libgd.org

rageshkrishna commented 7 years ago

This got me around the OpenSSL error:

echo "--with-openssl-dir=yes" >> opts
pickle install --with-configure-options=opts mongodb

Thanks for the help @jmikola @pierrejoye!

derickr commented 7 years ago

@rageshkrishna — that sounds like a bug (in pickle), as --with-openssl-dir by default is set to true, and it uses --without-openssl-dir when you use the -n flag to pickle:

derick@singlemalt:/tmp/pickle $ bin/pickle -n install mongodb
  - Installing mongodb (latest-stable): Downloading (100%)         
+-----------------------------------+---------+
| Package name                      | mongodb |
| Package version (current release) | 1.2.8   |
| Package status                    | stable  |
+-----------------------------------+---------+
The following error(s) happened: configure failed, see log at /tmp/pickle-42ad7f47688e6bdf7b6c6cf9875adf308065564b\config.log
1: phpize
2: Configuring for:
2: PHP Api Version:         20160303
2: Zend Module Api No:      20160303
2: Zend Extension Api No:   320160303
1: /tmp/mongodb/mongodb-1.2.8/configure --enable-mongodb=shared  --without-openssl-dir --without-system-ciphers --without-libbson --without-libmongoc --without-mongodb-sasl
2: checking for grep that handles long lines and -e... /bin/grep
2: checking for egrep... /bin/grep -E
2: checking for a sed that does not truncate output... /bin/sed
2: checking for cc... cc
2: checking whether the C compiler works... yes
2: checking for C compiler default output file name... a.out
2: checking for suffix of executables...
2: checking whether we are cross compiling... no
2: checking for suffix of object files... o
2: checking whether we are using the GNU C compiler... yes
2: checking whether cc accepts -g... yes
2: checking for cc option to accept ISO C89... none needed
2: checking how to run the C preprocessor... cc -E
2: checking for icc... no
2: checking for suncc... no
2: checking whether cc understands -c and -o together... yes
2: checking for system library directory... lib
2: checking if compiler supports -R... no
2: checking if compiler supports -Wl,-rpath,... yes
2: checking build system type... x86_64-unknown-linux-gnu
2: checking host system type... x86_64-unknown-linux-gnu
2: checking target system type... x86_64-unknown-linux-gnu
2: checking for PHP prefix... /usr/local/php/7.1dev
2: checking for PHP includes... -I/usr/local/php/7.1dev/include/php -I/usr/local/php/7.1dev/include/php/main -I/usr/local/php/7.1dev/include/php/TSRM -I/usr/local/php/7.1dev/include/php/Zend -I/usr/local/php/7.1dev/include/php/ext -I/usr/local/php/7.1dev/include/php/ext/date/lib
2: checking for PHP extension directory... /usr/local/php/7.1dev/lib/php/extensions/debug-non-zts-20160303
2: checking for PHP installed headers prefix... /usr/local/php/7.1dev/include/php
2: checking if debug is enabled... yes
2: checking if zts is enabled... no
2: checking for re2c... re2c
2: checking for re2c version... 0.16 (ok)
2: checking for gawk... gawk
2: checking whether to enable mongodb support... yes, shared
2: checking OpenSSL dir for mongodb... no
2: checking whether to use system default cipher list instead of hardcoded value... no
2: checking PHP version... 70104
2: checking whether to enable developer build flags... no
2: checking whether to enable code coverage... no
2: checking whether to use system libbson... no
2: checking whether to use system libmongoc... no
2: checking configuring libmongoc... ...
2: checking for pkg-config... /usr/bin/pkg-config
2: configure: error: Cannot find OpenSSL's <evp.h>
derickr commented 7 years ago

I filed a ticket for pickle: https://github.com/FriendsOfPHP/pickle/issues/152

rageshkrishna commented 7 years ago

@derickr You're right, I get the evp.h error if I just do pickle install mongodb and accept the defaults on all the prompts. It works fine only if I specifically say yes when it asks for OpenSSL dir for mongodb (default: ):.

Thanks for opening the issue on pickle.

allella commented 7 years ago

@derickr Is there any interest in promoting a forthcoming yum installable PECL package for CentOS / RHEL 7?

The folks at IUS are rolling out php71u-pecl-mongodb to go along with many of the other PHP and PECL packages they support.

I figured I'd ask on this somewhat related thread rather than open a new issue for the sake of getting someone's guidance if if this is a good or bad idea.

Thanks

derickr commented 7 years ago

Hi @allella , there has been a YUM installable package for a long time, made by @remicollet for the Fedora (and related) projects: http://pkgs.fedoraproject.org/cgit/rpms/php-pecl-mongodb.git/

remicollet commented 7 years ago

The php-pecl-mongodb package in EPEL is design to work with default PHP in base system.

Official RH answer to provide newer PHP versions is Software Collections which are also available for CentOS users => https://wiki.centos.org/AdditionalResources/Repositories/SCL

Additional packages maintained by community (the CentOS SCLo SIG) includes the sclo-php-pecl-mongodb package (planed to be rebase to 1.2.x with RHSCL next version) => https://blog.remirepo.net/post/2017/02/23/Additional-PHP-packages-for-RHSCL

@allella I don't think promoting alternative 3rd party repository make sense, especially when tons exists: ius, remi, webtatic... (and especially IUS which only provide a very minimal set of extensions, just pulling their sources from another repository...)

allella commented 7 years ago

@remicollet Alright. I had noticed EPEL was showing php-pecl-mongodb-1.1.10-1.el7.x86_64.rpm which is why I asking IUS to create a 1.2 version. Also, because we're using PHP 7.1.

I'll read more about the SCLo.

Thanks

carlwgeorge commented 7 years ago

@allella Check out https://www.hogarthuk.com/?q=node/15 and https://ius.io/IUSvsSCL/ for some SCL comparisons.