91

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?

3
  • i fixed this by changing permission of theme folder Jun 19, 2019 at 16:41
  • tried every solution, ended up reinstalling magento Oct 16, 2019 at 14:43
  • i had to create a local env (using MAMP) and found out i forgot to copy the themes from the remote site. After doing this, i re-compiled magento files using php bin/magento commands Oct 3, 2023 at 8:51

31 Answers 31

119

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.

8
  • Thanks. I had the same problem when I deleted a theme. Don't forget to delete the remnants left in the database. I did fix the theme-table, but forgot about the core_config_data value. Mar 14, 2017 at 10:48
  • @GielBerkers : Welcome :) Mar 14, 2017 at 11:07
  • @KaushalSuthar this didn't worked at all instead the admin went into text format. Then after running setup:static-content:deploy admin went back to UI. Oct 24, 2017 at 15:09
  • @AshwaniShukla : you might have made some mistake during the process... Oct 25, 2017 at 6:53
  • @KaushalSuthar the only mistake I made was pub/static/.htaccess was not there. thanks Nov 1, 2017 at 14:38
35

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

8
  • This can also be the case if your theme directory does not have the proper permissions. Sep 26, 2016 at 16:16
  • Permissions should be checked by some of the Magento scripts AFAIK, but you're right, this qualifies as the same: An inaccessible directory often behaves similar to a non-existing directory.
    – hakre
    Oct 1, 2016 at 8:08
  • 3
    This is no longer the place this is located. its in the content tab now.
    – CarComp
    Dec 5, 2016 at 15:24
  • @CarComp: Feel free to provide an updated screenshot and edit the answer. When I answered, it was as documented.
    – hakre
    Dec 5, 2016 at 15:37
  • @hakre, does not work. It still shows the error, even after switching to Magento Base.
    – Black
    Jan 28, 2020 at 16:51
14

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.

1
  • Thanks for sharing in this depth. This answer quite becomes a FAQ on it's own, very nice to see.
    – hakre
    Jan 8, 2018 at 21:14
13

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.

2
  • How did you delete from the vendor directory? With composer by composer remove vendor/theme ?
    – hakre
    Aug 22, 2016 at 6:37
  • No, just rm -rf vendor/theme
    – Arvind07
    Aug 22, 2016 at 7:16
8

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

7

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.

0
1

@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.

1
  • I get this error only when adding 'cache' for redis configuration to the env.php. Remove the changes, and it works fine. So why is it only when adding 'cache'? I checked the syntax of the array and it's fine. The same cache => value is working on my staging server (cut/pasted)
    – Scott
    May 30, 2018 at 10:54
1

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.

1

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.

1

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.

1

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.

1

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

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
1

Still facing the same issue when using this

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

Magento: 2.4.2

Is there anyone?

1
  • This is a question, not an answer.
    – Black
    Dec 19, 2022 at 15:33
1

This happend to me, the only thing i did was set to developer mode. I was 100% certain i had not removed theme files that were associated in the database. So i ran file and folder permissions

find . -type f -exec chmod 644 {} \;  &&
find . -type d -exec chmod 755 {} \; &&
find ./var -type d -exec chmod 777 {} \; &&
find ./pub/media -type d -exec chmod 777 {} \; &&
find ./pub/static -type d -exec chmod 777 {} \; &&
chmod 777 ./app/etc &&
chmod 644 ./app/etc/*.xml &&
chmod u+x bin/magento

clear cache and static content

rm -rf var/cache/* &&
rm -rf var/page_cache/* &&
rm -rf var/generation/* &&
rm -rf var/di var/generation &&
php bin/magento cache:flush &&
rm -rf /generated/* &&
rm -rf /pub/static/frontend/*

then forced re-delopy static content

php bin/magento setup:static-content:deploy -f

this fixed for my for my senario

0

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.

1
  • Could you please provide an example scenario where this issue might occur? The only one I can think of is if layout was changed to an option which only exists within a custom theme, then the theme is removed. But, if this were to occur whilst only using default layouts (or modified versions of the defaults, using the same name), then it surely implies a fault with the custom theme and not with the magento software itself?
    – Muckee
    Apr 22, 2018 at 14:42
0

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

enter image description here

0

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

0

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.

0

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.

0

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!

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

it should help.

0

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.
})
0

Another cause is php cache. Restarting php7.3-fpm worked for me.

0
$this->state->emulateAreaCode(Area::AREA_FRONTEND, function () {
// this should fix - Required parameter 'theme_dir' was not passed
   $this->designLoader->load(); \\Magento\Framework\View\DesignLoader
   ...
});
0

This means, theme is not available in system but its still selected as active theme from admin. You must go to admin and change the theme from admin.

Theme not available

FROM ADMIN

0

I found this caused by the layout did not load, indeed returning JSON and similar formats did not load layout

consider use

$this->getLayout()->getUpdate()->load()
1
0

The only way I could get it working again was to copy the theme and use a new name (update the name in registration.php and theme.xml), then select this new theme in the admin.

0

I had this because I was using some frontend description logic in admin generated email which required frontend template filters to be applied.

Unique scenario but this might help someone

use Magento\Cms\Model\Template\FilterProvider;
use Magento\Framework\App\State;
use Magento\Framework\View\Design\Theme\ThemeProviderInterface;
use Magento\Framework\View\DesignInterface;
use Magento\Store\Model\ScopeInterface;
use Magento\Framework\App\Config\ScopeConfigInterface;
 public function __construct(
        FilterProvider $filterProvider,
        State $appState,
        DesignInterface $design,
        ThemeProviderInterface $themeProvider,
        ScopeConfigInterface $scopeConfig
    ) {
        $this->filterProvider = $filterProvider;
        $this->appState = $appState;
        $this->design = $design;
        $this->themeProvider = $themeProvider;
        $this->scopeConfig = $scopeConfig;
    }
    $description = null;
    if ($storeStatus->getDescription()) {
        $this->appState->emulateAreaCode(
            \Magento\Framework\App\Area::AREA_FRONTEND,  
            function () use ($storeStatus, &$description) {
                $themeId = $this->scopeConfig->getValue(
                    'design/theme/theme_id',
                    \Magento\Store\Model\ScopeInterface::SCOPE_STORE
                );
                $theme = $this->themeProvider->getThemeById($themeId);
                $this->design->setDesignTheme($theme, \Magento\Framework\App\Area::AREA_FRONTEND);
                $description = $this->filterProvider->getPageFilter()->filter($storeStatus->getDescription());
                return $description;
            }
        );
    }

Then $description was passed to email in usual vars variable array

0

If all the above answers fail to fix the issue then the following should help.

This error usually originates due to theme.xml not being present or issues related to theme-related entries in the database.

  1. Check whether the theme.xml folder is present for all themes in the app/design. If yes then check the database.

2)Run select * from theme; Check if all themes have the correct parent_id as configured in app/design. Also, check that the theme_id being used for store in the core_config_data table is correct.

If all is correct and the issue still persists then update the core_config_data table's value column for the theme_id and set it to NULL;

update core_config_data set value=NULL where path like "%theme%". 

Run setup upgrade command. Go to admin Conetnt->Design->Configuration. Set the required theme. Then flush the cache. Refresh the front end and check. Your theme should be working at this point.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.