资产文件不存在错误,即使不再引用文件?

时间:2016-01-18 09:48:48

标签: php caching assetic symfony symfony-console

我有一个名为main.less的文件,我以前创建过。我删除它是因为我不再需要它,但现在当我尝试运行bin/console assetic:watch时出现以下错误

[error] The source file "/home/distribution/public_html/distribution.tech/app/../web/bundles/app/less/main.less" does not exist.

bin/console assetic:dump,无论使用何种环境。

 [RuntimeException]                                                                                                        
  The source file "/home/distribution/public_html/distribution.tech/app/../web/bundles/app/less/main.less" does not exist. 

在我这样做之前一直工作的当前例程是创建一个运行以下命令的shell脚本文件:

chown -R distribution:distribution .
rm -rf var/cache/dev/*
rm -rf var/cache/prod/*
rm -rf web/css/*
rm -rf web/js/*
bin/console cache:clear --env=dev
bin/console cache:clear --env=prod --no-debug
bin/console assets:install web --symlink --relative
bin/console assetic:dump --env=dev --verbose
bin/console assetic:dump --env=prod --no-debug
bin/console assetic:watch
bin/console doctrine:schema:update --force --dump-sql
bin/console doctrine:schema:update --force --dump-sql --env=prod
chown -R distribution:distribution .
bin/console server:run

我总是以root身份运行它以确保一切正常,但文件由用户分发拥有。

引用less和javascript文件的唯一文件是......

base.html.twig

{% spaceless %}
<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8" />
        <title>{% block title %}Welcome!{% endblock %}</title>
        {% block stylesheets %}
            {% stylesheets 'bundles/skeleton/less/main.less' filter='less' filter='uglifycss' filter='cssrewrite' output='css/compiled-main.css' %}
                <link rel="stylesheet" href="{{ asset_url }}" />
            {% endstylesheets %}
        {% endblock %}
        <link rel="icon" type="image/x-icon" href="{{ asset('favicon.ico') }}" />
    </head>
    <body>
        {% block body %}{% endblock %}
        {% block javascripts %}
            {% javascripts 
             '@SkeletonBundle/Resources/public/js/*' 
             '@AppBundle/Resources/public/js/*'
              filter='uglifyjs2' 
              output='js/js-compiled.js' 
            %}
                <script src="https://code.jquery.com/jquery-2.2.0.min.js"></script>
                <script src="{{ asset_url }}"</script>
            {% endjavascripts %}
        {% endblock %}
    </body>
</html>
{% endspaceless %}

我的目录结构如下所示,直接来自我的FTP

enter image description here

您会注意到main.less现在是骨架捆绑而不是应用捆绑。我把它移到这里,但由于某种原因它认为它仍然在应用程序包而不是骨架包??

如何解决此错误?

额外信息:

当我运行详细的错误跟踪时,我得到了资产:dump

Dumping all dev assets.
Debug mode is on.

03:37:43 [file+] /home/distribution/public_html/distribution.tech/app/../web/css/compiled-main.css
        /home/distribution/public_html/distribution.tech/app/../web/bundles/skeleton/less/main.less
03:37:43 [file+] /home/distribution/public_html/distribution.tech/app/../web/css/compiled-main_main_1.css
        /home/distribution/public_html/distribution.tech/app/../web/bundles/skeleton/less/main.less
03:37:44 [file+] /home/distribution/public_html/distribution.tech/app/../web/js/js-compiled.js
        /home/distribution/public_html/distribution.tech/src/SkeletonBundle/Resources/public/js/shared.js
        /home/distribution/public_html/distribution.tech/src/AppBundle/Resources/public/js/app.js
03:37:44 [file+] /home/distribution/public_html/distribution.tech/app/../web/js/js-compiled_part_1_shared_1.js
        /home/distribution/public_html/distribution.tech/src/SkeletonBundle/Resources/public/js/shared.js
03:37:45 [file+] /home/distribution/public_html/distribution.tech/app/../web/js/js-compiled_part_2_app_1.js
        /home/distribution/public_html/distribution.tech/src/AppBundle/Resources/public/js/app.js
03:37:45 [file+] /home/distribution/public_html/distribution.tech/app/../web/css/compiled-main.css
        /home/distribution/public_html/distribution.tech/app/../web/bundles/app/less/main.less


  [RuntimeException]                                                                                                        
  The source file "/home/distribution/public_html/distribution.tech/app/../web/bundles/app/less/main.less" does not exist.  


Exception trace:
 () at /home/distribution/public_html/distribution.tech/vendor/kriswallsmith/assetic/src/Assetic/Asset/FileAsset.php:62
 Assetic\Asset\FileAsset->load() at /home/distribution/public_html/distribution.tech/vendor/kriswallsmith/assetic/src/Assetic/Asset/BaseAsset.php:103
 Assetic\Asset\BaseAsset->dump() at /home/distribution/public_html/distribution.tech/vendor/kriswallsmith/assetic/src/Assetic/Asset/AssetCollection.php:151
 Assetic\Asset\AssetCollection->dump() at /home/distribution/public_html/distribution.tech/vendor/symfony/assetic-bundle/Command/AbstractCommand.php:119
 Symfony\Bundle\AsseticBundle\Command\AbstractCommand->doDump() at /home/distribution/public_html/distribution.tech/vendor/symfony/assetic-bundle/Command/AbstractCommand.php:51
 Symfony\Bundle\AsseticBundle\Command\AbstractCommand->dumpAsset() at /home/distribution/public_html/distribution.tech/vendor/symfony/assetic-bundle/Command/DumpCommand.php:118
 Symfony\Bundle\AsseticBundle\Command\DumpCommand->execute() at /home/distribution/public_html/distribution.tech/vendor/symfony/symfony/src/Symfony/Component/Console/Command/Command.php:256
 Symfony\Component\Console\Command\Command->run() at /home/distribution/public_html/distribution.tech/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:803
 Symfony\Component\Console\Application->doRunCommand() at /home/distribution/public_html/distribution.tech/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:186
 Symfony\Component\Console\Application->doRun() at /home/distribution/public_html/distribution.tech/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php:86
 Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at /home/distribution/public_html/distribution.tech/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:117
 Symfony\Component\Console\Application->run() at /home/distribution/public_html/distribution.tech/bin/console:29

assetic:dump [--forks FORKS] [--watch] [--force] [--period PERIOD] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-e|--env ENV] [--no-debug] [--] <command> [<write_to>]

Config.yml资产设置:

assetic:
    debug:          '%kernel.debug%'
    use_controller: '%kernel.debug%'
    filters:
        cssrewrite: ~
        uglifyjs2:
            # the path to the uglifyjs executable
            bin: /usr/bin/uglifyjs
        uglifycss:
            bin: /usr/bin/uglifycss
        less: 
            node_paths: [/usr/local/lib/node_modules/]
            bin: /usr/bin/less

骨架束中的Main.less

/* Global Variables */
@logo: "../images/logo-hires-opt.png";

/* Fonts */
@font-face {
    font-family: 'ProximaNova';
    src: url('../fonts/proximanova-regular-webfont.ttf');
}
@font-face {
    font-family: 'ProximaNovaAltBold';
    src: url('../fonts/proxima_nova_alt_bold-webfont.ttf');
}

.withfont{font-family:ProximaNova;color:blue;background:url('../images/background.jpg');}

@import "shared.less";
@import "header.less";
@import "footer.less";

appBundle中的Admin.less文件

.test{color:red}

admin.html.twig

{% extends 'SkeletonBundle::base.html.twig' %}

{% block body %}
    <div id="wrapper">
        <div id="container">
            <div class="withfont">admin page</div>
            <div>admin page without <span class="test">fonts</span></div>
        </div>
    </div>
{% endblock %}

2 个答案:

答案 0 :(得分:2)

在我的情况下,有必要清除缓存...

php bin/console cache:clear --env=dev

我在phpstorm中的整个项目ctrl+shift+f中搜索了这个文件名(作为字符串),他在缓存目录中找到了某个文件...也许如果从缓存文件中删除行就足够了......但清除所有缓存我的情况100%成功

答案 1 :(得分:0)

好的,事实证明我的编辑器有一个旧版本向base.html.twig开放,引用了较旧的位置,因此当它进行渲染时无法找到它...我不知道如何我没有注意到这一点,但错误确实与文件实际上没有相关。

错误发生在此命令

{% stylesheets 'bundles/skeleton/less/main.less' filter='less' filter='uglifycss' filter='cssrewrite' output='css/compiled-main.css' %}
                <link rel="stylesheet" href="{{ asset_url }}" />
            {% endstylesheets %}
很奇怪的部分是我会发誓我删除了旧的base.html.twig,但经过一些调整后它神奇地重新出现了,我认为它与我的编辑器有关,以及它如何保存,因为我移动了文件并保持编辑同时开放。