docker-magento: bin/download fails, unable to create config.json Permission Denied
Description Brand new Linux VM, Debian 10, with Docker + Docker-Compose.
Tried entering
curl -s https://raw.githubusercontent.com/markshust/docker-magento/master/lib/onelinesetup | bash -s -- magento.test 2.4.2
Failed with below.
Following https://github.com/markshust/docker-magento/blob/master/SETUP.md
Upon entering bin/download 2.3.4
Starting magento_elasticsearch_1 ... done
Starting magento_redis_1 ... done
Starting magento_db_1 ... done
Starting magento_rabbitmq_1 ... done
Creating magento_phpfpm_1 ... done
Creating magento_app_1 ... done
Composer authentication required (repo.magento.com public and private keys):
Username: <my public key>
Password: <my private key>
[ErrorException]
touch(): Unable to create file /var/www/.composer/config.json because Permission denied
config [-g|--global] [-e|--editor] [-a|--auth] [--unset] [-l|--list] [-f|--file FILE] [--absolute] [--] [<setting-key>] [<setting-value>]...
Composer auth has been setup.
Cannot create cache directory /var/www/.composer/cache/repo/https---repo.packagist.org/, or directory is not writable. Proceeding without cache
Cannot create cache directory /var/www/.composer/cache/files/, or directory is not writable. Proceeding without cache
Cannot create cache directory /var/www/.composer/cache/repo/https---repo.magento.com/, or directory is not writable. Proceeding without cache
Creating a "magento/project-community-edition=2.3.4" project at "./"
Warning from repo.magento.com: You haven't provided your Magento authentication keys. For instructions, visit https://devdocs.magento.com/guides/v2.3/install-gde/prereq/connect-auth.html
Warning from repo.magento.com: You haven't provided your Magento authentication keys. For instructions, visit https://devdocs.magento.com/guides/v2.3/install-gde/prereq/connect-auth.html
Warning from repo.magento.com: You haven't provided your Magento authentication keys. For instructions, visit https://devdocs.magento.com/guides/v2.3/install-gde/prereq/connect-auth.html
[Composer\Downloader\TransportException]
The 'https://repo.magento.com/packages.json' URL required authentication.
You must be using the interactive console to authenticate
create-project [-s|--stability STABILITY] [--prefer-source] [--prefer-dist] [--repository REPOSITORY] [--repository-url REPOSITORY-URL] [--add-repository] [--dev] [--no-dev] [--no-custom-installers] [--no-scripts] [--no-progress] [--no-secure-http] [--keep-vcs] [--remove-vcs] [--no-install] [--ignore-platform-reqs] [--] [<package>] [<directory>] [<version>]
Even tried creating /var/www/.composer/config.json and setting its perms to 777 (to test). Still fails.
Tried sudo bin/download 2.3.4 and it still fails. Tried it as root (last hope) and it fails.
Same result with bin/download and bin/download 2.3.0.
Steps To Reproduce See description.
Expected Result Successful install/setup
Actual Result Failed, see description
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 4
- Comments: 15 (5 by maintainers)
this happens because the ~/.composer folder owner is root. when copied to the container it still has the root owner
simple workaround is to run
./bin/root chown -R app:app /var/www/.composer/after the failed install and then run your one line install command againThanks for the comment @Hungnguyen999. It seems that many devs install Composer as root, but that is very wrong! Your command fixes it to be properly installed.
See https://getcomposer.org/doc/faqs/how-to-install-untrusted-packages-safely.md
bin/fixowns <- please remember this solved my 6h fighting with this problem…
@expertsnarensharma ok good to know this!
bin/fixowns: This will fix filesystem ownerships within the container. i have fixed this by running this docker command