How to Troubleshoot Upgrade Issues in Magento 2

Magento 2 export CLI

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

'

“We can’t take that action right now” Error

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:

  1. Go to the Magento Marketplace and log in to your account. 
  2. Find your account name in the top-right section of the page. Select My Profile there.
  3. Next, find the Marketplace tab and click Access Keys.
  4. Now, you can create new access keys. Click the corresponding button.
  5. 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.

For further information on how to generate new keys in Magento 2, follow this link: Get your authentication keys.

The updater application isn’t initialized

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:

  1. You have to be logged in to your Magento server as the file system owner.
  2. Go to your Magento installation directory.
  3. Back up the existing composer.json with the help of the following command:

  4. Now, when a safe copy of composer.json exists, open the original file in a text editor.
  5. 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:

  6. Now, when these changes are applied, you can save your composer.json file and exit the editor.
  7. 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:

  1. Log in to your Magento server as a file system owner.
  2. Save your composer.json file since the following steps will overwrite it:

  3. Now, you can update your local repository to the latest version:

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:

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:

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:

For Windows, use this one:

After these changes are applied, continue where you left off with the update.

For further information, follow these links: Update the Magento application & Git pull origin develop fails.

How to roll back after the update failure

Now, let’s discuss how to roll back when the Magento 2 upgrade fails. A message similar to the following one occurs in the Console Log:

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.

Read this troubleshooting guide for further reference: How to Troubleshoot Upgrade Issues in Magento 2.

'