0
votes

I have a longtime problem with assetic:dump. I wanna use "assetic" to get Javascript and CSS files from different bundles (I wrote) and collect them to dev and prod environment in the templates. Everytime I wanna dump new files, the assetic:dump command try to write in a complete broken path.

app/console assetic:dump

  [RuntimeException]                                                                                       
  Unable to create directory /var/www/app/../web//var/www/app/../htdocs/css  

I also try writing in: (nothing works)

app/console assetic:dump web
app/console assetic:dump .
app/console assetic:dump /var/www/web

I configured assetic like this:

assetic:
    debug:          %kernel.debug%
    use_controller: false
    read_from: "%kernel.root_dir%/../web"
    write_to: "%kernel.root_dir%/../web"
    bundles:
      - MyCodeBundle
      - NextCodeBundle
    #java: /usr/bin/java
    filters:
        lessphp:
            file: %kernel.root_dir%/../vendor/oyejorge/less.php/lessc.inc.php
            apply_to: "\.less$"
        cssrewrite: ~

I use also BraincraftedBootstrapBundle to use Twitter Bootstrap Js/CSS in my templates.

Where I can fix the path of assetic:dump?

1
Do you have symlinks within your SF installation?lxg
yes, web is a symlink to another directory. is that a problem? in a special environment, it's necessary, that "web" is named "htdocs", so i created a "htdocs" directory and web is a symlink to this.rickroyce
Yup, it looks like there's a problem with resolving that symlink. Don't know if it's a bug in SF/Assetic or a problem with your setup. Which SF version are you using?lxg
Ok, thx. I'll check that. Nice idea. I had problems with all Symfony Versions since 2.3. I also tried 2.5 and updated yesterday to 2.7 to check if the "bug" is gone. Thanks in advance, I try to find the broken symlink in the filesystem.rickroyce
It turns out that the Bundle called BraincraftedBootstrapBundle was buggy and mishandle the path to assets. After removing it to add Twitter Bootstrap manually, everything works fine.rickroyce

1 Answers

0
votes

As discussed in the comments, there seems to be a problem with the symlink from web to htdocs. Don't know if it's a bug in Symfony/Assetic or your local installation.

However, you don't even need that symlink. If you need the document root to be named htdocs, you can tell Symfony to use that directory:

In the application's composer.json, there should be an entry "symfony-web-dir": "web". Change the value to htdocs, and you should be fine. You should also remove the symlink from web to htdocs, to avoid confusion.

I haven't tested this, but I'd expect all Symfony distribution packages, including Assetic, to respect this setting. If Assetic doesn't, simply call Assetic with htdocs as target parameter.

And, you should remove the read_from and write_to parameters from your configuration. Your values are the default anyway, so there's no need to hardcode them.

Hope this helps.