moodlehq / moodle-cs

Moodle Coding Style
https://github.com/moodlehq/moodle-cs
GNU General Public License v3.0
18 stars 15 forks source link

Installation via composer uses old version #78

Closed t-schroeder closed 9 months ago

t-schroeder commented 10 months ago

The recommended installation via composer gives me version 3.2.5 instead of the latest version which is 3.3.10 at the time of writing this. That old version doesn't include the "moodle-extra" standard which is recommended in the readme. How do I get composer to install the latest version of "moodlehq/moodle-cs"?

$ composer --version
Composer version 2.6.5 2023-10-06 10:11:52
$ composer global require --dry-run moodlehq/moodle-cs
Changed current directory to /home/st-admin/.config/composer
./composer.json has been updated
Running composer update moodlehq/moodle-cs
Loading composer repositories with package information
Updating dependencies
Lock file operations: 4 installs, 0 updates, 0 removals
  - Locking dealerdirect/phpcodesniffer-composer-installer (v0.7.2)
  - Locking moodlehq/moodle-cs (v3.2.5)
  - Locking phpcompatibility/php-compatibility (9.3.5)
  - Locking squizlabs/php_codesniffer (3.7.2)
Installing dependencies from lock file (including require-dev)
Package operations: 4 installs, 0 updates, 0 removals
  - Installing squizlabs/php_codesniffer (3.7.2)
  - Installing dealerdirect/phpcodesniffer-composer-installer (v0.7.2)
  - Installing phpcompatibility/php-compatibility (9.3.5)
  - Installing moodlehq/moodle-cs (v3.2.5)
1 package suggestions were added by new dependencies, use `composer suggest` to see details.
No installed packages - skipping audit.
Using version ^3.2 for moodlehq/moodle-cs
t-schroeder commented 10 months ago

Here's what I get when trying to install version 3.3.10 (currently the latest) explicitly:

$ composer global require moodlehq/moodle-cs 3.3.10
Changed current directory to /home/st-admin/.config/composer
./composer.json has been updated
Running composer update moodlehq/moodle-cs
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Root composer.json requires moodlehq/moodle-cs 3.3.10 -> satisfiable by moodlehq/moodle-cs[v3.3.10].
    - moodlehq/moodle-cs v3.3.10 requires phpcompatibility/php-compatibility dev-develop#0a17f9ed -> found phpcompatibility/php-compatibility[dev-develop, 10.x-dev (alias of dev-develop)] but it does not match your minimum-stability.

Installation failed, reverting ./composer.json and ./composer.lock to their original content.
t-schroeder commented 10 months ago

Here's what is necessary to get composer to install the latest version:

composer global config minimum-stability dev
composer global config prefer-stable true
composer global require moodlehq/moodle-cs

That solves the issue for me. But I would recommend adding this to the readme, so others won't have to spend potentially hours troubleshooting, too.

andrewnicols commented 10 months ago

Thanks Tim,

The issue here is that one of our dependency (phpcompatibility) has not got a stable version out which is compatible with supported php versions (the irony...).

Our options here are to stop using it as a dependency, or fork it.

In the mean time, you can run the following which will allow you to use the dev version we're currently pointing at:

composer global config minimum-stability dev