Magento 2.2 – Fix ‘Failed to Open Stream’ Error During Static Content Deploy

deploymagento2.2static-content

I have recently added a new root source css file for magento storefront by putting it in default_head_blocks.xml throught below statement.

<css src="css/custom.css"/>

Now I ran upgrade command

php bin/magento setup:upgrade

I am having the same custom.less file at below path of my custom theme.

app/design/frontend/myvendor/mytheme/web/css/custom.less

When I now try to run deploy command Magento is giving me an error

pub/static/frontend/myvendor/mytheme/en_US/css/custom.css): failed to open stream: No such file or directory

I don't know if this is a version issue or not but I already tried signing off static files from backend by setting

store>configuration>advanced>Developer>Static File Setting>Sign Static Files to No

as well as trying to run the command again with admin rights.

Still, the error persists.

Best Answer

This error was actually created as custom.less file was blank and therefore magento was not generating custom.css file from it.

I don't know if it is bug or not as blank custom.css file should be generated from respective blank custom.less file.

Adding some css rules to it solves this issue.

Related Topic