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?
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?
Just in case if you are removing theme directly(Not in Magento way).
Then follow these steps.
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/*
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.
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.
theme
-table, but forgot about the core_config_data
value.
Commented
Mar 14, 2017 at 10:48
setup:static-content:deploy
admin went back to UI.
Commented
Oct 24, 2017 at 15:09
pub/static/.htaccess
was not there. thanks
Commented
Nov 1, 2017 at 14:38
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.
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.
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.
composer remove vendor/theme
?
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
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
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.
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:
Magento\Framework\View\Design\Fallback\Rule\Theme->getPatternDirs::74
Magento\Framework\Component\ComponentRegistrar->getPath::73
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.
})
$this->state->emulateAreaCode(Area::AREA_FRONTEND, function () {
// this should fix - Required parameter 'theme_dir' was not passed
$this->designLoader->load(); \\Magento\Framework\View\DesignLoader
...
});
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.
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()
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.
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
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.
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.
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