yireo / magento2-replace-tools

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot Add a replacement bulk package

Top-CMS opened this issue · comments

Hi,

I cannot add a replacement bulk package.

Magento 2.4.6-p3
See error:
[Composer\Downloader\TransportException] The "https://repo.magento.com/packages.json" file could not be downloaded (HTTP/2 404 ): {"warning":"You haven\u0027t provided your Magento authentication keys. For instructions, visit https:\/\/devdocs.magento.com\/guides\/v2.3\/install-gde\ /prereq\/connect-auth.html"}

Of course I got the correct credenials. Install Magento and other extensions no error

app@0897ff71b97a:~/magento2$ composer require yireo/magento2-replace-tools # Require this plugin
Using version ^1.0 for yireo/magento2-replace-tools
./composer.json has been updated
Running composer update yireo/magento2-replace-tools
Loading composer repositories with package information
Updating dependencies
Lock file operations: 2 installs, 0 updates, 0 removals
  - Locking league/flysystem-memory (3.13.0)
  - Locking yireo/magento2-replace-tools (1.0.4)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 2 installs, 0 updates, 0 removals
  - Downloading league/flysystem-memory (3.13.0)
  - Downloading yireo/magento2-replace-tools (1.0.4)
  - Installing league/flysystem-memory (3.13.0): Extracting archive
  - Installing yireo/magento2-replace-tools (1.0.4): Extracting archive
Package laminas/laminas-zendframework-bridge is abandoned, you should avoid using it. No replacement was suggested.
Package sebastian/phpcpd is abandoned, you should avoid using it. No replacement was suggested.
Generating autoload files
128 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
app@0897ff71b97a:~/magento2$ composer replace:bulk:add yireo/magento2-replace-bundled # Add a replacement bulk package


  [Composer\Downloader\TransportException]
  The "https://repo.magento.com/packages.json" file could not be downloaded (HTTP/2 404 ):
  {"warning":"You haven\u0027t provided your Magento authentication keys. For instructions, visit https:\/\/devdocs.magento.com\/guides\/v2.3\/install-gde\
  /prereq\/connect-auth.html"}


replace:bulk:add <package>

I'm not able to replicate this. And even though, you say that the authentication should work, it doesn't: This composer plugin uses composer to fetch meta-packages and this gives the error The "https://repo.magento.com/packages.json" file could not be downloaded. In other words, something in your composer authentication is still off. Perhaps this is due to a different COMPOSER_HOME being used in different circumstances? Perhaps the auth.json is in var/composer_home/ and not the root?

I will test more

For sure the auth.json is good. Installed Magento and some other plugins with it.
It is stored in the /data/web/.composer folder

After install my composer.json looks like"

    "minimum-stability": "stable",
    "prefer-stable": true,
    "repositories": [
        {
            "type": "composer",
            "url": "https://repo.magento.com/"
        }
    ],
    "extra": {
        "magento-force": "override"
    },
    "replace": {
        "yireo/magento2-replace-sample-data": "*"
    }


this (the old method) works:

app@0897ff71b97a:~/magento2$ composer require yireo/magento2-replace-sample-data
Using version ^4.2 for yireo/magento2-replace-sample-data
./composer.json has been updated
Running composer update yireo/magento2-replace-sample-data
Loading composer repositories with package information
Updating dependencies
Lock file operations: 1 install, 0 updates, 1 removal
  - Removing magento/module-sample-data (100.4.4)
  - Locking yireo/magento2-replace-sample-data (4.2.2)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 1 install, 0 updates, 1 removal
  - Downloading yireo/magento2-replace-sample-data (4.2.2)
  - Removing magento/module-sample-data (100.4.4)
  - Installing yireo/magento2-replace-sample-data (4.2.2): Extracting archive
Removing Magento/SampleData

You're including a partial dump of your composer.json and commands that do not show all steps.

I've tried to replicate things with the following JSON:

{   
    "minimum-stability": "stable",
    "prefer-stable": true,
    "require": {
        "magento/product-community-edition": "2.4.6-p3",
        "yireo/magento2-replace-tools": "^1.0"
    },
    "repositories": [
        {
            "type": "composer",
            "url": "https://repo.magento.com/"
        }
    ],
    "extra": {
        "magento-force": "override"
    },
    "config": {
        "allow-plugins": {
            "magento/composer-dependency-version-audit-plugin": true,
            "magento/inventory-composer-installer": true,
            "magento/magento-composer-installer": true,
            "yireo/magento2-replace-tools": true
        }
    }
}

And next, the following commands:

composer replace:bulk:add yireo/magento2-replace-bundled
composer replace:build

I don't get any errors from this :(

This is with php 8.1

app@0897ff71b97a:~/magento2$ composer replace:list
+---------+---------+
| Package | Version |
+---------+---------+
PHP Fatal error:  Uncaught Error: Undefined constant Symfony\Component\Console\Command\Command::SUCCESS in /data/web/magento2/vendor/yireo/magento2-replace-tools/src/Composer/Command/ReplaceListCommand.php:32
Stack trace:
#0 phar:///usr/local/bin/composer22/vendor/symfony/console/Command/Command.php(245): Yireo\ReplaceTools\Composer\Command\ReplaceListCommand->execute()
#1 phar:///usr/local/bin/composer22/vendor/symfony/console/Application.php(835): Symfony\Component\Console\Command\Command->run()
#2 phar:///usr/local/bin/composer22/vendor/symfony/console/Application.php(185): Symfony\Component\Console\Application->doRunCommand()
#3 phar:///usr/local/bin/composer22/src/Composer/Console/Application.php(336): Symfony\Component\Console\Application->doRun()
#4 phar:///usr/local/bin/composer22/vendor/symfony/console/Application.php(117): Composer\Console\Application->doRun()
#5 phar:///usr/local/bin/composer22/src/Composer/Console/Application.php(131): Symfony\Component\Console\Application->run()
#6 phar:///usr/local/bin/composer22/bin/composer(83): Composer\Console\Application->run()
#7 /usr/local/bin/composer22(29): require('...')
#8 {main}
  thrown in /data/web/magento2/vendor/yireo/magento2-replace-tools/src/Composer/Command/ReplaceListCommand.php on line 32

Fatal error: Uncaught Error: Undefined constant Symfony\Component\Console\Command\Command::SUCCESS in /data/web/magento2/vendor/yireo/magento2-replace-tools/src/Composer/Command/ReplaceListCommand.php:32
Stack trace:
#0 phar:///usr/local/bin/composer22/vendor/symfony/console/Command/Command.php(245): Yireo\ReplaceTools\Composer\Command\ReplaceListCommand->execute()
#1 phar:///usr/local/bin/composer22/vendor/symfony/console/Application.php(835): Symfony\Component\Console\Command\Command->run()
#2 phar:///usr/local/bin/composer22/vendor/symfony/console/Application.php(185): Symfony\Component\Console\Application->doRunCommand()
#3 phar:///usr/local/bin/composer22/src/Composer/Console/Application.php(336): Symfony\Component\Console\Application->doRun()
#4 phar:///usr/local/bin/composer22/vendor/symfony/console/Application.php(117): Composer\Console\Application->doRun()
#5 phar:///usr/local/bin/composer22/src/Composer/Console/Application.php(131): Symfony\Component\Console\Application->run()
#6 phar:///usr/local/bin/composer22/bin/composer(83): Composer\Console\Application->run()
#7 /usr/local/bin/composer22(29): require('...')
#8 {main}
  thrown in /data/web/magento2/vendor/yireo/magento2-replace-tools/src/Composer/Command/ReplaceListCommand.php on line 32
app@0897ff71b97a:~/magento2$ composer replace:bulk:add yireo/magento2-replace-bundled


  [Composer\Downloader\TransportException]
  The "https://repo.magento.com/packages.json" file could not be downloaded (HTTP/2 404 ):
  {"warning":"You haven\u0027t provided your Magento authentication keys. For instructions, visit https:\/\/devdocs.magento.com\/guides\/v2.3\/install-gde\/prereq\/connect
  -auth.html"}


replace:bulk:add <package>

This is showing you that Symfony Console is outdated, which you probably already guessed because the error says so. Which Symfony Console version are you using? composer show symfony/console | grep version

Hi,

I tested it on another Magento 2.4.6-p3, same problem. Both are on a docking station:
https://github.com/ByteInternet/hypernode-docker
docker.hypernode.com/byteinternet/hypernode-buster-docker-php81-mysql80

composer show symfony/console | grep version
versions : * v5.4.28

And what is the version of composer itself?

Composer version 2.2.21

Strange. The constants like Symfony\Component\Console\Command\Command::SUCCESS have been added to the Symfony Console since version 5.1 and both Magento and Composer have been using this version for a long time. I'm also not able to duplicate this issue, so I can only say that something is somewhere outdated in your environment causing this error.

Note that I consider the earlier issue - the authentication issue - closed. Recommendation: If you have a new issue, it is better to open a new Issue. This is not a support thread between a customer and paid developer, this is meant to guide anyone in the open source community - hence the word Issue is singular.

Hi,

Sorry for bothering you but I have the exact same problem.
I understood that this is not a support thread but as it is the exact same issue, I thought it would maybe be useful to inform you in the same github issue to avoid a duplicate.

I run the following :
No docker
PHP 8.2
Magento 2.4.6-p3
Composer 2.2.6

And I'm not able to download the bulk replace-inventory package :

$ composer2 replace:bulk:add yireo/magento2-replace-inventory
  [Composer\Downloader\TransportException]                                                                                                                                               
  The "https://repo.magento.com/packages.json" file could not be downloaded (HTTP/2 404 ):                                                                                               
  {"warning":"You haven\u0027t provided your Magento authentication keys. For instructions, visit https:\/\/devdocs.magento.com\/guides\/v2.3\/install-gde\/prereq\/connect-auth.html"}  
                                                                                                                                                                                         

replace:bulk:add <package>

I'm using a fresh install of magento 2.4.6-p3 with some other amasty extensions and two marketplace extensions.

Here is my symfony console version :

$ composer2 show symfony/console | grep version
versions : * v5.4.28

I have the same problem with any of your bulk replace package and my composer.json is defined exactly as you've provided in #9 (comment)

Just to be sure to understand, why do you consider the authentication issue closed ? Did you provide an explanation that I did not see upper or do you consider this error as something on our side ?

Thank you very much for your tools, they are very useful.

@sezio I didn't hear back from @Top-CMS after my suggestions and instead, new issues were reported, suggesting that the title of the post was no longer relevant. This is why I considered the issue closed.

If others, like you, are bumping into this as well, apparently, something else is at play. Which version of the yireo/magento2-replace-tools plugin are you using?

If the same composer.json file is used, then authentication with the Marketplace is already succeeding (because that's where Magento packages are downloaded from). But where are the authentication credentials actually saved? Is this a file auth.json in the root of your Magento site? Or a file var/composer_home/auth.json? Or a global auth.json file?

Hi @jissereitsma

I did not specified a specific version of the yireo/magento2-replace-tools package so composer automatically installed the 1.0.5.

The auth.json is placed at the root of my website and contains functional credentials.

Unfortunately, I do not have any other clue of what is different compared to you. I can also confirm that, like @Top-CMS said, installing the package without using the replace tools work fine

I've tried again to reproduce things, but still no luck. What is your platform (Windows, Linux, MacOS)? Also, what if you try to copy the details from the auth.json into a global auth.json file (placed within your global composer home)? Your composer home should be reported with composer config --list --global |grep data-dir.

I have the repo.magento.com in both
/data/web/.composer/auth.json
/data/web/magento2/auth.json

composer config --list --global |grep data-dir
[data-dir] /data/web/.local/share/composer

When I do : composer replace:list

app@0897ff71b97a:~/magento2$ composer replace:list
+---------+---------+
| Package | Version |
+---------+---------+
PHP Fatal error:  Uncaught Error: Undefined constant Symfony\Component\Console\Command\Command::SUCCESS in /data/web/magento2/vendor/yireo/magento2-replace-tools/src/Composer/Command/ReplaceListCommand.php:32
Stack trace:
#0 phar:///usr/local/bin/composer22/vendor/symfony/console/Command/Command.php(245): Yireo\ReplaceTools\Composer\Command\ReplaceListCommand->execute()
#1 phar:///usr/local/bin/composer22/vendor/symfony/console/Application.php(835): Symfony\Component\Console\Command\Command->run()
#2 phar:///usr/local/bin/composer22/vendor/symfony/console/Application.php(185): Symfony\Component\Console\Application->doRunCommand()
#3 phar:///usr/local/bin/composer22/src/Composer/Console/Application.php(336): Symfony\Component\Console\Application->doRun()
#4 phar:///usr/local/bin/composer22/vendor/symfony/console/Application.php(117): Composer\Console\Application->doRun()
#5 phar:///usr/local/bin/composer22/src/Composer/Console/Application.php(131): Symfony\Component\Console\Application->run()
#6 phar:///usr/local/bin/composer22/bin/composer(83): Composer\Console\Application->run()
#7 /usr/local/bin/composer22(29): require('...')
#8 {main}
  thrown in /data/web/magento2/vendor/yireo/magento2-replace-tools/src/Composer/Command/ReplaceListCommand.php on line 32

Fatal error: Uncaught Error: Undefined constant Symfony\Component\Console\Command\Command::SUCCESS in /data/web/magento2/vendor/yireo/magento2-replace-tools/src/Composer/Command/ReplaceListCommand.php:32
Stack trace:
#0 phar:///usr/local/bin/composer22/vendor/symfony/console/Command/Command.php(245): Yireo\ReplaceTools\Composer\Command\ReplaceListCommand->execute()
#1 phar:///usr/local/bin/composer22/vendor/symfony/console/Application.php(835): Symfony\Component\Console\Command\Command->run()
#2 phar:///usr/local/bin/composer22/vendor/symfony/console/Application.php(185): Symfony\Component\Console\Application->doRunCommand()
#3 phar:///usr/local/bin/composer22/src/Composer/Console/Application.php(336): Symfony\Component\Console\Application->doRun()
#4 phar:///usr/local/bin/composer22/vendor/symfony/console/Application.php(117): Composer\Console\Application->doRun()
#5 phar:///usr/local/bin/composer22/src/Composer/Console/Application.php(131): Symfony\Component\Console\Application->run()
#6 phar:///usr/local/bin/composer22/bin/composer(83): Composer\Console\Application->run()
#7 /usr/local/bin/composer22(29): require('...')
#8 {main}
  thrown in /data/web/magento2/vendor/yireo/magento2-replace-tools/src/Composer/Command/ReplaceListCommand.php on line 32

@Top-CMS Please realize that you seem to be mixing up 2 very different issues: Issue number 1 was reported in this thread and has only something to do with authentication - let's keep that issue, and only that issue, active in this thread (so that others are only reacting to that issue and not to a different issue). Issue number 2 was reported by you afterwards and has only to do with a version of Symfony in your system that does not support the constant SUCCESS. I have moved that second issue to a separate Issue: #12

If the original issue of authentication was solved for you, please mark this as solved here. If the other issue of a different Symfony version is still bugging, please address it in the other issue. Discussing 2 different issues in the same GitHub Issue is not handy.

If the original issue of authentication was solved for you, please mark this as solved here.

No, it has not been solved yet.
I thought it was helpful to add the message for composer replace:list as well.

But still get message:

$ composer2 replace:bulk:add yireo/magento2-replace-inventory
  [Composer\Downloader\TransportException]                                                                                                                                               
  The "https://repo.magento.com/packages.json" file could not be downloaded (HTTP/2 404 ):                                                                                               
  {"warning":"You haven\u0027t provided your Magento authentication keys. For instructions, visit https:\/\/devdocs.magento.com\/guides\/v2.3\/install-gde\/prereq\/connect-auth.html"}  

You mentioned that the output of composer config --list --global |grep data-dir is this: /data/web/.local/share/composer. In other words, that's the composer home folder. What happens if you copy the auth.json file to that home folder?

Nope, still

app@0897ff71b97a:~/magento2$ composer require yireo/magento2-replace-tools
Using version ^1.0 for yireo/magento2-replace-tools
./composer.json has been updated
Running composer update yireo/magento2-replace-tools
Loading composer repositories with package information
Updating dependencies
Lock file operations: 2 installs, 0 updates, 0 removals
  - Locking league/flysystem-memory (3.13.0)
  - Locking yireo/magento2-replace-tools (1.0.5)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 2 installs, 0 updates, 0 removals
  - Installing league/flysystem-memory (3.13.0): Extracting archive
  - Installing yireo/magento2-replace-tools (1.0.5): Extracting archive
Package laminas/laminas-zendframework-bridge is abandoned, you should avoid using it. No replacement was suggested.
Package sebastian/phpcpd is abandoned, you should avoid using it. No replacement was suggested.
Generating autoload files
137 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
app@0897ff71b97a:~/magento2$ composer replace:bulk:add yireo/magento2-replace-bundled

                                                                                                                                                           
  [Composer\Downloader\TransportException]                                                                                                                 
  The "https://repo.magento.com/packages.json" file could not be downloaded (HTTP/2 404 ):                                                                 
  {"warning":"You haven\u0027t provided your Magento authentication keys. For instructions, visit https:\/\/devdocs.magento.com\/guides\/v2.3\/install-gd  
  e\/prereq\/connect-auth.html"}                                                                                                                           
                                                                                                                                                           

replace:bulk:add <package>

Another update:
I updated composer to version 2.7.1 (was 2.2.21).
Error with composer 2.2.21

app@0897ff71b97a:~/magento2$ composer replace:bulk:add yireo/magento2-replace-bundled

                                                                                                                                                           
  [Composer\Downloader\TransportException]                                                                                                                 
  The "https://repo.magento.com/packages.json" file could not be downloaded (HTTP/2 404 ):                                                                 
  {"warning":"You haven\u0027t provided your Magento authentication keys. For instructions, visit https:\/\/devdocs.magento.com\/guides\/v2.3\/install-gd  
  e\/prereq\/connect-auth.html"}    

Now with composer version 2.7.1 :

app@0897ff71b97a:~/magento2$ composer replace:bulk:add yireo/magento2-replace-bundled
PHP Fatal error:  Declaration of Magento\ComposerRootUpdatePlugin\Plugin\Commands\OverrideRequireCommand::execute(Symfony\Component\Console\Input\InputInterface $input, Symfony\Component\Console\Output\OutputInterface $output) must be compatible with Composer\Command\RequireCommand::execute(Symfony\Component\Console\Input\InputInterface $input, Symfony\Component\Console\Output\OutputInterface $output): int in /data/web/magento2/vendor/magento/composer-root-update-plugin/Plugin/Commands/OverrideRequireCommand.php on line 173

Fatal error: Declaration of Magento\ComposerRootUpdatePlugin\Plugin\Commands\OverrideRequireCommand::execute(Symfony\Component\Console\Input\InputInterface $input, Symfony\Component\Console\Output\OutputInterface $output) must be compatible with Composer\Command\RequireCommand::execute(Symfony\Component\Console\Input\InputInterface $input, Symfony\Component\Console\Output\OutputInterface $output): int in /data/web/magento2/vendor/magento/composer-root-update-plugin/Plugin/Commands/OverrideRequireCommand.php on line 173    

As of yet, the last issue described is an issue with Symfony in Magento being of a different version than Symfony in composer. This either means that Symfony in Magento needs to be down-/ or upgraded or that Symfony in composer needs to be down-/ or upgraded. I've done this repeatedly in the past with various projects, but all of those cases were unrelated to these composer replace tools, so therefore I have to label this as a more general support request instead of an issue with this specific repository.

To clean things up, I'm closing this issue. Feel free to open a new ticket if another issue (or error message) pops up. Issues should be small and readable and I have to admit I lost oversight of which issue was popping up where and when in your environment.