magento2: Pipeline deployment build failed "Uncaught Error: Call to a member function getPackage()"

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.

Preconditions

  1. Magento 2.2
  2. PHP 7.0.19
  3. Merge css enabled

Steps to reproduce

  1. Run app:config:dump on development system
  2. Commit code to git
  3. Pull code to build system with same environment
  4. Run php bin/magento setup:static-content:deploy -f en_US

Expected result

  1. Static content get deployed succesfully

Actual result

  1. Getting PHP Fatal error: Uncaught Error: Call to a member function getPackage() on null in vendor/magento/module-deploy/Package/Processor/PostProcessor/CssUrls.php:215

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 7
  • Comments: 30 (2 by maintainers)

Most upvoted comments

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

@magento-engcom-team Can you please reopen this ticket? The issue is still present.

Same issue for me with Magento 2.3.4 using deployer

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.

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?

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();

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.

This is reproducible in 2.3.1 as well when deploying static content in deployment pipeline and:

  1. env.php is not present
'system' => [
        'default' => [
            'dev' => [
                'css' => [
                    'minify_files' => '1'
                ]
            ]
        ]
    ]

is added to config.php

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.

Hi,

I also faced the same issue and reason of getting this issue was–

  1. I removed the whole var folder and didn’t added the ht-access again in this folder.
  2. the style-m.css , style-l.css and other default css files were under the web folder of new theme so same files were again compiling and conflicting with the blank theme.

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