PHP Fatal error: Uncaught Error: Call to a member function getPackage() on null in vendor/magento/module-deploy/Package/Processor/PostProcessor/CssUrls.php:215
This fails only on build system but works fine in development system if i run same deployment command.
PHP Fatal error: Uncaught Error: Call to a member function getPackage() on null in vendor/magento/module-deploy/Package/Processor/PostProcessor/CssUrls.php:215
Hi, we have similar problem. Workaround for that is remove generated data before deploy. If var/view_preprocessed
exists magento using data from this dir.
rm -rf pub/static/* var/view_preprocessed/pub/*
php bin/magento setup:static-content:deploy -f en_US
Here is my old question on stackexchange related to this issue: [Magento 2.2 Build system]
Hi @bmxmale
I tried your solution multiple times it didn't work for me
This is my server configuration
PHP 7.1
Magento2.2.0
Hi @magento-engcom-team
I am able to reproduce this issue in both local and staging environment
PHP 7.1
Magento2.2.0
Operating system Ubuntu and Windows
Hi @magento-engcom-team
Hope this may help your fix
PHP Fatal error: Uncaught Error: Call to a member function getPackage() on null in E:xampphtdocsequip2go.com.devpublic_htmlvendormagentomodule-deployPackageProcessorPostProcessorCssUrls.php:215
Stack trace:
Fatal error: Uncaught Error: Call to a member function getPackage() on null in E:xampphtdocsequip2go.com.devpublic_htmlvendormagentomodule-deployPackageProcessorPostProcessorCssUrls.php on line 215
Error: Call to a member function getPackage() on null in E:xampphtdocsequip2go.com.devpublic_htmlvendormagentomodule-deployPackageProcessorPostProcessorCssUrls.php on line 215
Call Stack:
0.0003 347040 1. {main}() E:xampphtdocsequip2go.com.devpublic_htmlbinmagento:0
4.4549 17501696 2. MagentoFrameworkConsoleCli->run() E:xampphtdocsequip2go.com.devpublic_htmlbinmd5-a7812db66e08ab5471ab11ba99b8cc8fmagento:23
@gulshan-streammarket, thank you for your report.
We were not able to reproduce this issue by following the steps you provided. Please provide more detailed steps to reproduce.
Hi,
I also faced the same issue and reason of getting this issue was--
I added the ht-access in var folder and removed the default CSS files from the web folder of the newly created theme and then got the success in deploy without any issue.
Thanks
@gulshan-streammarket, thank you for your report.
We were not able to reproduce this issue by following the steps you provided. If you'd like to update it, please reopen the issue.
Hi @magento-engcom-team ,
this error occurs when minify CSS files configuration has value true (Stores->Configuration->Advanced->Developer->Css Settings->Minify CSS Files).
and it is reproduced even after fresh installation.
I had this error when I override css files in my template. I had a bad css file.
I check permission and format of file who stuck process with
l:218 vendor/magento/module-deploy/Package/Processor/PostProcessor/CssUrls.php :
var_dump($filePath);
var_dump(get_class($matchedFile));
$package = $matchedFile->getPackage();
I found that for me it was happening due to email css files email.css and email-inline.css in my custom theme, instead of .less and the line that was causing this issue was at the top with the code:
@import url("{{base_url_path}}frontend/Magento/luma/{{locale}}/css/email-fonts.css");
and found that the issue was due to the variable {{base_url_path}} instead i changed the code to
@import url("{{baseUrl}}/css/email-fonts.css");
and the error was gone.
@malikt Yea the same issue. Helped me
@romantomchak, we cannot reproduce this issue. Please provide a complete list of steps to reproduce.
@engcom-backlog-pb
Steps to reproduce:
composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition ./
bin/magento module:enable --all
Then add the following to config.php to make sure Magento has enough info to generate the assets
<?php
return [
'modules' => [
'Magento_Store' => 1,
'Magento_Directory' => 1,
'Magento_Eav' => 1,
'Magento_Backend' => 1,
'Magento_Theme' => 1,
'Magento_Customer' => 1,
'Magento_AdminNotification' => 1,
'Magento_Indexer' => 1,
'Magento_AdvancedPricingImportExport' => 1,
'Magento_Config' => 1,
'Magento_Authorization' => 1,
'Magento_Cms' => 1,
'Magento_Rule' => 1,
'Magento_Backup' => 1,
'Magento_Catalog' => 1,
'Magento_Bundle' => 1,
'Magento_BundleImportExport' => 1,
'Magento_CacheInvalidate' => 1,
'Magento_Quote' => 1,
'Magento_SalesSequence' => 1,
'Magento_Security' => 1,
'Magento_CatalogImportExport' => 1,
'Magento_Payment' => 1,
'Magento_Cron' => 1,
'Magento_Msrp' => 1,
'Magento_Search' => 1,
'Magento_CatalogUrlRewrite' => 1,
'Magento_Widget' => 1,
'Magento_CatalogInventory' => 1,
'Magento_Sales' => 1,
'Magento_Checkout' => 1,
'Magento_CmsUrlRewrite' => 1,
'Magento_User' => 1,
'Magento_ConfigurableImportExport' => 1,
'Magento_ConfigurableProduct' => 1,
'Magento_ConfigurableProductSales' => 1,
'Magento_Contact' => 1,
'Magento_Cookie' => 1,
'Magento_Email' => 1,
'Magento_CurrencySymbol' => 1,
'Magento_Vault' => 1,
'Magento_Integration' => 1,
'Magento_CustomerImportExport' => 1,
'Magento_Deploy' => 1,
'Magento_Developer' => 1,
'Magento_Dhl' => 1,
'Amazon_Core' => 1,
'Magento_Downloadable' => 1,
'Magento_ImportExport' => 1,
'Magento_Authorizenet' => 1,
'Magento_Newsletter' => 1,
'Magento_EncryptionKey' => 1,
'Magento_Fedex' => 1,
'Magento_GiftMessage' => 1,
'Magento_GoogleAdwords' => 1,
'Magento_GoogleAnalytics' => 1,
'Magento_Ui' => 1,
'Magento_GroupedImportExport' => 1,
'Magento_GroupedProduct' => 1,
'Magento_DownloadableImportExport' => 1,
'Magento_Paypal' => 1,
'Magento_InstantPurchase' => 1,
'Magento_Analytics' => 1,
'Magento_LayeredNavigation' => 1,
'Magento_Marketplace' => 1,
'Magento_MediaStorage' => 1,
'Magento_CatalogRule' => 1,
'Magento_Multishipping' => 1,
'Magento_NewRelicReporting' => 1,
'Magento_ProductAlert' => 1,
'Magento_OfflinePayments' => 1,
'Magento_SalesRule' => 1,
'Magento_PageCache' => 1,
'Magento_Captcha' => 1,
'Klarna_Core' => 1,
'Magento_Persistent' => 1,
'Magento_Reports' => 1,
'Magento_ProductVideo' => 1,
'Amazon_Login' => 1,
'Magento_QuoteAnalytics' => 1,
'Magento_ReleaseNotification' => 1,
'Magento_Review' => 1,
'Magento_RequireJs' => 1,
'Magento_SendFriend' => 1,
'Magento_ReviewAnalytics' => 1,
'Magento_Robots' => 1,
'Magento_Rss' => 1,
'Magento_CatalogRuleConfigurable' => 1,
'Amazon_Payment' => 1,
'Magento_SalesAnalytics' => 1,
'Magento_SalesInventory' => 1,
'Magento_OfflineShipping' => 1,
'Klarna_Ordermanagement' => 1,
'Magento_UrlRewrite' => 1,
'Magento_CatalogSearch' => 1,
'Magento_CustomerAnalytics' => 1,
'Magento_Shipping' => 1,
'Magento_Wishlist' => 1,
'Magento_Signifyd' => 1,
'Magento_Sitemap' => 1,
'Magento_CheckoutAgreements' => 1,
'Magento_Swagger' => 1,
'Magento_Swatches' => 1,
'Magento_SwatchesLayeredNavigation' => 1,
'Magento_Tax' => 1,
'Magento_TaxImportExport' => 1,
'Klarna_Kp' => 1,
'Magento_Translation' => 1,
'Magento_GoogleOptimizer' => 1,
'Magento_Ups' => 1,
'Magento_SampleData' => 1,
'Magento_CatalogAnalytics' => 1,
'Magento_Usps' => 1,
'Magento_Variable' => 1,
'Magento_Braintree' => 1,
'Magento_Version' => 1,
'Magento_Webapi' => 1,
'Magento_WebapiSecurity' => 1,
'Magento_Weee' => 1,
'Magento_CatalogWidget' => 1,
'Dotdigitalgroup_Email' => 1,
'Magento_WishlistAnalytics' => 1,
'Shopial_Facebook' => 1,
'Temando_Shipping' => 1,
'Vertex_Tax' => 1
],
'scopes' => [
'websites' => [
'admin' => [
'website_id' => '0',
'code' => 'admin',
'name' => 'Admin',
'sort_order' => '0',
'default_group_id' => '0',
'is_default' => '0',
],
'base' => [
'website_id' => '1',
'code' => 'base',
'name' => 'Main Website',
'sort_order' => '0',
'default_group_id' => '1',
'is_default' => '1',
],
'test' => [
'website_id' => '2',
'code' => 'test',
'name' => 'test',
'sort_order' => '0',
'default_group_id' => '0',
'is_default' => '0',
],
],
'groups' => [
0 => [
'group_id' => '0',
'website_id' => '0',
'code' => 'default',
'name' => 'Default',
'root_category_id' => '0',
'default_store_id' => '0',
],
1 => [
'group_id' => '1',
'website_id' => '1',
'code' => 'main_website_store',
'name' => 'Main Website Store',
'root_category_id' => '2',
'default_store_id' => '1',
],
],
'stores' => [
'admin' => [
'store_id' => '0',
'code' => 'admin',
'website_id' => '0',
'group_id' => '0',
'name' => 'Admin',
'sort_order' => '0',
'is_active' => '1',
],
'default' => [
'store_id' => '1',
'code' => 'default',
'website_id' => '1',
'group_id' => '1',
'name' => 'Default Store View',
'sort_order' => '0',
'is_active' => '1',
],
],
],
'system' => [
'default' => [
'dev' => [
'css' => [
'minify_files' => '1'
]
]
]
]
];
And then run
bin/magento setup:static-content:deploy -f
````
**Expected result:**
Static content will be deployed
**Actual result**
PHP Fatal error: Uncaught Error: Call to a member function getPackage() on null in /www/project-community-edition/vendor/magento/module-deploy/Package/Processor/PostProcessor/CssUrls.php:215
```
If you alter config.php and set minify_files to 0, generating of static assets will succeed
The problem is that you can't generate "minified" css, which is an issue in CI/CD
-- edit --
Updated the contents of config.php
@rutgerrademaker
@engcom-backlog-pb Not sure what you did, but if you followed my steps exactly there would not be an en env.php. What happens if you delete env.php and run the deploy command again?
@rutgerrademaker env.php and config.php are both created while Magento installing. And deleting env.php is a very strange step.
@engcom-backlog-pb
Actually it is not a strange step if you think that this is a problem in a "pipeline" which creates an artifact independent of an environment. In our (and I think most) pipeline(s) there is no env.php (as it is obviously not in the project's repository)
This works fine until you enable 'minify_files' for css
If you follow my (simplified) steps of the commands in the pipeline you don't get an env.php
I'll have to make an excuse though because I posted the wrong contents of config.php (this is updated now in my previous post)
N.B. My best guess is that generating the assets in a Pipeline without an env.php is an issue because there are no actual urls available in a database or env.php
Disclaimer, I'm the pipeline guy with only a little m2 experience.
@rutgerrademaker
I have tried to reproduce the issue by your updated steps, but nothing changed.
@gulshan-streammarket we are closing this issue due to inactivity. If you'd like to update it, please reopen the issue.
i am having the same issue with 2.3:
Deploy using quick strategy
frontend/Magento/blank/de_DE 1731/2716 =================>---------- 63% % 2 secs
PHP Fatal error: Uncaught Error: Call to a member function getPackage() on null in /var/www/html/magento2/vendor/magento/module-deploy/Package/Processor/PostProcessor/CssUrls.php:215
Stack trace:
Looks like the issue has never been fixed. It's reproducible on the latest 2.2.x and 2.3.x branches.
@magento-engcom-team Could you please reopen the ticket?
It seems to be a magento bug :-( . The way to reverse it is the following (I know this is not a solution) but it will help to have the site working again:
On command line:
Magento ≥ 2.2 bin/magento config:set dev/css/minify_files 0 bin/magento cache:clean
Magento < 2.2 On DB (mysql client) execute: UPDATE core_config_data SET value = 0 WHERE 'dev/css/minify_files
bin/magento cache:clean
Now, you can compile again.
This is reproducible in 2.3.1 as well when deploying static content in deployment pipeline and:
'system' => [
'default' => [
'dev' => [
'css' => [
'minify_files' => '1'
]
]
]
]
is added to config.php
I also have the same issue
PHP Fatal error: Uncaught Error: Call to a member function getPackage() on null in /var/app/current/vendor/magento/module-deploy/Package/Processor/PostProcessor/CssUrls.php:215
php bin/magento -V
Magento CLI version 2.2.0
Same issue for me with Magento 2.3.4 using deployer
@magento-engcom-team Can you please reopen this ticket? The issue is still present.
Please reopen this ticket, we're having this issue on m2.3.5-p1
And even on 2.4.1... @magento-admin
Most helpful comment
Hi, we have similar problem. Workaround for that is remove generated data before deploy. If
var/view_preprocessed
exists magento using data from this dir.rm -rf pub/static/* var/view_preprocessed/pub/*
php bin/magento setup:static-content:deploy -f en_US
Here is my old question on stackexchange related to this issue: [Magento 2.2 Build system]