bin/magento Deleted When Upgrading to Magento 2.2.0 Using Composer – How to Fix

magento2

I am tying to upgrade a Magento 2.1 site to Magento 2.2.0 but it seems to be dropping out during the process and the bin/magento file is removed but not replaced so nothing at all works after this.

I am using these commands:

cd /var/www/html
bin/magento maintenance:enable
composer require magento/product-community-edition 2.2.0 --no-update  
composer update

It seems to work nicely upgrading all the files but then it seems to stop (as if it has actually finished) but I get the following and the file bin/magento has completely gone.

I am definitely using the same user account to do the upgrade as was used to install Magento so I don’t think it’s a permissions problem.

 ....truncated lots of updates....
 - Removing theseer/fdomdocument (1.6.5)
 - Installing theseer/fdomdocument (1.6.6)
 Downloading: 100%         

 zendframework/zend-session suggests installing mongodb/mongodb (If you want to use the MongoDB session save handler)
 zendframework/zend-session suggests installing zendframework/zend-cache (Zend\Cache component)
 paragonie/random_compat suggests installing ext-libsodium (Provides a modern crypto API that can be used to generate random bytes.)
 zendframework/zend-captcha suggests installing zendframework/zend-i18n-resources (Translations of captcha messages)
 zendframework/zend-captcha suggests installing zendframework/zendservice-recaptcha (ZendService\ReCaptcha component)
 ramsey/uuid suggests installing ircmaxell/random-lib (Provides RandomLib for use with the RandomLibAdapter)
 ramsey/uuid suggests installing ext-libsodium (Provides the PECL libsodium extension for use with the SodiumRandomGenerator)
 ramsey/uuid suggests installing ext-uuid (Provides the PECL UUID extension for use with the PeclUuidTimeGenerator and PeclUuidRandomGenerator)
 ramsey/uuid suggests installing moontoast/math (Provides support for converting UUID to 128-bit integer (in string form).)
 ramsey/uuid suggests installing ramsey/uuid-doctrine (Allows the use of Ramsey\Uuid\Uuid as Doctrine field type.)
 ramsey/uuid suggests installing ramsey/uuid-console (A console application for generating UUIDs with ramsey/uuid)
 Package fabpot/php-cs-fixer is abandoned, you should avoid using it. Use friendsofphp/php-cs-fixer instead.
 Writing lock file
 Generating autoload files
 File doesn't exist: bin/magento
 Check "chmod" section in composer.json of magento/magento2-base package.

Best Answer

I had the same problem.

It seems to be some kind of configuration error or some composer related issue. There is a trace of the same issue on the Magento Forum and on Magento2 Github Issue tracker.

There is a solution suggested by a Magento2 contributor here (for Enterprise Edition): https://github.com/magento/magento2/issues/4792#issuecomment-352069899

It seems that running:

composer clear-cache
composer update

would restore all eventually removed files. But it didn't work for me :-|

What I did to solve the issue was to downgrade and upgrade again.

Be very careful with filesystem permissions, you should always follow the official documentation at http://devdocs.magento.com/guides/v2.0/install-gde/prereq/file-system-perms.html

Related Topic