Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"assets:install" command fails with error "The target directory "web" does not exist", why?

I am running a Symfony3 application inside a Docker container. I have created a CommonBundle with all the resources (js, css, images). This resources are symlinked to another path as shown below:

$ docker exec -u www-data -it dockeramp_php_1 ls -la oneview_symfony/src/CommonBundle/Resources/public
total 8
drwxrwsr-x 2 www-data www-data 4096 Feb 23 21:09 .
drwxr-sr-x 5 www-data www-data 4096 Feb 23 20:54 ..
lrwxrwxrwx 1 root     www-data   32 Feb 23 21:09 css -> /var/www/html/public_html/styles
lrwxrwxrwx 1 root     www-data   32 Feb 23 21:09 images -> /var/www/html/public_html/images
lrwxrwxrwx 1 root     www-data   28 Feb 23 21:08 js -> /var/www/html/public_html/js

The directory oneview_symfony/web does exists and it's writable by www-data as shown below:

$ docker exec -u www-data -it dockeramp_php_1 ls -la oneview_symfony/web
total 64
drwxrwsr-x 3 www-data www-data  4096 Feb 23 20:50 .
drwxrwsr-x 9 www-data www-data  4096 Feb 23 21:16 ..
-rwxrwxr-x 1 www-data www-data  3319 Feb 23 16:45 .htaccess
-rwxrwxr-x 1 www-data www-data   631 Feb 23 16:45 app.php
-rwxrwxr-x 1 www-data www-data   843 Feb 23 16:45 app_dev.php
-rwxrwxr-x 1 www-data www-data  2092 Feb 23 16:45 apple-touch-icon.png
drwxr-sr-x 2 www-data www-data  4096 Feb 23 20:50 bundles
-rw-rw-rw- 1 www-data www-data 21486 Feb 23 20:50 config.php
-rwxrwxr-x 1 www-data www-data  6518 Feb 23 16:45 favicon.ico
-rwxrwxr-x 1 www-data www-data   116 Feb 23 16:45 robots.tx

I am trying to install the assets relative or symlink switching values on the composer.json file:

{
    ...
    "extra": {
        ... 
        "symfony-web-dir": "web",
        "symfony-assets-install": "relative",
    }
}

I am trying to publish the assets running the following command and ending up with the error below:

$ docker exec -u www-data -it dockeramp_php_1 php oneview_symfony/bin/console assets:install


  [InvalidArgumentException]                  
  The target directory "web" does not exist.

What I am missing here?

There is a similar issue here but without answer so far.

like image 797
ReynierPM Avatar asked Jan 04 '23 11:01

ReynierPM


2 Answers

Can you try this command instead:

$ docker exec -u www-data -it dockeramp_php_1 php oneview_symfony/bin/console assets:install web

If that doesn't work, try the full path to the web directory. Let us know if that works. Not sure if that will fix the problem, but please try it.

like image 194
Alvin Bunk Avatar answered Jan 07 '23 00:01

Alvin Bunk


For anyone trying to install assets in Symfony 4 with the old Symfony3 directory structure getting:

Error thrown while running command "assets:install". Message: "The target directory "public" does not exist."

The same fix Alvin Bunk provided works:

$ bin/console assets:install web

Just manually provide the old target path

like image 32
Yes Barry Avatar answered Jan 07 '23 01:01

Yes Barry