Fixing magento issues

How to fix “Required parameter ‘theme_dir’ was not passed” in Magento 2

Pinterest LinkedIn Tumblr

Recently, one of my client encountered the error Required parameter ‘theme_dir’ was not passed on his Magento 2 website and he asked me how to fix this issue. After digging into the problem, I found out that this is not a rare issue. Many Magento 2 user are facing this error and don’t know how to resolve it

The error may happen when you try to save product in Magento 2 admin, the error message displays right here:

Required parameter 'theme_dir' was not passed

In this tutorial, I will explain the cause of this error and all working solution to fix it

It’s highly recommended to put Magento 2 in maintenance mode before working with the fix

Cause of the error

The error happens when you remove a theme folder of Magento 2 in app/design/frontend/<Vendor>/ <theme-name>, but not remove theme data from database.

Magento 2 will throw this error when it found theme in database, but couldn’t find theme folder as you had deteled it.

You may also see this error if theme folder’s name is not the same as theme name in database (usually happens when you change folder’s name)

Now we will have 3 solution to completely fix this error

Solution 1: Update current theme in Admin

This solution works perfectly in case you installed a new theme but Magento 2 is using your removed theme

In Magento 2 admin section, go to: Content => Design => Configuration

step 1 change theme

Next, select the default store view to edit Design Configuration, select the theme you are using on your store and click on Save Configuration

step 2 change theme

Finally, flush cache to update

Solution 2

In case the 1st solution does not resolve the issue on your website, we will need to remove theme entry from database.

You can do this either using PHPmyadmin or using CLI command

Remove theme from database using phpmyadmin

If you have PHPmyadmin install on your server => Login to phpmyadmin tool using your Magento 2 database username and password (in case you don’t remember, open database configuration file located in app/etc/env.php using any text editor to retrieve database information:

  array (
        'host' => 'localhost',
        'dbname' => 'database_name',
        'username' => 'database_username',
        'password' => 'database_password',
        'active' => '1',
      ),

In this example, the login is: database_username and password is database_password

After you logged into phpymadmin, find theme table and delete the record in the table “Theme” corresponding to the deleted theme folders.

 

theme table magento 2

Or if you don’t want to remove the record, you can set theme type to 1 = virtual to stop using the theme in database. type 0 = physical theme

theme type virtual physical

Finally, save changes

Remove theme from database using MYSQL command

Connect to your server using ssh protocol and use this syntax to remove theme entry from database

mysql -u <dbuser> -p -e "delete from <dbname>.theme where theme_path ='<Vendorname>/<themename>' AND area ='frontend' limit 1"

Replace the following information

  • <dbuser>: your Magento database username
  • <dbname>: your Magento database name
  • <Vendor>/<theme>: relative path to the theme directory, for example Magentip/theme1

Solution 3: Remove theme using Magento 2 CLI

Magento 2 also provides a CLI for uninstalling theme if you install Magento 2 using composer (refer here)

Use this syntax to remove theme from Magento 2 properly

bin/magento theme:uninstall --clear-static-content frontend/Magento/blank
  • {theme path} is the path to the Magento 2 theme you want to uninstall, eg: frontend/Magento/blank.
  • --clear-static-content this syntax is used to remove static view files, to make static view files display properly in frontend

Finally, flush cache and refresh your website to see changes

php bin/magento cache:flush

Avoid this error in the future

As you can see from the tutorial, the best way to avoid error: “Required parameter ‘theme_dir’ was not passed” in Magento 2  to remove a Magento 2 in a proper way (using Magento 2 CLI composer as described in Solution 3)

In case you do not install Magento 2 using composer, always remember to remove/update theme table in Magento 2 database.

If you followed my solutions but still can’t not fix the error, please drop a comment below and I will try my best to help you resolve the issue.

Hung Tran is the main editor of magentip.com, he loves to write about everything related to Magento 2

4 Comments

  1. Thank you, the solution 2 worked like a charm. I forgot to remove theme data from database, after using Mysql syntax to remove it now the error Required parameter ‘theme_dir’ was not passed is fixed.

    • still not solve the problem, I have tried all solutions you provide. but not work any solution.

      • Hi,
        I had the same problem : I’ve removed the vendor directory and made a ‘composer install’ and the problem was solved.

Write A Comment