New Symfony 3 installation: Could not open input file: app/console in composer install
Solution 1
The ScriptHandler
take the dir from the extra config key in the composer.json
files names as symfony-bin-dir
. So check that the composer contain the correct configuration key, as example:
composer.json
....
"extra": {
"symfony-app-dir": "app",
"symfony-bin-dir": "bin",
"symfony-var-dir": "var",
....
EDIT:
The problem was related to the cache of composer. It was solved clearing it with the command:
>php composer.phar clear-cache
Hope this helps.
Solution 2
Just create var
directory. After that composer install
and composer update
will work ok.
Explanation:
vendor/sensio/distribution-bundle/Composer/ScriptHandler.php:462
protected static function useNewDirectoryStructure(array $options)
{
return isset($options['symfony-var-dir']) && is_dir($options['symfony-var-dir']);
}
So you need both to have symfony-var-dir
in composer.json
's extra
and have this directory existing.
Solution 3
I have been running into the same problem. The script uses the existance of the var directory to decide whether to use the new directory structure or the old one. If var exists, the new directory structure is used. Otherwise it uses the old structure.
The default .gitignore file prevents both the var directory and the bin directory from being added to git.
What I did to solve the problem for me was to edit .gitignore in the project directory so that it looks like this:
/app/config/parameters.yml
/bin/*
/build/
/composer.phar
/vendor/
/web/bundles/
/var/*
!var/cache
/var/cache/*
!var/cache/.gitkeep
!var/logs
/var/logs/*
!var/logs/.gitkeep
!var/sessions
/var/sessions/*
!var/sessions/.gitkeep
!bin/console
!bin/symfony_requirements
/phpunit.xml
I do not pretend to be an expert on .gitignore, so I'm not sure that is the most elegant way of doing it, but it is what worked for me.
Solution 4
I had the same problem:
[RuntimeException]
An error occurred when executing the ""cache:clear --no-warmup"" command:
Could not open input file: app/console
My console file is in /bin/ folder too so I had to call this from root of project to clear the cache each time I clone the project from DevOps:
php bin/console cache:clear
Afterwards I can run composer install
and it works fine
Related videos on Youtube
cklm
Updated on September 04, 2022Comments
-
cklm over 1 year
I installed a fresh symfony3-instance via the official symfony-installer (http://symfony.com/download). After doing the first things, I commited the project to Git and cloned it the other day on another computer. After the cloning I ran "composer install" to install all the symfony-dependencies. Now comes the problem: The script
ScriptHandler::clearCache
stops with an error:Could not open input file: app/console
. Thats right - symfony3 has a new directory-structure - so theconsole
resides now in/bin
- not in/app
. How can I tell composer/the project to use the new structure instead of the old one?I read here (What is the new Symfony 3 directory structure?) about the console-command
SENSIOLABS_ENABLE_NEW_DIRECTORY_STRUCTURE=true
- but that doesn't work in my case.Any tips?
-
Matteo over 8 yearsHi @cklm possibly a problem related to the composer cache? Try removing the composer cache via the command
php composer.phar clear-cache
-
cklm over 8 yearsthanks a lot - clearing the composer-cache (why?!) solved my problem!
-
Eugen Mihailescu almost 8 yearsI can confirm: when
var
is missing => cannot open app/console in composer install. Creating thevar
did the trick for me. -
fnagel over 6 yearsDid the trick for me too. Experienced this after updating from 3.3 to 3.4 but I have no idea why, never happened before...