question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Trouble installing global package with composer for Yii2

See original GitHub issue

What version of Cloud Foundry and CF CLI are you using? (i.e. What is the output of running cf curl /v2/info && cf version? cf version 6.26.0+9c9a261fd.2017-06-27

What version of the buildpack you are using? Buildpack version 4.3.43

If you were attempting to accomplish a task, what was it you were attempting to do? In order to use Yii 2.0, composer requires the fxp/composer-asset-plugin to be installed globaly, I saw on different forums and also on #163 that adding the ADDITIONAL_PREPROCESS_CMDS property in the options.json file should fix the problem, but I am not seeing any output when deploying my application that shows the composer is installing that dependency.

.bp-config/options.json { "PHP_VERSION": "{PHP_56_LATEST}", "PHP_EXTENSIONS": ["mcrypt","mbstring"], "ADDITIONAL_PREPROCESS_CMDS": [ "php php/bin/composer.phar global require \"fxp/composer-asset-plugin:~1.4.1\"" ] }

I also tried adding a custom command using the pre-update-cmd property in the composer.json file. In this case I see the composer installing the plugin needed but when doing the composer install I am still getting the same error message.

`-------> Buildpack version 4.3.43 WARNING: buildpack version changed from 4.3.42 to 4.3.43 WARNING: PHP version >=5.5.38 not available, using default version (5.6.31). In future versions of the buildpack, specifying a non-existent PHP version will cause staging to fail. See: http://docs.cloudfoundry.org/buildpacks/php/gsg-php-composer.html Installing HTTPD HTTPD 2.4.28 Downloaded [https://buildpacks.cloudfoundry.org/dependencies/httpd/httpd-2.4.28-linux-x64-ea45b58f.tgz] to [/tmp] WARNING: A version of PHP has been specified in both ‘composer.json’ and ‘./bp-config/options.json’. WARNING: The version defined in ‘composer.json’ will be used. Warning: PHP_EXTENSIONS in options.json is deprecated. See: http://docs.cloudfoundry.org/buildpacks/php/gsg-php-config.html Installing PHP PHP 5.6.31 Downloaded [https://buildpacks.cloudfoundry.org/dependencies/php/php-5.6.31-linux-x64-2551a0b1.tgz] to [/tmp] Downloaded [https://buildpacks.cloudfoundry.org/dependencies/php/php-5.6.31-linux-x64-2551a0b1.tgz] to [/tmp] Downloaded [https://buildpacks.cloudfoundry.org/dependencies/composer/composer-1.5.2-ac2fa3db.phar] to [/tmp] PROTIP: Include a ‘composer.lock’ file with your application! This will make sure the exact same version of dependencies are used when you deploy to CloudFoundry. % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:–:-- --:–:-- --:–:-- 0 100 387 100 387 0 0 1698 0 --:–:-- --:–:-- --:–:-- 1704 -----> Using custom GitHub OAuth token in $COMPOSER_GITHUB_OAUTH_TOKEN % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:–:-- --:–:-- --:–:-- 0 0 0 0 0 0 0 0 0 --:–:-- --:–:-- --:–:-- 0 100 387 100 387 0 0 2469 0 --:–:-- --:–:-- --:–:-- 2464 Loading composer repositories with package information Updating dependencies Your requirements could not be resolved to an installable set of packages. Problem 1 - Installation request for yiisoft/yii2 ~2.0.12 -> satisfiable by yiisoft/yii2[2.0.12]. - yiisoft/yii2 2.0.12 requires bower-asset/jquery 2.2.@stable | 2.1.@stable | 1.11.@stable | 1.12.@stable -> no matching package found. Problem 2 - Installation request for yiisoft/yii2-bootstrap ~2.0.7 -> satisfiable by yiisoft/yii2-bootstrap[2.0.7]. - yiisoft/yii2-bootstrap 2.0.7 requires bower-asset/bootstrap 3.3.* | 3.2.* | 3.1.* -> no matching package found. Problem 3 - Installation request for yiisoft/yii2-gii ~2.0.5 -> satisfiable by yiisoft/yii2-gii[2.0.5]. - yiisoft/yii2-gii 2.0.5 requires bower-asset/typeahead.js 0.10.* | ~0.11.0 -> no matching package found. Problem 4 - yiisoft/yii2 2.0.12 requires bower-asset/jquery 2.2.@stable | 2.1.@stable | 1.11.@stable | 1.12.@stable -> no matching package found. - asasmoyo/yii2-saml 1.4.0 requires yiisoft/yii2 * -> satisfiable by yiisoft/yii2[2.0.12]. - Installation request for asasmoyo/yii2-saml ~1.4.0 -> satisfiable by asasmoyo/yii2-saml[1.4.0]. Potential causes:

  • A typo in the package name
  • The package is not available in a stable-enough version according to your minimum-stability setting see https://getcomposer.org/doc/04-schema.md#minimum-stability for more details. Read https://getcomposer.org/doc/articles/troubleshooting.md for further common problems. Running update with --no-dev does not mean require-dev is ignored, it just means the packages will not be installed. If dev requirements are blocking the update you have to resolve those problems. Traceback (most recent call last): -----> Composer command failed File “/tmp/buildpacks/3f0c03c7602ee67512337b56bc424f4b/scripts/compile.py”, line 59, in <module> .from_build_pack(‘lib/additional_commands’) File “/tmp/buildpacks/3f0c03c7602ee67512337b56bc424f4b/lib/build_pack_utils/builder.py”, line 209, in extensions process_extension(path, ctx, ‘compile’, process, args=[self]) File “/tmp/buildpacks/3f0c03c7602ee67512337b56bc424f4b/lib/build_pack_utils/utils.py”, line 69, in process_extension success(getattr(extn, to_call)(*args)) File “/tmp/buildpacks/3f0c03c7602ee67512337b56bc424f4b/extensions/composer/extension.py”, line 429, in compile return composer.compile(install) File “/tmp/buildpacks/3f0c03c7602ee67512337b56bc424f4b/lib/extension_helpers.py”, line 154, in compile self._compile(install) File “/tmp/buildpacks/3f0c03c7602ee67512337b56bc424f4b/extensions/composer/extension.py”, line 196, in _compile self.run() File “/tmp/buildpacks/3f0c03c7602ee67512337b56bc424f4b/extensions/composer/extension.py”, line 331, in run *self._ctx[‘COMPOSER_INSTALL_OPTIONS’]) File “/tmp/buildpacks/3f0c03c7602ee67512337b56bc424f4b/extensions/composer/extension.py”, line 375, in run shell=True) File “/tmp/buildpacks/3f0c03c7602ee67512337b56bc424f4b/lib/build_pack_utils/runner.py”, line 109, in stream_output raise CalledProcessError(retcode, cmd) build_pack_utils.runner.CalledProcessError: Command ‘<open file ‘<fdopen>’, mode ‘w’ at 0x7f479cb5f9c0>’ returned non-zero exit status 2 Failed to compile droplet Exit status 223 Staging failed: Exited with status 223 Destroying container Successfully destroyed container `

`composer.json { “name”: “yiisoft/yii2-app-basic”, “description”: “Yii 2 Basic Project Template”, “keywords”: [“yii2”, “framework”, “basic”, “project template”], “homepage”: “http://www.yiiframework.com/”, “type”: “project”, “license”: “BSD-3-Clause”,a “support”: { “issues”: “https://github.com/yiisoft/yii2/issues?state=open”, “forum”: “http://www.yiiframework.com/forum/”, “wiki”: “http://www.yiiframework.com/wiki/”, “irc”: “irc://irc.freenode.net/yii”, “source”: “https://github.com/yiisoft/yii2” }, “minimum-stability”: “stable”, “require”: { “php”: “>=5.5.38”, “ext-ldap”: “", “ext-pdo”: "”, “yiisoft/yii2”: “~2.0.12”, “yiisoft/yii2-bootstrap”: “~2.0.7”, “yiisoft/yii2-swiftmailer”: “~2.1.0”, “yiisoft/yii2-debug”: “~2.0.12”, “yiisoft/yii2-gii”: “~2.0.5”, “yiisoft/yii2-faker”: “~2.0.3”, “codeception/base”: “~2.3.6”, “codeception/verify”: “~0.4.0”, “codeception/specify”: “~0.4.6”, “asasmoyo/yii2-saml”: “~1.4.0”, “onelogin/php-saml”: “~2.11.0” }, “require-dev”: { “yiisoft/yii2-gii”: “~2.0.5”, “yiisoft/yii2-faker”: “~2.0.3”, “codeception/base”: “~2.3.6”, “codeception/verify”: “~0.4.0”, “codeception/specify”: “~0.4.6” }, “config”: { “vendor-dir”:“lib/vendor”, “process-timeout”: 1800, “fxp-asset”: { “installer-paths”: { “npm-asset-library”: “lib/vendor/npm”, “bower-asset-library”: “lib/vendor/bower” } } }, “scripts”: { “post-create-project-cmd”: [ “yii\composer\Installer::postCreateProject” ] }, “extra”: { “yii\composer\Installer::postCreateProject”: { “setPermission”: [ { “runtime”: “0777”, “web/assets”: “0777”, “yii”: “0755” } ], “generateCookieValidationKey”: [ “htdocs/config/web.php” ] } } }

` Please confirm where necessary:

  • [ x ] I have included a log output
  • [ x ] My log includes an error message
  • [ ] I have included steps for reproduction

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
dmikusacommented, Oct 20, 2017

I don’t think ADDITIONAL_PREPROCESS_CMDS is what you want. Those commands would run prior to your app starting in the runtime environment, not at staging. For what it’s worth, ADDITIONAL_PREPROCESS_CMDS has largely replaced by using a .profile script.

There’s also no way through the buildpack to install a global composer module. The current extension only installs modules for the project, you can see how the command is run here.

Without some sort of feature request, the best you can probably do would be to hack around this. I haven’t used Yii, so I’m not sure sure what would be the best way to do that.

As far as a feature request goes, what do you think would be a good way to specify global packages that need installed with composer? Perhaps and an option to options.json like COMPOSER_INSTALL_GLOBAL? The option could be a list so you could specify packages like ["fxp/composer-asset-plugin:~1.4.1", "some-other-package:~0.34"]. Or can you include that into the composer.json file & we could fish it out of there?

0reactions
sclevinecommented, Mar 12, 2018

Closing due to inactivity.

Read more comments on GitHub >

github_iconTop Results From Across the Web

unable to install package using composer in yii2
Try to update your composer asset plugin. Open your shell and run. composer global require "fxp/composer-asset-plugin:dev-master". Then run.
Read more >
Composer failing to download packages - Installation and Setup
I have just built a Vagrant virtual machine running Debian 8 and php7.0 and have just started the install steps. composer global require ......
Read more >
Yii2 stuck on "installing dependencies" - Yii Framework Forum
How long has it been stuck? Composer can take a while to install the required packages if they're not cached.
Read more >
Yii2 Composer is broken! - Yii Framework Forum
Potential causes: - A typo in the package name - The package is not available in a stable-enough version according to your min...
Read more >
Getting Started: Installing Yii | The Definitive Guide to Yii 2.0
You can install Yii in two ways, using the Composer package manager or by downloading an archive file. The former is the preferred...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found