In the following article, we discuss various issues that occur when you try to upgrade Magento 2. If you want to find more tips on how to address multiple problems that take place when you run your e-commerce store, check our Developer’s Cookbook. Now, let’s find out how to troubleshoot Magento 2 upgrade challenges.
Let’s assume that you want to upgrade your Magento 2 installation. Outdated software is no longer safe and reliable, so you need to take action to avoid possible issues associated with its vulnerabilities. Furthermore, you may want to get new features represented in the latest update.
You proceed to the System Upgrade page, and nothing happens. Only the following error displays when you start the upgrade:
“Sorry, we can’t take that action right now”
However, there is no cause for concern. Although the error doesn’t let you get what you need at the moment, you can effortlessly troubleshoot the corresponding upgrade issue. Below, we explore three possible cases that describe the reason for the problem and its resolution.
You’re not authenticated
You cannot upgrade your Magento website if you are not authenticated. It is the most common reason for the “Sorry, we can’t take that action right now” error. If you haven’t entered your authentication keys in the Magento admin, the system won’t let you apply any changes. How to troubleshoot this upgrade issue in Magento 2?
You just need to enter your authentication keys in the backend section of your Magento 2 website and retry to run the upgrade process.
Chances are, it won’t help. However, there is another way to run the upgrade successfully. It would help if you generated new authentication keys:
Find your account name in the top-right section of the page. Select My Profile there.
Next, find the Marketplace tab and click Access Keys.
Now, you can create new access keys. Click the corresponding button.
Specify a specific name for the keys. Confirm the action.
That’s it! You’ve just generated new public and private keys. Note that the Public key is your username, while the Private key is your password. Go to the Magento admin, reenter the new credentials and try to upgrade your Magento 2 store once again.
In some cases, the error occurs when the updater application is not initialized. It usually happens when the Magento software originates from packagist. If the https://repo.magento.com repository is not specified in the composer create-project command, you face the trouble.
Also, note that the updater application runs upon cron. If you run the upgrade and cron is not initialized, you fail to complete the procedure.
To solve this issue, you need to modify Magento’s composer.json. Bear in mind that it should reference the https://repo.magento.com repository.
Besides, it is necessary to run composer install in the updater’s root directory. You need to resolve dependencies and initialize it to address the “Sorry, we can’t take that action right now” issue. Follow these steps:
You have to be logged in to your Magento server as the file system owner.
Go to your Magento installation directory.
Back up the existing composer.json with the help of the following command:
cp composer.json composer.json.bak
Now, when a safe copy of composer.json exists, open the original file in a text editor.
Proceed to the repositories section and add the reference to the https://repo.magento.com repository:
For instance, the applied change may look as follows:
Now, when these changes are applied, you can save your composer.json file and exit the editor.
After that, it is necessary to change to the update subdirectory that contains the updater. Use the following command to achieve this goal:
When the command completes, try to re-upgrade the system. This time, the “Sorry, we can’t take that action right now” issue should not bother you. However, if it appears once again, there is another possible reason for it.
Cloned Magento GitHub repo
When the Magento software is installed by cloning the repository, the System Upgrade utility doesn’t work. You have to deal with it.
Instead, you can use git pull origin and composer update to run the upgrade:
Log in to your Magento server as a file system owner.
Save your composer.json file since the following steps will overwrite it:
cp composer.json composer.json.old
Now, you can update your local repository to the latest version:
git pull origin develop
After that, it is necessary to diff and merge your composer.json.old with composer.json installed with your Magento software:
Enter this command:
Now, you can upgrade your Magento database:
The final step requires cleaning the cache:
If the following error displays, follow the troubleshooting steps below:
error:Your local changes tothe following files would be overwritten by merge:
<list of files>
Tofind which files are subject tobeing overwritten,either read the message orenter:
If you intentionally modified files, you should resolve the conflicts manually. Ask for help here: GitHub help.
If you didn’t modify any files intentionally, try one of the solutions discussed below.
You’re confident that no files were modified. Also, you don’t mind removing or overwriting the changes in the Magento file system. In this case, the following command may help:
$git reset--hard HEAD&&git pull origin develop
After executing it, you can proceed to the step where you left off and rerun the update.
It is also recommended to use the GitHub configuration to prevent these errors. The default setting for storing content involves the operating system-default line ending characters. If your OS is Linux, but another collaborator uses Windows, GitHub turns the Windows line endings to the ones used in Linux to enable successful cloning or pulling. As a result, the appearance of a change to files occurs. However, no change is made.
You need to configure GitHub to ignore line endings. In your Git client, enter the following command:
$git config--system core.autocrlf false
For Windows, use this one:
$git config--system core.eol LF
After these changes are applied, continue where you left off with the update.
Click Rollback to restore the previous backup. Note that if you did not back up previously, Magento recovers your data. If there is no component version to which to roll back, you have to contact the component vendor. Alternatively, you may try to resolve the issue on your own account.