Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update to 2.1.1 can not deploy content files #6426

Closed
knidie opened this issue Aug 31, 2016 · 65 comments
Closed

update to 2.1.1 can not deploy content files #6426

knidie opened this issue Aug 31, 2016 · 65 comments
Labels
Area: Frontend bug report Issue: Cannot Reproduce Cannot reproduce the issue on the latest `2.4-develop` branch Issue: Format is not valid Gate 1 Failed. Automatic verification of issue format is failed Progress: needs update

Comments

@knidie
Copy link

knidie commented Aug 31, 2016

update to 2.1.1 can not deploy static content because missing deployed_version.txt,

[UnexpectedValueException]
Unable to retrieve deployment version of static files from the file system.

[UnexpectedValueException]
Unable to retrieve deployment version of static files from the file system.

[Magento\Framework\Exception\FileSystemException]
Cannot read contents from file "/var/www/html/magento2/pub/static/deployed_version.txt" Warning!file_get_contents(/var/www/html
/magento2/pub/static/deployed_version.txt): failed to open stream: No such file or directory

@ihor-sviziev
Copy link
Contributor

ihor-sviziev commented Aug 31, 2016

I also had this issue.
@knidie as temporary solution you could just create empty file in following path: /var/www/html/magento2/pub/static/deployed_version.txt

@knidie
Copy link
Author

knidie commented Aug 31, 2016

thanks, it works great!!

@knidie knidie closed this as completed Aug 31, 2016
@hostep
Copy link
Contributor

hostep commented Sep 1, 2016

Indeed, I noticed this too: magento/devdocs#419 (comment)

Since you can resolve it by creating an empty file, this feels like a regression bug which crept into the 2.1.1 release. Maybe you should reopen the bug and let the Magento devs comment on this if this was an intentional change or not...

ihor-sviziev added a commit to ihor-sviziev/magento2 that referenced this issue Sep 1, 2016
…content:deploy

After Upgrading to Magento 2.1.1 we had following exception when magento mode is "production" and we executing php bin/magento setup:statis-content:deploy:
```
[Magento\Framework\Exception\FileSystemException]                                                                                                                                                                        
  Cannot read contents from file "/vhosts/www/magento2/pub/static/deployed_version.txt" Warning!file_get_contents(/vhosts/www/magento2/pub/static/deployed_version.txt): failed to open stream: N  
  o such file or directory                                                                                                                                                                                                 
                                                                                                                                                                                                                           


Exception trace:
 () at /vhosts/www/magento2/vendor/magento/framework/Filesystem/Driver/File.php:149
 Magento\Framework\Filesystem\Driver\File->fileGetContents() at /vhosts/www/magento2/vendor/magento/framework/Filesystem/Directory/Read.php:207
 Magento\Framework\Filesystem\Directory\Read->readFile() at /vhosts/www/magento2/vendor/magento/framework/App/View/Deployment/Version/Storage/File.php:44
 Magento\Framework\App\View\Deployment\Version\Storage\File->load() at /vhosts/www/magento2/vendor/magento/framework/App/View/Deployment/Version.php:77
 Magento\Framework\App\View\Deployment\Version->readValue() at /vhosts/www/magento2/vendor/magento/framework/App/View/Deployment/Version.php:49
 Magento\Framework\App\View\Deployment\Version->getValue() at /vhosts/www/magento2/vendor/magento/module-theme/Model/Url/Plugin/Signature.php:88
 Magento\Theme\Model\Url\Plugin\Signature->renderUrlSignature() at /vhosts/www/magento2/vendor/magento/module-theme/Model/Url/Plugin/Signature.php:66
 Magento\Theme\Model\Url\Plugin\Signature->aroundGetBaseUrl() at /vhosts/www/magento2/vendor/magento/framework/Interception/Interceptor.php:142
 Magento\Store\Model\Store\Interceptor->___callPlugins() at /vhosts/www/magento2/var/generation/Magento/Store/Model/Store/Interceptor.php:143
 Magento\Store\Model\Store\Interceptor->getBaseUrl() at /vhosts/www/magento2/vendor/magento/framework/Url.php:452
 Magento\Framework\Url->getBaseUrl() at /vhosts/www/magento2/vendor/magento/framework/View/Asset/Repository.php:266
 Magento\Framework\View\Asset\Repository->getFallbackContext() at /vhosts/www/magento2/vendor/magento/framework/View/Asset/Repository.php:244
 Magento\Framework\View\Asset\Repository->getStaticViewFileContext() at /vhosts/www/magento2/vendor/magento/framework/RequireJs/Config.php:123
 Magento\Framework\RequireJs\Config->__construct() at /vhosts/www/magento2/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php:93
 Magento\Framework\ObjectManager\Factory\AbstractFactory->createObject() at /vhosts/www/magento2/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php:89
 Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create() at /vhosts/www/magento2/vendor/magento/framework/ObjectManager/ObjectManager.php:57
 Magento\Framework\ObjectManager\ObjectManager->create() at /vhosts/www/magento2/vendor/magento/module-deploy/Model/Deployer.php:252
 Magento\Deploy\Model\Deployer->deploy() at /vhosts/www/magento2/vendor/magento/module-deploy/Console/Command/DeployStaticContentCommand.php:445
 Magento\Deploy\Console\Command\DeployStaticContentCommand->deploy() at /vhosts/www/magento2/vendor/magento/module-deploy/Console/Command/DeployStaticContentCommand.php:468
 Magento\Deploy\Console\Command\DeployStaticContentCommand->Magento\Deploy\Console\Command\{closure}() at n/a:n/a
 call_user_func() at /vhosts/www/magento2/vendor/magento/module-deploy/Model/Process.php:53
 Magento\Deploy\Model\Process->run() at /vhosts/www/magento2/vendor/magento/module-deploy/Model/ProcessManager.php:41
 Magento\Deploy\Model\ProcessManager->fork() at /vhosts/www/magento2/vendor/magento/module-deploy/Console/Command/DeployStaticContentCommand.php:473
 Magento\Deploy\Console\Command\DeployStaticContentCommand->runProcessesInParallel() at /vhosts/www/magento2/vendor/magento/module-deploy/Console/Command/DeployStaticContentCommand.php:371
 Magento\Deploy\Console\Command\DeployStaticContentCommand->execute() at /vhosts/www/magento2/vendor/symfony/console/Symfony/Component/Console/Command/Command.php:257
 Symfony\Component\Console\Command\Command->run() at /vhosts/www/magento2/vendor/symfony/console/Symfony/Component/Console/Application.php:874
 Symfony\Component\Console\Application->doRunCommand() at /vhosts/www/magento2/vendor/symfony/console/Symfony/Component/Console/Application.php:195
 Symfony\Component\Console\Application->doRun() at /vhosts/www/magento2/vendor/magento/framework/Console/Cli.php:96
 Magento\Framework\Console\Cli->doRun() at /vhosts/www/magento2/vendor/symfony/console/Symfony/Component/Console/Application.php:126
 Symfony\Component\Console\Application->run() at /vhosts/www/magento2/bin/magento:23
```

This pull request will fix this issue.
Fixes magento#6426
@bery
Copy link

bery commented Sep 12, 2016

I do not think that creating a blank file is a solution - more like an ugly workaround for incorrect functional logic. Would it be possible to get rid of this messages and change the behavior to

  • check if the file exists, if yes read the version and see what needs to be done
  • if the file does not exist, continue with the deploy (e.g. clean, fresh deploy)

@knidie
Copy link
Author

knidie commented Sep 12, 2016

It worked for me, this file must be there, if not system stops to deploy files , as temporary solution it's just fine.

weikai chen

在 2016年9月12日,下午2:58,bery notifications@github.com 写道:

I do not think that creating a blank file is a solution - more like an ugly workaround for incorrect functional logic. Would it be possible to get rid of this messages and change the behavior to

check if the file exists, if yes read the version and see what needs to be done
if the file does not exist, continue with the deploy (e.g. clean, fresh deploy)

You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub, or mute the thread.

@hostep
Copy link
Contributor

hostep commented Sep 12, 2016

@knidie: I think it's best if you re-open this ticket, since it's new and unexpected behavior introduced in Magento 2.1.1
I'm pretty sure the change in behavior was also unintentional so we can probably call it a new bug.
Even though there is a temporary workaround, that's not really enough to call this bug "fixed".
Do you agree?

Let's include some Magento support people in here, maybe they can verify this with the developers if this is a new bug or if this was actually intentional (which I don't really believe).
/cc @veloraven, @piotrekkaminski, @pboisvert, @mazhalai, ...

Thanks!

@knidie knidie reopened this Sep 13, 2016
@eug123
Copy link
Contributor

eug123 commented Sep 21, 2016

Hi @knidie,
This issue was fixed in the scope of the MAGETWO-56915 and delivered to the develop branch.
Please check if the issue is still reproducible for you on the develop branch.
Thank you

@MomotenkoNatalia MomotenkoNatalia added Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development bug report Area: Frontend Progress: needs update labels Sep 21, 2016
@jvreeken
Copy link

I had this problem only when I enabled signing of static files. in:
Stores->Configuration->Advanced->Developer->Static Files Setting->Yes
Turning it to No allowed it to compile, but it's not a solution as we want to use that for caching
When is 2.1.1 going to be updated / when is the next release for 2.1.2?
Seems like 2.1.1 has a lot of issues that make it basically unusable for production without hacking and patching.

@Ctucker9233
Copy link

@eug123 Has MAGETWO-56915 been ported to 2.1 or is it just in develop right now? If it's not ported, will we have to wait for the next patch/2.1.2?

@ihor-sviziev
Copy link
Contributor

This issue should be included in next update, but I'm not sure

On Oct 7, 2016 23:51, "Ctucker9233" notifications@github.com wrote:

@eug123 https://github.com/eug123 Has MAGETWO-56915 been ported to 2.1
or is it just in develop right now? If it's not ported, will we have to
wait for the next patch/2.1.2?


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#6426 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AByXUdqnRWpqBW4QzwLFd6AM4P-AgXZLks5qxrDDgaJpZM4Jx-_S
.

@keyurshah
Copy link

had this issue when upgrading from magento 2.1.0 to 2.1.2

@ghost
Copy link

ghost commented Oct 13, 2016

Also had this issue when upgrading from 2.1.1 to 2.1.2.

@michelgokan
Copy link

michelgokan commented Nov 19, 2016

This seems a critical problem. Please consider fixing it because we can't deploy static files in some situations :( . I'm using 2.1.2.

@slackerzz
Copy link
Member

bug present in M2 2.1.2 EE

@bery
Copy link

bery commented Jan 18, 2017

There is a workaround for this behavior - run
php bin/magento setup:upgrade --keep-generated

Yet, be careful when running this as you have to do the cleanup on your own.

Directories to be cleaned up manually:

  • var/cache
  • var/page_cache
  • var/di
  • var/generation
  • pub/static

Also it is worth to mention that magento documentation specifically warns from doing this when magento is set to production mode.

@KrystynaKabannyk
Copy link

Hi @knidie, this issue has been backported in 2.1.3, that's why I'm closing it. Feel free to reopen it if something is not working.

@twosg
Copy link

twosg commented May 1, 2017

This issue is still alive for me at Magento 2.1.6.

Magento is in production mode and I have used bin/magento setup:upgrade
the pub/static folder was empty (just .htaccess)

After creating the deployed_version.txt it works again.

@aburkes
Copy link

aburkes commented May 2, 2017

I am having the same issue.

Furthermore, creating the deployed_version.txt only partially works. Attempting to load a page in the frontend results in linked style files and images coming up 404 - it would appear that it's linking to the wrong location.

For the record, this is the default theme, "Lumo". It also breaks links to javascript files, so the site is essentially non-functional. Worse, this happens in the backend as well.

@dmitrisol
Copy link

dmitrisol commented May 3, 2017

Have the same issue in production mode in CE 2.1.6. bin/magento setup:upgrade first removed the file, and later complains about it missing:

php bin/magento setup:upgrade
Cache cleared successfully
File system cleanup:
/data1/projects/trc/staging/magento2/var/generation/Composer
/data1/projects/trc/staging/magento2/var/generation/MOFX
/data1/projects/trc/staging/magento2/var/generation/MageWorx
/data1/projects/trc/staging/magento2/var/generation/Magento
/data1/projects/trc/staging/magento2/var/generation/Symfony
/data1/projects/trc/staging/magento2/var/generation/Wyomind
/data1/projects/trc/staging/magento2/pub/static/deployed_version.txt
Updating modules:
Schema creation/updates:
...
...
...
Installing data... Upgrading data... 

                                                                               
  [UnexpectedValueException]                                                   
  Unable to retrieve deployment version of static files from the file system.  
                                                                               




                                                                                                                                                                                                        
  [Magento\Framework\Exception\FileSystemException]                                                                                                                                                     
  Cannot read contents from file "/www/magento2/pub/static/deployed_version.txt" Warning!file_get_contents(/www/magento2/pub/static/deployed_version.txt  
  ): failed to open stream: No such file or directory                                                                                                                                                   
                                                                                                                                                                                                        


setup:upgrade [--keep-generated] [--magento-init-params="..."]

@szumel
Copy link

szumel commented May 9, 2017

Override protected function readValue($appMode) from \Magento\Framework\App\View\Deployment\Version

protected function readValue($appMode)
 {
        switch ($appMode) {
            case \Magento\Framework\App\State::MODE_DEFAULT:
            case \Magento\Framework\App\State::MODE_PRODUCTION:
                try {
                    $result = $this->versionStorage->load();
                } catch (\UnexpectedValueException $e) {
                    $result = (new \DateTime())->getTimestamp();
                    $this->versionStorage->save($result);
                }
                break;

            case \Magento\Framework\App\State::MODE_DEVELOPER:
                $result = (new \DateTime())->getTimestamp();
                break;

            default:
                $result = $this->versionStorage->load();
        }
        return $result;
    }

@xtfer
Copy link

xtfer commented Feb 20, 2018

Ignore that commit reference, though, that shouldn't have shown up here and was removed from that repository. Its not the correct solution.

@gjportegies
Copy link

gjportegies commented Feb 27, 2018

Issue still exists in version 2.2.3

Problem came up when switching from production mode to developer mode.

@ihor-sviziev
Copy link
Contributor

@gjportegies could you prepare actual steps to reproduce on clean magento installation?

@xtfer
Copy link

xtfer commented Feb 28, 2018

"Clean install of 2.2.2 using the CLI, in production mode." :)

@ihor-sviziev
Copy link
Contributor

@xtfer this is not steps to reproduce. Which steps/commands should I execute in order to reproduce this issue?

@gjportegies
Copy link

@ihor-sviziev I'm not sure at this point. But I think it happens when switching from production to developer mode while still having JS and CSS minifying and merging enabled.

@ihor-sviziev ihor-sviziev removed the Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development label Feb 28, 2018
@essexboyupnorth
Copy link

essexboyupnorth commented Feb 28, 2018

UPDATE: switching the following line in the server block of the NGINX config file from "production" to "developer" solved my issues:
set $MAGE_MODE developer;

Similar situation to @xtfer. Clean install of Magento 2.2.3 using:

  • composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition
  • This ran without errors, moved all files up to htdocs.
  • Accessed the setup wizard in a browser using the server IP address. The wizard ran successfully.
  • Launch admin gives me "There has been an error processing your request" page with error log record no.
  • Error report starts with: "Unable to retrieve deployment version of static files from the file system". Full report attached.
  • Running php bin/magento setup:static-content:deploy -f fixes error by creating deployed_version.txt in pub/static but front and backend load without css.
    static-files-error.txt

@KevinGimbel
Copy link

KevinGimbel commented Oct 15, 2018

I just encountered the same issue on version 2.2.4.

We automatically deploy Magento to AWS when a commit to a Git repository is made. During the deployment, we run some Magento CLI commands (for example setup:upgrade, cache:clean, and cache:flush).

Magento is running in production mode and this shouldn't happen in my opinion. As it is now I do not have the confidence to set up a fully automated deployment process with Magento 2 for a production shop, so I am stuck with having manual steps in my deployment process which drastically effects scalability.

Edit: I could "solve" the problem by running bin/magento setup:static-content:deploy -f

@ihor-sviziev
Copy link
Contributor

@KevinGimbel if you still have this issue on latest Magento version (2.2.6 atm) - let us know by creating new issue. We'll re-check it

@mklooss
Copy link

mklooss commented Nov 1, 2018

got this issue on M2.2 also.

Fixed it by adding: "static_content_on_demand_in_production" in the app/etc/env.php
source: https://devdocs.magento.com/guides/v2.2/cloud/env/variables-intro.html

Code:

if ($appMode == \Magento\Framework\App\State::MODE_PRODUCTION
&& !$this->deploymentConfig->getConfigData(
ConfigOptionsListConstants::CONFIG_PATH_SCD_ON_DEMAND_IN_PRODUCTION
)
) {
$this->getLogger()->critical('Can not load static content version.');
throw new \UnexpectedValueException(
"Unable to retrieve deployment version of static files from the file system."
);
}

@xLidoni
Copy link

xLidoni commented Aug 26, 2019

@mklooss Hi! I'm using magento 2.2.2.
I've the same problem.

How and where i must write:
static_content_on_demand_in_production

In app/etc/env.php
In which line?

This is my env.php : https://pastebin.com/Djhqczej

Thanks.

@ihor-sviziev
Copy link
Contributor

ihor-sviziev commented Sep 3, 2019

@mklooss Hi! I'm using magento 2.2.2.
I've the same problem.

How and where i must write:
static_content_on_demand_in_production

In app/etc/env.php
In which line?

This is my env.php : https://pastebin.com/Djhqczej

Thanks.

You can add it like this:
https://gist.github.com/ihor-sviziev/367a8a068c8141adad92812a6b8ea0be/revisions#diff-a9565219ff1cc95ce0ccd0d138bbf45f

But actually the issue was fixed in newer Magento version, so it' better to update to latest magento 2.2.x release

@freeyland
Copy link

freeyland commented Nov 15, 2019

I have the same issue on 2.3.3

The solution static_content_on_demand_in_production works

thx

@aliomattux
Copy link

I have Magento 2.3.3 and same issue.

When in production mode only
Using commands grunt clean or grunt exec delete the file deployed_version.txt and then complains it can't find the vesrion. To me this definitely seems like a bug.

@ihor-sviziev
Copy link
Contributor

@aliomattux,
What you mentioned looks like separate issue. We didn't have this issue since magento 2.2.x.
Could you report separate issue with exact steps to reproduce?

Thank you!

@scapritta
Copy link

Using commands grunt clean or grunt exec delete the file deployed_version.txt and then complains it can't find the vesrion. To me this definitely seems like a bug.

same error on a 2.3.1

executing grunt:exec loses deployed_version.txt and creates the problem.

@ihor-sviziev
Copy link
Contributor

@sy-salvo
What you mentioned looks like separate issue. We didn't have this issue since magento 2.2.x.
Could you report separate issue with exact steps to reproduce?

Thank you!

@scapritta
Copy link

scapritta commented Feb 26, 2020

Hi @ihor-sviziev

This is just happening when i run the command

grunt exec:theme_name

while in production mode.

And this gives the error:

Unable to retrieve deployment version of static files from the file system.

The deployed_version.txt file is missing after running the command.

I don't know if it can be a real issue (grunt command remove all files from pub/static and first of all: should we use grunt in production mode?)

We tried this command in production mode because we were experiencing some differences between the "grunted" generated files and the deployed ones with setup:static-content:deploy command in pub/static.

@hostep
Copy link
Contributor

hostep commented Feb 27, 2020

@sy-salvo: Magento doesn't recommend to use grunt in production mode. In production mode, you should use the bin/magento setup:static-content:deploy [bunch-of-optional-flags...] command.

If you need a module to use the node.js less compiler (instead of the php one) in production, you can for example use something like this, which should result in the exact same output in production as in development.

@scapritta
Copy link

thanks @hostep for your feedback.
It's ok for us using setup:static-content:deploy
just figuring out the deepest differences between two methods, in order to understand some minor different results.

@aliomattux
Copy link

What do you mean Magento doesn't recommend using grunt in production mode, why is it provided then? Do you have a link to official documentation that states this?

For me, static content deploy does not compile less. We are using less, and our custom theme has less. If I was to do as you suggest, I would have broken css.

@ihor-sviziev
Copy link
Contributor

ihor-sviziev commented Feb 27, 2020 via email

@scapritta
Copy link

Yes, actually we encountered the problem just because of this.

  • using grunt for less development on custom theme
  • need to execute grunt commands + static-content:deploy on production in order to see all customizations

But executing the grunt command on production mode gives us the "deployed_version.txt" problem

@aliomattux
Copy link

In my tests, using static content deploy does not correctly compile and show changes to less. The only way I was able to get it to work was to use grunt exec and then grunt less. My understanding is that you would either use static content deploy OR grunt, not both. Grunt performs the same actions as static deploy. I do not believe the comment about not recommending grunt in production mode is factual unless an official source could be provided to verify that claim.

To get around the issue of deploy file deleting, In env.php I set the mode 'static_content_on_demand_in_production' as mentioned in a previous post. Using grunt without, will delete the version file when using grunt exec. I verified this on multiple independent deployments. Some have suggested that the deploy file deleting is a separate issue. Would recommend whoever to file a new issue with steps to reproduce on a fresh install. I am satisfied where my project is so will not work on this issue further. I would also test using 2.3.4, however there are a surprising number of core issues in 2.3.3, so I don't have confidence that upgrading wouldn't introduce new issues.

@scapritta
Copy link

scapritta commented Feb 27, 2020

@aliomattux thanks for sharing.

Your scenario is very similar to our.

At least, if i correctly understood the first part of your post, we can use production mode not deploying static view files with setup:static-conten:deploy but using grunt:exec and grunt:less
Are u using this approach in production?

thanks

@hostep
Copy link
Contributor

hostep commented Feb 27, 2020

One of the reasons why running setup:static-content:deploy instead of grunt on production is prefered, is that it can also take care of minifying and/or bundling of javascript files, minifying of html, ...
I'm pretty sure that the grunt scripts Magento provides out of the box do not provide that kind of functionality.

Look, you can run grunt in production, and by all means if this works for you and you are happy with it you can certainly do it, but I'm pretty sure Magento doesn't recommend it (even though I can't really find this on devdocs after searching around a bit).

The downside of using setup:static-content:deploy for less compilation when using the less.php compiler which Magento ships with, is that it might indeed cause slightly different output then when you compile less with the less.js library.
Therefore, you can swap the library to compile less files from less.php to less.js using that module I refered to earlier (the readme is a bit outdated, you should be able to use less.js v2 or v3 by now and that shrinkwrapping is no longer best practice, so if you are familiar enough with nodejs/npm you can probably figure everything out by not following the readme exactly)

@shyamranpara
Copy link
Contributor

I also had this issue.
@knidie as temporary solution you could just create empty file in following path: /var/www/html/magento2/pub/static/deployed_version.txt

Thanks worked

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Frontend bug report Issue: Cannot Reproduce Cannot reproduce the issue on the latest `2.4-develop` branch Issue: Format is not valid Gate 1 Failed. Automatic verification of issue format is failed Progress: needs update
Projects
None yet
Development

No branches or pull requests