wp-cli / package-command

Lists, installs, and removes WP-CLI packages.
MIT License
17 stars 20 forks source link

Errors installing command into development environment #184

Open Roy-Orbison opened 1 year ago

Roy-Orbison commented 1 year ago

Bug Report

Describe the current, buggy behavior

I read the contributing guidlines for installing a command, but got an error that looked like a regression of the problem described in wp-cli/wp-cli#5602.

When trying to work around it with the :dev-main suffix, wp-cli baulked at the https: scheme and the ssh alias github: (which shortens the usual git@github.com and selects the right key).

Maybe I'm just doing it wrong but it seems like odd behaviour when supplying legitimate URLs that work with Git.

Describe how other contributors can replicate this bug

Install command using wp package install ... with an HTTP or ssh alias URL. It may do the same with the explicit git@... URL.

See shell output below.

Describe what you expect as the correct outcome

Command to install as per docs, or docs are updated to new expected command.

It worked when I used wp package install wp-cli/search-replace-command:dev-main.

Let us know what environment you are running this on

OS:     Linux 6.5.0-10-generic wp-cli/wp-cli#10-Ubuntu SMP PREEMPT_DYNAMIC Fri Oct 13 13:49:38 UTC 2023 x86_64
Shell:  /bin/bash
PHP binary:     /usr/bin/php
PHP version:    8.2.10-2ubuntu1
php.ini used:   /etc/php/8.2/cli/php.ini
MySQL binary:   /usr/bin/mysql
MySQL version:  mysql  Ver 15.1 Distrib 10.11.4-MariaDB, for debian-linux-gnu (x86_64) using  EditLine wrapper
SQL modes:
WP-CLI root dir:        /home/roy/GitHub/wp-cli
WP-CLI vendor dir:      /home/roy/GitHub/wp-cli/vendor
WP_CLI phar path:
WP-CLI packages dir:    /home/roy/.wp-cli/packages/
WP-CLI cache dir:       /home/roy/.wp-cli/cache
WP-CLI global config:
WP-CLI project config:
WP-CLI version: 2.10.0-alpha

Provide additional context/screenshots

Shell output:

roy@RoyBook ~/GitHub/wp-cli
$ bin/wp package install https://github.com/wp-cli/search-replace-command.git
Installing package wp-cli/search-replace-command (dev-main)
Updating /home/roy/.wp-cli/packages/composer.json to require the package...
Registering https://github.com/wp-cli/search-replace-command.git as a VCS repository...
Using Composer to install the package...
---
Loading composer repositories with package information
Warning: Could not authenticate against github.com
---
Error: Package installation failed.
Reverted composer.json.

roy@RoyBook ~/GitHub/wp-cli
$ bin/wp package install github:wp-cli/search-replace-command.git
Warning: Couldn't fetch default branch for package 'github:wp-cli/search-replace-command.git' (HTTP code 403). Presuming default branch is 'master'.
Installing package wp-cli/search-replace-command (dev-master)
Updating /home/roy/.wp-cli/packages/composer.json to require the package...
Registering github:wp-cli/search-replace-command.git as a VCS repository...
Using Composer to install the package...
---
Loading composer repositories with package information
Updating dependencies
Generating rules
Resolving dependencies through SAT
Looking at all rules.

Dependency resolution completed in 0.000 seconds
Your requirements could not be resolved to an installable set of packages.
Problem 1
    - Root composer.json requires wp-cli/search-replace-command dev-master, found wp-cli/search-replace-command[dev-main, dev-bump-travis-server-to-xenial, v1.0.0, v1.0.1, v1.0.2, v1.0.3, v1.0.4, v1.1.0, v1.1.1, v1.1.2, v1.1.3, v1.1.4, v1.2.0, v1.3.0, v1.3.1, v2.0.0, v2.0.1, v2.0.2, v2.0.3, v2.0.4, v2.0.5, v2.0.6, v2.0.7, v2.0.8, v2.0.9, v2.0.10, v2.0.11, v2.0.12, v2.0.13, v2.0.14, v2.0.15, v2.0.16, v2.0.17, v2.0.18, v2.0.19, v2.0.20, v2.1.0, v2.1.1, v2.1.2, v2.1.3, 2.x-dev (alias of dev-main)] but it does not match the constraint. Perhaps dev-master was renamed to dev-main?
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.
---
Error: Package installation failed (Composer return code 2).
Reverted composer.json.

roy@RoyBook ~/GitHub/wp-cli
$ bin/wp package install github:wp-cli/search-replace-command.git
Warning: Couldn't fetch default branch for package 'github:wp-cli/search-replace-command.git' (HTTP code 403). Presuming default branch is 'master'.
Installing package wp-cli/search-replace-command (dev-master)
Updating /home/roy/.wp-cli/packages/composer.json to require the package...
Registering github:wp-cli/search-replace-command.git as a VCS repository...
Using Composer to install the package...
---
Loading composer repositories with package information
Updating dependencies
Generating rules
Resolving dependencies through SAT
Looking at all rules.

Dependency resolution completed in 0.000 seconds
Your requirements could not be resolved to an installable set of packages.
Problem 1
    - Root composer.json requires wp-cli/search-replace-command dev-master, found wp-cli/search-replace-command[dev-main, dev-bump-travis-server-to-xenial, v1.0.0, v1.0.1, v1.0.2, v1.0.3, v1.0.4, v1.1.0, v1.1.1, v1.1.2, v1.1.3, v1.1.4, v1.2.0, v1.3.0, v1.3.1, v2.0.0, v2.0.1, v2.0.2, v2.0.3, v2.0.4, v2.0.5, v2.0.6, v2.0.7, v2.0.8, v2.0.9, v2.0.10, v2.0.11, v2.0.12, v2.0.13, v2.0.14, v2.0.15, v2.0.16, v2.0.17, v2.0.18, v2.0.19, v2.0.20, v2.1.0, v2.1.1, v2.1.2, v2.1.3, 2.x-dev (alias of dev-main)] but it does not match the constraint. Perhaps dev-master was renamed to dev-main?
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.
---
Error: Package installation failed (Composer return code 2).
Reverted composer.json.

roy@RoyBook ~/GitHub/wp-cli
$ bin/wp package install github:wp-cli/search-replace-command.git:dev-main
Error: Invalid package: shortened identifier 'github' not found.

roy@RoyBook ~/GitHub/wp-cli
$ bin/wp package install https://github.com/wp-cli/search-replace-command.git:dev-main
Error: Invalid package: shortened identifier 'https' not found.

roy@RoyBook ~/GitHub/wp-cli
$ bin/wp package install wp-cli/search-replace-command:dev-main
Installing package wp-cli/search-replace-command (dev-main)
Updating /home/roy/.wp-cli/packages/composer.json to require the package...
Using Composer to install the package...
---
Loading composer repositories with package information
Updating dependencies
Generating rules
Resolving dependencies through SAT
Looking at all rules.

Dependency resolution completed in 0.000 seconds
Analyzed 86 packages to resolve dependencies
Analyzed 88 rules to resolve dependencies
Lock file operations: 1 install, 0 updates, 0 removals
Installs: wp-cli/search-replace-command:dev-main 0b662a3
- Locking wp-cli/search-replace-command (dev-main 0b662a3)
Writing lock file
Installing dependencies from lock file
Package operations: 1 install, 0 updates, 0 removals
Installs: wp-cli/search-replace-command:dev-main 0b662a3
 - Installing <info>wp-cli/search-replace-command</info> (<comment>dev-main 0b662a3</comment>)
Generating autoload files
---
Success: Package installed.
danielbachhuber commented 11 months ago

Thanks for the report, @Roy-Orbison !

We can definitely try to fix up the URL syntaxes you think are broken. I'm having a little bit of a hard time grokking your report, though. Which syntaxes would you like to see supported?

Roy-Orbison commented 11 months ago

In this docs section, it states that adding a module is done like so, the last parameter looking like a typical Git URL:

wp package install git@github.com:wp-cli/dist-archive-command.git

These all failed:

What worked was wp-cli/search-replace-command:dev-main, which I gleaned from this issue comment where someone else had encountered the invalid default branch dev-master.

You don't necessarily have to support those URL types, more that the docs didn't match the experience, so maybe something needs to be updated.

danielbachhuber commented 11 months ago

Thanks, @Roy-Orbison.

I think we should:

In honestly, what's most likely is that the additional URL patterns weren't considered when the feature was created.

Feel free to submit a pull request, if you'd like. Here is some guidance on our pull request best practices.