How to fix the «The "https://repo.magento.com/packages.json" file could not be downloaded: allow_url_fopen must be enabled in php.ini» issue?

To fix this issue, you should do exactly that the system says: enable the allow_url_fopen option in your command-line PHP interpreter.

You can check whether the allow_url_fopen is enabled by executing the following command in the root Magento 2 folder:

php -i | grep allow_url_fopen

Similar issues:

See also:

Using php -d allow_url_fopen=on allows a person to override php.ini. Then the full path to composer needs to be explicitly added…

Example:
# php -d allow_url_fopen=on /opt/bin/composer update

Adding this here for next person who Google’s their way here.