Required parameter ‘theme_dir’ was not passed: How to fix this issue in Magento 2

Required parameter ‘theme_dir’ was not passed error is caused by corrupted theme files.  Such errors may occur when you have “virtual” themes instead of “normal”. Also, this message sometimes appears during the upgrade. Many shop owners are facing this error and don’t know how to deal with it. In this tutorial, Magesolution will explain to you the nature of the error and certainly,  all working solutions to deal with these issues.

Cause of the error: Required parameter ‘theme_dir’ was not passed

Required parameter 'theme_dir'

This error appears when you remove a template folder, which is still referenced in the database. You’ll see this message.

There are some reasons behind the” Required parameter ‘theme_dir’ was not passed ” error message which is:

  • The error appears when you remove a theme folder of Magento 2 in app/design/frontend// but do not remove theme data from the database.
  • The error message can happen on a journey when you’re updating a theme in the incorrect way. Also, till you didn’t enable maintenance mode on your Magento 2 website, Magento could change your theme to Virtual.
  • When changing the appearance of a website,  you might want to override a theme or completely remove it. Most Magento users delete all the files in the wrong way. They delete theme folders straight from the app/design or vendor/ directory. However, there is a separate entry for your template in the Magento database table. Therefore, there are still some points related to the template left in the database. And this is the most frequent case when the “Required parameter ‘theme_dir’ was not passed” error appears.

How to remove the theme from Magento 2?

You have to remove a theme through a separate uninstall command. Magento supports you with step-by-step instructions to delete them from the system. Besides using the bin/magento theme: uninstall command, you can also easily remove the theme record from the database table “theme”. It will be useful in case you already deleted the directory structure. Lastly, everything will be fine. Moreover, keep in mind that the theme in the Magento database is marked as virtual even if you have recovered and deleted everything. Therefore, if you want to fix the “Required parameter ‘theme_dir’ was not passed” error,  you are gonna make changes only in the database.

Read more:

Magento invalid form key. please refresh the page: How to solve this error in Magento 2

pdo_mysql extension is not installed: How to fix this issue in Magento 2

How to solve the Required parameter ‘theme_dir’ was not passed error

passed error

There are 3 ways to completely resolve this common Magento 2 error, let us mention them here…

Method 1

If your theme files are in place with full web server read access, but the error still appears, please follow these steps:

  • Move to PhpMyAdmin > Your Magento2 database
  • Find the “theme” table
  • Set up your theme type to ‘0’ (Physical theme) (Or remove the record)
  • Save the changes

Method 2

Magento 2 also coma CLI for uninstalling themes if you install Magento 2 using composer

Use this command  to remove the theme from Magento 2

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

At last, you flush cache and refresh your Magento 2 site to see changes

php bin/magento cache:flush

Method 3

You can perform this task by  either using PHPmyadmin or using the CLI command

1. Remove theme from database using PHPMyAdmin

If you have PHPmyadmin installed on your server, so you need to login to the PHPMyAdmin tool using your Magento 2 database username and password (if you don’t remember, open the database configuration file located in app/etc/env.php using any text editor to get back database data:

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 PHPMyAdmin, find the theme table and delete the record in the table “Theme” corresponding to the deleted theme folders.

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

Lastly, you remember to save changes

2. Remove theme from database using MYSQL command

Connect to your server using the ssh protocol and run the command to remove theme entry from the database

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

Replace the below information

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

Conclusion

That’s all about the Required parameter ‘theme_dir’ was not passed the message and how to fix this issue in Magento 2.  We hope you find it helpful and in case you face any difficulties. Contact us and we will definitely support you with our Magento Website Development service.