I'm just trying devbox out and following the PHP sample from the documentation I made this devbox.json:
{
"packages": [
"php",
"php81Packages.composer",
"php81Extensions.imagick"
],
"shell": {
"init_hook": null
},
"nixpkgs": {
"commit": "52e3e80afff4b16ccb7c52e9f0f5220552f03d04"
}
}
When running composer install
I get this output:
Installing dependencies from lock file (including require-dev)
Verifying lock file contents can be installed on current platform.
Your lock file does not contain a compatible set of packages. Please run composer update.
Problem 1
- Root composer.json requires PHP extension ext-imagick * but it is missing from your system. Install or enable PHP's imagick extension.
To enable extensions, verify that they are enabled in your .ini files:
- /nix/store/4l6iwxd26lpavkld9xpz7hb46swl1xsq-php-with-extensions-8.1.13/lib/php.ini
You can also run `php --ini` in a terminal to see which files are used by PHP in CLI mode.
Alternatively, you can run Composer with `--ignore-platform-req=ext-imagick` to temporarily ignore these required extensions.
It seems that composer uses /nix/store/4l6iwxd26lpavkld9xpz7hb46swl1xsq-php-with-extensions-8.1.13
as its php instance. When I run php -i | grep imagick
the output is
imagick
imagick module => enabled
imagick module version => 3.7.0
imagick classes => Imagick, ImagickDraw, ImagickPixel, ImagickPixelIterator, ImagickKernel
imagick.allow_zero_dimension_images => 0 => 0
imagick.locale_fix => 0 => 0
imagick.progress_monitor => 0 => 0
imagick.set_single_thread => 1 => 1
imagick.shutdown_sleep_count => 10 => 10
imagick.skip_version_check => 0 => 0
nativeBuildInputs => /nix/store/5qwh70a0l0kw604g7kaj184mjrlia8jn-php-with-extensions-8.1.13 /nix/store/994rivc1y4xczq2n6phiqxy2g3z0g7gi-php-composer-2.4.4 /nix/store/8r41k2w2day19l80jvnlvdhrzpygblvx-php-imagick-3.7.0
$_SERVER['nativeBuildInputs'] => /nix/store/5qwh70a0l0kw604g7kaj184mjrlia8jn-php-with-extensions-8.1.13 /nix/store/994rivc1y4xczq2n6phiqxy2g3z0g7gi-php-composer-2.4.4 /nix/store/8r41k2w2day19l80jvnlvdhrzpygblvx-php-imagick-3.7.0
$_ENV['nativeBuildInputs'] => /nix/store/5qwh70a0l0kw604g7kaj184mjrlia8jn-php-with-extensions-8.1.13 /nix/store/994rivc1y4xczq2n6phiqxy2g3z0g7gi-php-composer-2.4.4 /nix/store/8r41k2w2day19l80jvnlvdhrzpygblvx-php-imagick-3.7.0
So it clearly sees the imagick extension. Looking back at the composer output it seems that /nix/store/4l6iwxd26lpavkld9xpz7hb46swl1xsq-php-with-extensions-8.1.13
is used as its php instance. Running /nix/store/4l6iwxd26lpavkld9xpz7hb46swl1xsq-php-with-extensions-8.1.13/bin/php -I | grep imagick
I get the following output:
nativeBuildInputs => /nix/store/5qwh70a0l0kw604g7kaj184mjrlia8jn-php-with-extensions-8.1.13 /nix/store/994rivc1y4xczq2n6phiqxy2g3z0g7gi-php-composer-2.4.4 /nix/store/8r41k2w2day19l80jvnlvdhrzpygblvx-php-imagick-3.7.0
$_SERVER['nativeBuildInputs'] => /nix/store/5qwh70a0l0kw604g7kaj184mjrlia8jn-php-with-extensions-8.1.13 /nix/store/994rivc1y4xczq2n6phiqxy2g3z0g7gi-php-composer-2.4.4 /nix/store/8r41k2w2day19l80jvnlvdhrzpygblvx-php-imagick-3.7.0
$_ENV['nativeBuildInputs'] => /nix/store/5qwh70a0l0kw604g7kaj184mjrlia8jn-php-with-extensions-8.1.13 /nix/store/994rivc1y4xczq2n6phiqxy2g3z0g7gi-php-composer-2.4.4 /nix/store/8r41k2w2day19l80jvnlvdhrzpygblvx-php-imagick-3.7.0
No mention of the imagick extension anymore. It seems that the regular php command uses this instance:
/nix/store/5qwh70a0l0kw604g7kaj184mjrlia8jn-php-with-extensions-8.1.13/bin/php
instead of
/nix/store/4l6iwxd26lpavkld9xpz7hb46swl1xsq-php-with-extensions-8.1.13/bin/php
When using the following devbox.json:
{
"packages": [
"php81",
"php81Packages.composer",
"php81Extensions.imagick"
],
"shell": {
"init_hook": null
},
"nixpkgs": {
"commit": "52e3e80afff4b16ccb7c52e9f0f5220552f03d04"
}
}
I get errors in development.nix, because it adds the php81 entry multiple times:
php81 = pkgs.php81.withExtensions ({ enabled, all }: enabled ++ (with all; [ curl exif ftp gettext imagick imap pdo pdo_mysql simplexml soap ]));
php81 = pkgs.php81.withExtensions ({ enabled, all }: enabled ++ (with all; [ imagick ]));
@calvinbaart Thank you for reporting. Looking at this today and we'll circle back.
@calvinbaart thanks for the report!
You identified 2 bugs that we should be able to fix by next release (few days):
php81Packages.composer
is not using the php package that has the extensions. (as you correctly pointed out)devbox add
(previously we would parse your composer.json to determine it).If you don't want to wait for the next release, I was able to get it working by making some small changes to the devbox.json:
php81Packages.composer
install php81.packages.composer
. These are the same, but the latter will use the php81 with extensions. (After the fix, either one will work)devbox.json
(i.e. curl exif ftp...
become php81Extensions.curl
, etc). They need to be sorted alphabetically. (after the fix, the abc order requirement goes away but you'll still need to declare each extension you want)I was able to get the following setup to work:
devbox.json:
{
"packages": [
"php81",
// abc order
"php81Extensions.curl",
"php81Extensions.exif",
"php81Extensions.imagick",
"php81.packages.composer"
],
"shell": {
"init_hook": null
},
"nixpkgs": {
"commit": "52e3e80afff4b16ccb7c52e9f0f5220552f03d04"
}
}
and composer.json
{
"license": "MIT",
"require": {
"ext-imagick": "*",
"ext-curl": "*",
"ext-exif": "*"
}
}
and ran:
devbox shell
composer install
Owner Name | jetpack-io |
Repo Name | devbox |
Full Name | jetpack-io/devbox |
Language | Go |
Created Date | 2022-08-18 |
Updated Date | 2023-03-31 |
Star Count | 4960 |
Watcher Count | 19 |
Fork Count | 68 |
Issue Count | 42 |
Issue Title | Created Date | Updated Date |
---|