consolidation / cgr

Safe replacement for `composer global require`
451 stars 24 forks source link

Can't install package with a lower minimum-stability than stable #2

Closed thinkspill closed 7 years ago

thinkspill commented 8 years ago

When I read about your project I immediately thought of using it to get this other project installed:

https://github.com/Trismegiste/Mondrian

However, I'm stuck on this:

[ ~ ]$ cgr trismegiste/mondrian
Using version ^1.3 for trismegiste/mondrian
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - trismegiste/mondrian v1.3.3 requires nikic/php-parser 1.0.0beta2 -> satisfiable by nikic/php-parser[v1.0.0beta2] but these conflict with your requirements or minimum-stability.
    - trismegiste/mondrian v1.3.2 requires nikic/php-parser 1.0.0beta2 -> satisfiable by nikic/php-parser[v1.0.0beta2] but these conflict with your requirements or minimum-stability.
    - trismegiste/mondrian v1.3.1 requires nikic/php-parser 1.0.0beta2 -> satisfiable by nikic/php-parser[v1.0.0beta2] but these conflict with your requirements or minimum-stability.
    - Installation request for trismegiste/mondrian ^1.3 -> satisfiable by trismegiste/mondrian[v1.3.1, v1.3.2, v1.3.3].

Installation failed, reverting ./composer.json to its original content.

Is there a way to override a minimum-stability requirement here? And if not, is there a way to set up a repositories key so I can try installing a fork with fixed requirements?

Thanks for the awesome tool!

greg-1-anderson commented 8 years ago

When using composer directly, this is a two-step process:

  1. composer global config minimum-stability dev
  2. composer global require trismegiste/mondrian

Unfortunately, Composer does not have any standard options on the require command to edit the minimum-stability configuration value, as it does for some of its other commands. Therefore, I'll have to add some sort of non-standard option to the cgr command to make it configure the minimum stability prior to running composer require in the appropriate directory.

Minimum stability is a common enough use-case that it seems worth supporting. It would be a little complicated to support general-purpose composer.json editing in cgr, I think, but let me know if you have any ideas on how this might work simply.

greg-1-anderson commented 7 years ago

This is now available via --stability dev

geek-merlin commented 7 years ago

It would be cool to have this documented in the error messge or the help. Especially as this deviates from the guessed composer --minimum-stability.

(here's what i did before the web search...)

merlin@thinker:~$ cgr joachim-n/dorgflow
>> Running: composer '--working-dir=/home/merlin/.config/composer/global/joachim-n/dorgflow' 'require' 'joachim-n/dorgflow'

  [InvalidArgumentException]                                                                                         
  Could not find package joachim-n/dorgflow at any version for your minimum-stability (stable). Check the package s  
  pelling or your minimum-stability                                                                                  

require [--dev] [--prefer-source] [--prefer-dist] [--no-progress] [--no-update] [--no-scripts] [--update-no-dev] [--update-with-dependencies] [--ignore-platform-reqs] [--prefer-stable] [--prefer-lowest] [--sort-packages] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--] [<packages>]...

merlin@thinker:~$ cgr --help
The 'cgr' tool is a "safer" alternative to 'composer global require'.
Installing projects with cgr helps avoid dependency conflicts between
different tools.  Use 'cgr' wherever 'composer global require' is recommended.

Examples:

Install a project:
------------------
$ cgr drush/drush

Display the info of a project:
-----------------------------
$ cgr info drush/drush

Display the info of all projects installed via 'cgr':
----------------------------------------------------
$ cgr info

Update a project:
-----------------
$ cgr update drush/drush

Update all projects installed via 'cgr':
----------------------------------------
$ cgr update

Remove a project:
-----------------
$ cgr remove drush/drush

For more information, see: https://github.com/consolidation/cgr

merlin@thinker:~$ cgr joachim-n/dorgflow --minimum-stability=dev
>> Running: composer '--minimum-stability=dev' '--working-dir=/home/merlin/.config/composer/global/joachim-n/dorgflow' 'require' 'joachim-n/dorgflow'

  [Symfony\Component\Console\Exception\RuntimeException]  
  The "--minimum-stability" option does not exist.        

require [--dev] [--prefer-source] [--prefer-dist] [--no-progress] [--no-update] [--no-scripts] [--update-no-dev] [--update-with-dependencies] [--ignore-platform-reqs] [--prefer-stable] [--prefer-lowest] [--sort-packages] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--] [<packages>]...