magento2: 2.3.2 installed and bin/magento setup:upgrade not working

Preconditions (*)

  1. Version 2.3.1 upgraded to Version 2.3.2

Steps to reproduce (*)

  1. I had 2.3.1 installed and working for last couple months
  2. I did composer update - all was still well
  3. I ran composer to update to version 2.3.2 composer require magento/product-community-edition:~2.3.2 --no-update
  4. I then tried to fun my flush.sh which does:

bin/magento setup:upgrade bin/magento setup:di:compile bin/magento setup:static-content:deploy -f bin/magento indexer:reindex bin/magento cache:flush

Expected result (*)

  1. I expected the above commands to run properly and for the site to be functioning on 2.3.2.

Actual result (*)

  1. The site is still running, but I get this warning on screen:
Warning: Use of undefined constant SODIUM_CRYPTO_PWHASH_ALG_ARGON2ID13 - assumed 'SODIUM_CRYPTO_PWHASH_ALG_ARGON2ID13' (this will throw an Error in a future version of PHP) in /var/www/html/vendor/magento/framework/Encryption/Encryptor.php on line 153
  1. When I ran my flush.sh script, I get the following errors:
bin/magento setup:upgrade

                                                           
  There are no commands defined in the "setup" namespace.  
                                                           

bin/magento setup:di:compile

                                                              
  There are no commands defined in the "setup:di" namespace.  
                                                              

bin/magento setup:static-content:deploy -f

                                                                          
  There are no commands defined in the "setup:static-content" namespace.  
                                                                          

bin/magento indexer:reindex

                                                             
  There are no commands defined in the "indexer" namespace.  
                                                             

bin/magento cache:flush

                                                           
  There are no commands defined in the "cache" namespace.  
                                                           
                                                                 

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 6
  • Comments: 28 (16 by maintainers)

Commits related to this issue

Most upvoted comments

Cloud Users - You can use this patch on 2.3.2 to fix this issue without waiting on a support ticket.

diff --git a/vendor/magento/framework/Encryption/Encryptor.php b/vendor/magento/framework/Encryption/Encryptor.php
index 4bc1b2589362..4bb4bba9d11f 100644
--- a/vendor/magento/framework/Encryption/Encryptor.php
+++ b/vendor/magento/framework/Encryption/Encryptor.php
@@ -162,7 +162,7 @@ public function __construct(
      */
     public function getLatestHashVersion(): int
     {
-        if (extension_loaded('sodium')) {
+        if (extension_loaded('sodium') && defined('SODIUM_CRYPTO_PWHASH_ALG_ARGON2ID13')) {
             return self::HASH_VERSION_ARGON2ID13;
         }
 

Note that there is a more “official” way to get the updated libsodium-dev package on debian.

Docker steps:

  • Add the backports repo to source.list:
RUN echo "deb http://deb.debian.org/debian stretch-backports main" >> /etc/apt/sources.list
  • Update the repo sources and install that package from the backports repo:
RUN apt-get update && apt-get -t stretch-backports install -y libsodium-dev
  • Then install the sodium PHP extension:
RUN docker-php-ext-install sodium

UPDATE: I noticed there is an issue with the PHP 7.1 docker image not working with the above. In this case, you can also use PECL to install the PHP extension and enable it manually with:

RUN pecl install -f libsodium-1.0.17 \
  && echo "extension=sodium.so" > /usr/local/etc/php/conf.d/sodium.ini

I had the following problem in a gitlab ci runner during deployment:

bin/magento setup:di:compile
                                                    
  There are no commands defined in the "setup:di" namespace.  

These 3 lines solved my problem (thank you @markshust):

RUN echo "deb http://deb.debian.org/debian stretch-backports main" >> /etc/apt/sources.list 

RUN apt-get update && apt-get -t stretch-backports install -y \
  libsodium-dev

RUN pecl install -f libsodium-1.0.17

see also https://github.com/markshust/docker-magento/blob/master/images/php/7.2/Dockerfile#L33-L38

I’ve prepared a PR, once 2.3-develop is updated with 2.3.2 I will submit it

Re-opening because @engcom-Charlie doesn’t seem to be reading all the comments 😃

@engcom-Charlie: try to run Magento 2.3.2 where php-sodium extension is installed but libsodium’s version is < 1.0.13

Hi @pmsteil. Thank you for your report. The issue has been fixed in magento/magento2#23866 by @matei in 2.3-develop branch Related commit(s):

The fix will be available with the upcoming 2.3.3 release.

The following docker snippet has worked for me:

USER root
RUN curl https://packages.sury.org/php/apt.gpg -o /etc/apt/trusted.gpg.d/php.gpg
RUN echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list
RUN rm -rf /var/lib/apt/lists/* && apt-get update
RUN apt-get install --yes libsodium-dev
RUN docker-php-ext-install sodium

hi @evs-xsarus thanks for help. Yesterday I talk with my hosting support, and then they gave me a new command line for running script. I don’t know if Magento script command was change for running setup upgrade and all command. And then, it works. This is the reply from my hosting, May be it will work for anyone who search and face a problem like I did.

Hi there, Instead of typing :

php scriptname

type:

/home/xxxxxxx/public_html/php scriptname

Please let us know if there is anything further we can do for you.

Best Regards

Note: xxxxxx is username your hosting. Example: command: php bin/magento setup:upgrade You have to type command: /home/myusername/public_html/php bin/magento setup:upgrade

It work for me. If still confuse, ask your hosting.

@cows-magento: according to the release notes I quoted above, you need at least version 1.0.13 of libsodium. So that might be the problem here.

Probably something like:

FROM debian:stretch-slim

RUN apt-get update && \
    apt-get install --yes \
	apt-transport-https \
	lsb-release \
	ca-certificates \
	wget && \
    wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg && \
    echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list && \
    apt-get update && \
    apt-get dist-upgrade --yes && \
    apt-get install --yes \
		php7.1-fpm \
		php-sodium

Demo:

$ docker run -it f928ee598772 /bin/bash
root@15bbb6fcd806:/# php -i | grep sodium
/etc/php/7.1/cli/conf.d/20-sodium.ini,
sodium
sodium support => enabled
sodium compiled version => 2.0.10
libsodium headers version => 1.0.16
libsodium library version => 1.0.17
root@15bbb6fcd806:/# php -a
Interactive mode enabled

php > echo SODIUM_CRYPTO_PWHASH_ALG_ARGON2ID13;
2

Takeaways:

  • Its the underlying system library that’s old
  • Debian (Stretch nor afaik backports) doesn’t package good versions
  • Sury does (https://deb.sury.org/)

(Worked out in conjunction with MageMojo Fam ♥ your mileage may vary)

@pmsteil: you’ll probably need to install the sodium php extension

It’s a bit annoying they haven’t added it to the dependencies in the composer.json file.


This is also mentioned in the release notes:

Issue: The security enhancements that are part of Magento 2.3.2 require the installation of libsodium version 1.0.13 or higher. You will not be able to successfully install Magento Commerce 2.3.2 without first ensuring that your server runs version 1.0.13 or higher. See Libsodium releases for a description of the available releases and installation instructions.

But apparently it is possible to install Magento 2.3.2 without libsodium? 😛

Didn’t try kanduvisla solution but this works for me with php 7.2

RUN curl -O https://download.libsodium.org/libsodium/releases/libsodium-1.0.18.tar.gz \
    && tar xfvz libsodium-1.0.18.tar.gz \
    && cd libsodium-1.0.18 \
    && ./configure \
    && make && make install \
    && pecl install -f libsodium

For those interested: none of the above solutions worked for me in my Docker setup. What eventually did work, was compiling libsodium manually:

RUN wget https://download.libsodium.org/libsodium/releases/LATEST.tar.gz
RUN tar xvzf LATEST.tar.gz
RUN cd libsodium-stable && \
    ./configure && \
    make && make check && \
    make install

RUN docker-php-ext-install sodium

Manual testing scenarios

  • Have a docker-compose.yml with a DB container with a 2.3.1 database and a FPM container based on php:7.2.4-fpm
  • On the FPM container , create a composer.json depending on Magento 2.3.2 (tested with magento/product-enterprise-edition but probably community has the same issue)
  • Ensure you have an env.php file with appropriate configuration for connectivity to the DB container
  • Run composer install
  • Run bin/magento setup:upgrade

Expected result: Magento DB should upgrade correctly Actual result: bin/magento fails with

 An abstract factory could not create an instance of magentosetupconsolecommandbackupcommand(alias: Magento\Setup\Console\Command\Back
  upCommand).


In ServiceManager.php line 941:

  An exception was raised while creating "Magento\Setup\Console\Command\BackupCommand"; no instance returned


In Di.php line 865:

  Missing instance/object for parameter maintenanceMode for Magento\Setup\Console\Command\BackupCommand::__construct


In ServiceManager.php line 1130:

  An abstract factory could not create an instance of magentoframeworkappmaintenancemode(alias: Magento\Framework\App\MaintenanceMode).


In ServiceManager.php line 941:

  An exception was raised while creating "Magento\Framework\App\MaintenanceMode"; no instance returned


In ErrorHandler.php line 61:

  Warning: Use of undefined constant SODIUM_CRYPTO_PWHASH_ALG_ARGON2ID13 - assumed 'SODIUM_CRYPTO_PWHASH_ALG_ARGON2ID13' (this will thr
  ow an Error in a future version of PHP) in /var/www/html/vendor/magento/framework/Encryption/Encryptor.php on line 153

@cows-magento: according to the release notes I quoted above, you need at least version 1.0.13 of libsodium. So that might be the problem here.

@hostep I am running docker on latest php7.2.19 and it installs version 1.0.11 by default https://github.com/docker-library/php/blob/a9f19e9df5f7a5b74d72a97439ca5b77b87faa35/7.2/stretch/fpm/Dockerfile

do you have any idea how to force an update by default?

@hostep thanks! Any clues as to how to install these two from the command line on macos/linux? Thanks!