5

Context:

  • magento 2.1.7 community-edition
  • composer.phar 1.7.2
  • installed and setup on a development server
  • then deployed on a production server (dictinct from the previous)

All worked well, including frontend, products, orders, invoice... but we now required to update magento (at least 2.2.0):

  • ~/.composer/auth.json set up.
  • /home/web/www-preprod is magento root directory (and where composer.json and composer.phar resides)
  • composer.phar similar to the one used on the development server

Attempt 1: wizard

Stuck at "readiness check":

Check component Dependency
We found conflicting component dependencies

Attempt 2: CLI

Stuck at any composer update or composer require

php composer.phar update

Loading composer repositories with package information

[Composer\Downloader\TransportException]
The "https://repo.magento.com/packages.json" file could not be downloaded: failed to open stream: Connection refused


update [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--lock] [--no-custom-installers] [--no-autoloader] [--no-scripts] [--no-progress] [--no-suggest] [--with-dependencies] [--with-all-dependencies] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--ignore-platform-reqs] [--prefer-stable] [--prefer-lowest] [-i|--interactive] [--root-reqs] [--] []...


Diagnose

$ php composer.phar diagnose ; echo 'done'; grep wait 

Checking composer.json: WARNING
The version field is present, it is recommended to leave it out if the package is published on Packagist.
Defining autoload.psr-0 with an empty namespace prefix is a bad idea for performance
require.magento/product-community-edition : exact version constraints (2.1.7) should be avoided if the package follows semantic versioning
require.composer/composer : unbound version constraints (@alpha) should be avoided
Checking platform settings: WARNING
PHP was compiled with --enable-sigchild which can cause issues on some platforms.
Recompile it without this flag if possible, see also:
https://bugs.php.net/bug.php?id=22999

Checking git settings: OK
Checking http connectivity to packagist: WARNING
[Composer\Downloader\TransportException] The "http://repo.packagist.org/packages.json" file could not be downloaded: failed to open stream: Connection refused
Checking https connectivity to packagist: WARNING
[Composer\Downloader\TransportException] The "https://repo.packagist.org/packages.json" file could not be downloaded: failed to open stream: Connection refused
Checking github.com rate limit: OK
Checking disk free space: OK
Checking pubkeys: Tags Public Key Fingerprint: * Dev Public Key Fingerprint: * OK
Checking composer version: WARNING
You are not running the latest stable version, run composer self-update to update (1.7.2 => 1.8.0)
Composer version: 1.7.2
PHP version: 7.0.32
PHP binary path: /usr/local/php7.0/bin/php

The server cannot reach repo.packagist.org/packages.json through neither http nor https

update -vvv

$ php -f composer.phar update -vvv ; echo 'done'; grep wait
Reading ./composer.json
Loading config file /home/me/.composer/config.json
Loading config file /home/me/.composer/auth.json
Loading config file ./composer.json
Checked CA file /etc/ssl/certs/ca-certificates.crt: valid
Failed to initialize global composer: Composer could not find the config file: /home/me/.composer/composer.json
To initialize a project, please create a composer.json file as described in the https://getcomposer.org/ "Getting Started" section
Reading /home/web/www-preprod/vendor/composer/installed.json
Loading plugin MagentoHackathon\Composer\Magento\Plugin
activate magento plugin
Running 1.7.2 (2018-08-16 16:57:12) with PHP 7.0.32 on Linux / 4.14.66-ovh-vps-grsec-zfs-classid
Loading composer repositories with package information
Downloading https://repo.magento.com/packages.json
Downloading https://repo.magento.com/packages.json
Downloading https://repo.magento.com/packages.json

[Composer\Downloader\TransportException]
The "https://repo.magento.com/packages.json" file could not be downloaded: failed to open stream: Connection refused

Exception trace:
() at phar:///home/web/www-preprod/composer.phar/src/Composer/Util/RemoteFilesystem.php:547
Composer\Util\RemoteFilesystem->get() at phar:///home/web/www-preprod/composer.phar/src/Composer/Util/RemoteFilesystem.php:101
Composer\Util\RemoteFilesystem->getContents() at phar:///home/web/www-preprod/composer.phar/src/Composer/Repository/ComposerRepository.php:682
[... skip some lines for readability ...]
Symfony\Component\Console\Application->run() at phar:///home/web/www-preprod/composer.phar/src/Composer/Console/Application.php:103
Composer\Console\Application->run() at phar:///home/web/www-preprod/composer.phar/bin/composer:56
require() at /home/web/www-preprod/composer.phar:24

[...]

Lacking of any credentials, proxy or configuration error: did anyone had this error too? Googling did not show that specific error.

EDIT: Clue: auth.json

Following @sebastian 's comment, to be thorough:

  1. I renamed my /home/me/.composer/auth.json.and
  2. ran composer.phar global config http-basic.repo.magento.com <public_key> <private_key> to be sure
  3. that command regenerates the file in /home/me/.composer/
  4. retrying composer update the very same errors pops up (same stack with -vvv).

Other test: Even without any auth.json, the composer update -vvv ends up identical.

My best clue so far is a server limitation (blacklisted?), I am looking for: - a solution to run composer update on local .json (since I can wget them) - getting back the magento 2.1.7 on dev server, upgrading it from there and then re-uploading on prod server

EDIT: Follow-up on local .json

I managed to set composer.json repository to local:

"repositories": [ { "type": "path", "url": "/home/web/www-preprod/packages.json" } ], 

Composer update output:

Problem 1
- The requested package magento/product-community-edition 2.2.0 exists as magento/product-community-edition[2.1.7] but these are rejected by your constraint.


New attempt: set up composer.json by CLI

php composer.phar require magento/community-edition 2.2.0 --no-update 

./composer.json has been updated

php composer.phar update 

Loading composer repositories with package information
The "https://repo.packagist.org/packages.json" file could not be downloaded: failed to open stream: Connection refused
https://repo.packagist.org could not be fully loaded, package information was loaded from the local cache and may be out of date
Updating dependencies (including require-dev)


[Composer\Downloader\TransportException]
The "http://repo.packagist.org/p/ramsey/uuid%247189d3afa8232bcec2b8a64e5043b64b57616fd03b0280bd3e9995f5c32d50f8.json" file could not be downloaded: failed to
open stream: Connection refused
[...]

So... Now, how to get and setup local .json from repo.packagist.org?

2
  • Exploring stackoverflow.com/questions/52404280/… (the production server may have that kind of quirks). If that's the case, it is more a composer vs. network parameters than a magento-related issue Commented Dec 17, 2018 at 16:02
  • After several weeks, the problem is still there. In the meantime, we redeployed a copy updated on our computers. Commented Jan 14, 2019 at 10:38

1 Answer 1

0

u've added

... "repo.magento.com": { "username": "<YOUR-MAGENTO-PUBLIC-KEY>", "password": "<YOUR-MAGENTO-PRIVATE-KEY>" } ... to your ~/.composer/auth.json, right?

Your log tells me that the connection is refused for https://repo.magento.com/packages.json and not only repo.packagist.org/packages.json

The "https://repo.magento.com/packages.json" file could not be downloaded: failed to open stream: Connection refused

Have you tried to put the auth.json into the Mage dir or the http-auth credentials directly into composer.json?

What is the current work dir you're calling php composer.phar update ?

8
  • Hi sebastian, thanks for the advice, I edited the post: no success with the auth.json clue. Commented Dec 18, 2018 at 10:22
  • @nicolallias ok, have you tried a simple curl for that package http://repo.packagist.org/p/ramsey/uuid..json ? Setting up a packagist proxy may work with toran or satis.. but i don't think thats ur problem. Looks like there is a misconfiguration in composer.. What file do you mean with: /home/me/.composer/ Commented Dec 18, 2018 at 11:18
  • /home/me is the home folder of my unix user. /home/me/.composer is COMPOSER_HOME ; I indeed to plan to wget (or curl) every required files... I will keep you in touch ;) Commented Dec 18, 2018 at 13:33
  • Maybe you can show the content of your /home/me/.composer/auth.json and /home/me/.composer/composer.json? I'm confused about that u've got content in the /home/me/.composer/composer.json? :-D I would probably backup both files in /home/me/.composer, delete them, put the auth.json into Mage Root and do a fresh install by composer install (via composer.lock) not composer update. On prod environments i usallly use the --prefer-dist option for composer install Commented Dec 18, 2018 at 14:42
  • composer.json is in magento root directory (/home/web/www-preprod/), in which I launch every php -f composer.phar commands Commented Dec 18, 2018 at 15:51

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.