30

I'm trying to run composer install on a cakephp installation, however it asks the user if they want to they want to set folder permissions:

Note, this is an example. In production the composer install command will happen automatically via CI or whatever:

John:$ composer install
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Nothing to install or update
Generating autoload files
> Cake\Composer\Installer\PluginInstaller::postAutoloadDump
> App\Console\Installer::postInstall
Set Folder Permissions ? (Default to Y) [Y,n]?

This is great, but there are times where I want to specify 'yes' from the command line so that my docker install doesn't require interaction, and so that our deployment process can work (there is no user involved!) I've tried several things, inspected the code and googled like mad to no avail.

I'm guessing there's an environment variable I can set to make it default to yes / quiet, but I just can't find what it is.

Loek
  • 4,037
  • 19
  • 35
John Hunt
  • 4,265
  • 8
  • 45
  • 59

2 Answers2

60

Try composer install --no-interaction or composer install -n

According to the documentation this triggers Composer to pick the default option whenever an interactive action is necessary:

--no-interaction (-n): Do not ask any interactive question.
Loek
  • 4,037
  • 19
  • 35
  • 8
    In my case default is "no" and operation fails? Is there a way to select "yes" automatically? – MilanG Mar 11 '19 at 13:35
  • `composer install --no-scripts` comes to mind. It will probably skip steps that are important for you though. Doesn't `composer install -y` work? – Loek Mar 12 '19 at 07:57
  • 1
    if default is Yes, how to set No as an answer? – famas23 Dec 05 '21 at 16:25
9

As stated in the previous answers --no-interaction or -n parameter is the official way to disable the regular user interaction on all composer commands. For more information check the available global options: https://getcomposer.org/doc/03-cli.md#global-options

However, Composer sometimes asks for questions that need an answer. For instance:

composer update

...

In GitDownloader.php line 112:
                                                                                                                                   
The .git directory is missing from ..., see https://getcomposer.org/commit-deps for more information

In these cases, if the --no-interaction parameter is specified, then Composer fails with an error.

To avoid the --no-interaction error, the yes command to the rescue:

yes | composer update
Anibal Sanchez
  • 494
  • 1
  • 7
  • 11