Question

What is the error message:

Required parameter 'theme_dir' was not passed

Is it related to in Magento 2? And how can this problem be fixed?

Was it helpful?

Solution 2

This error message means that you have a theme configured which doesn't exist on the file-system (any more).

It can be easily fixed by selecting a valid theme instead. Go to Content -> Configuration, select the scope (global, website, store_view) and change the theme. After you've done that you should also remove it from Content -> Themes.

change theme for store

References

OTHER TIPS

Just in case if you are removing theme directly(Not in Magento way).

Then follow these steps.

STEP 1 : File Operations

Delete the content from app/design/frontend/<Vendor> (make sure you back it up first).

Delete all the content of folder var/view_preprocessed & pub/static/frontend.

rm -rf var/view_preprocessed/* pub/static/frontend/*

STEP 2 : DB Operations

Go to your theme table and delete the entry for your created theme.

After that...

Go to your core_config_data table and search the column path for design/theme/theme_id

SELECT * FROM core_config_data WHERE path = "design/theme/theme_id"

and replace your default theme id in it.

STEP 3 : Flush cache

Flush your cache php bin/magento cache:flush

It is very important that you follow all the steps first before trying to change the design in the backend! Otherwise it won't work.

Let me know if you still face any problems after that.

In my case I deleted a child theme from Vendor directory. But the DB entry was still there in theme table. So go to the theme table and delete the record that points to deleted theme.

This problem can also occur when you're in an emulated state, for example in a CLI command. I had a situation where I could not send an e-mail in the CLI, because the wrapping command was running in an emulated state:

$this->appState->emulateAreaCode(AppArea::AREA_GLOBAL, function() {
    // In this section the email was sent
});

In the above example, when the e-mail was trying to determine it's template dir, it would map to global/Magento/backend, which is non-existent. To fix this, I had to manually add it in my constructor:

/** @var \Magento\Framework\Component\ComponentRegistrarInterface $componentRegistrar */
// Make the admin theme global accessible for sending e-mails:
\Magento\Framework\Component\ComponentRegistrar::register(
    'theme',
    'global/Magento/backend',
    $componentRegistrar->getPath('theme', 'adminhtml/Magento/backend')
);

After this fix, the issue was solved and I could send the e-mail.

Update:

When it comes to sending mail using the CLI, a more proper approach would be to use emulation. For example:

/** @var Magento\Framework\App\State $state */
$state->emulateAreaCode(
    'frontend',
    [$this->accountManagement, 'initiatePasswordReset'],
    [
        $customer->getEmail(),
        AccountManagement::EMAIL_REMINDER,
        $customer->getWebsiteId()
    ]
);

This way you don't have to your dirty little hacks.

Make sure theme table entry & magento\app\design\frontend\<Vendor> Entry will be same.

If not it causes this issue.

Remove unnecessary theme via Admin -> Content -> Design -> Themes. Delete It. So it will remove DB Entry as well.

If u only remove folder then it will not work

run sql UPDATE core_config_data SET value=NULL WHERE path='design/theme/theme_id'

then clear the pub/static/frontend, var/view_preprocessing, var/cache, var/page_cache directories.

@hakre is correct. I got the same error Required parameter 'theme_dir' was not passed. Below I explain what I did to cause the error:

I creating a theme in app/design/frontend/MyVendorTheme2/myThemeName2 directory, and then configured it by selecting the theme "MyVendorTheme2 - myThemeName2" in the Magento 2 Admin browser (Stores > Configuration > THEME SETTINGS > GENERAL > Design > Design Theme). But I then decided to move the "myThemeName2" directory (containing my new theme) to be under a different (existing) vendor folder "MyVendorTheme1" app/design/frontend/MyVendorTheme1/myThemeName2, and removed it from the "MyVendorTheme2" folder where it was before. I proceeded to compile assets (i.e. grunt clean, grunt exec:myThemeName2, grunt less:myThemeName2), and then opened my browser at my theme subdomain (i.e. http://myvirtualhostdomain:myport/myvendortheme1_mythemename2_magento2_quickstart/).

Initially I got an unspecified error: There has been an error processing your request Exception printing is disabled by default for security reasons. Error log record number:

I enabled error reporting by renaming pub/errors/local.xml.sample to local.xml, and refreshed the page. I was then presented with the error Required parameter 'theme_dir' was not passed.

I resolved the error by going back into my Magento 2 Admin browser (Stores > Configuration > THEME SETTINGS > GENERAL > Design > Design Theme), which had my previous and now invalid design theme selected, so I chose the correct one.

This error happened to me when saving product images after installing a custom theme.

I had the custom theme that was set as a virtual type, that is in the DB in theme table, type = 1. In my case I wasn't using the theme anymore so I deleted it from the table.

I know this question is quite old, but since I ran into this just today and quickly found out what my problem was, I decided to post my answer as a reminder for all of those that, like me, use PhpStorm to work with Magento: remember to check out your files when switching branches.

In my case, the branch that I was working on didn't had the required theme files (they got stashed by PhpStorm when I changed from the theme branch to the master branch) because they hasn't been merged on it yet, thus the error.

Hope this might help someone.

Go to your core_config_data table and search for theme and you will get path record like

design/theme/theme_id

replace your default theme id in it. Also flush cache after that.

I had such problem in my cron and CLI command. I was trying to create order and invoice programmatically with sending email to the customer. The solution for this is emulating correct area:

$this->appState->emulateAreaCode(\Magento\Framework\App\Area::AREA_FRONTEND, function() {});

It works well with frontend area.

This error happens when you change/remove a theme folder but did not remove theme from database. I follow this tutorial and successfully fix this issue

To fix this error, you can update theme data in database, remove entry or update path using this command

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

Replace the following information

  • dbuser: database username

  • dbname: database name

  • Vendor/theme: path to the theme directory, for example
    Magentip/theme1

You can also uninstall theme properly using Magento 2 CLI

bin/magento theme:uninstall --clear-static-content frontend/Magento/blank

1 - Use the command below to identify the themes in the admin panel.

n98-magerun2 dev:theme:list

2 - Run the command to identify the installed themes:

ls -lha app/design/frontend/MyThemePackage/

3- Run these commands below to create the theme that doesn't exist:

n98-magerun2 deploy:mode:set developer
n98-magerun2 dev:console
make:theme frontend MyThemePackage MyThemeName

Or run this command to uninstall the theme that doesn't exist.

bin/magento theme:uninstall --clear-static-content frontend/MyThemePackage/MyThemeName

If nothing has worked, don't forget to check the categories section. There is a design settings there too. Make sure that the correct design theme is assigned. In my case, I was getting the error only on some categories.

When you are adding or editing product then Go to Design section and change layout option.

enter image description here

You can remove the unused theme from DB directly by executing this below query:

delete from theme where theme_path in ('unusedtheme');

whene unusedtheme is the unused theme, and after you will clena your cache

I had this issue when i removed by accident app/desing/adminhtml/theme-name folder. Bringing it back resolved my issue. Moreover it only occured when i tried to enter Admin Panel.

In some cases you delete custom theme in-proper way then you will also face this error. In this situation:

1) you have to delete that entry/row from 'theme' table.
2) set value 1 (1 for blank theme 2 for Luma what ever you want to set) against 'design/theme/theme_id'

Refresh the page error gone.

I resolved the issue. In my case the problem was not Magento2 but a wrong operation I did time ago as follow: I created a theme creating the relative path in app/design/frontend/MyFolder/MyTheme and registered it as explained in Magento 2 online documentation. Then I decided to cancel the theme and instead to use the appropriate command: bin/magento theme:uninstall frontend/MyFolder/MyTheme I deleted the folders directly. This is not a good operation as the database is not updated with the due information. Solution: with an editor of database as phpmyadmin, delete the record in the table "Theme" corrisponding to the deleted folders. I hope this will help!

rm -rf var/cache/*
rm -rf var/view_preprocessed/
rm -rf generated/*
rm -rf pub/static/*
sudo chmod -R 777 .

it should help.

This happened to me when I was emulating the Crontab area code for a specific email-sending job during testing (which is what I want to emulate since it is a cron job).

Look at the following (abbreviated) stack trace of 2.3.3:

This was trying to resolve the $componentName of crontab/Magento/theme-blank (which doesn't exist). I solved this by emulating the frontend (since that is where my email should be emulated from).

<?php

use Magento\Framework\App\Area;
use Magento\Framework\App\State;


// ...

/** @var State */
private $state;

// ...

$this->state->emulateAreaCode(Area::AREA_FRONTEND, function () {
    // This includes my logic that was causing the exception.
})

delete all the theme temporary files which is not using on website and delete also from the theme which is not using and run cache:flush

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top