Yii2: The file or directory to be published does not exist: .../backend/vendor/bower/bootstrap/dist

Created on 11 Jan 2016  路  24Comments  路  Source: yiisoft/yii2

After composer update i have this problem with advanced template:
[error][yii\base\InvalidParamException] exception 'yii\base\InvalidParamException' with message 'The file or directory to be published does not exist: /var/www/vhosts/***/httpdocs/backend/vendor/bower/bootstrap/dist'

My composer.json:

{
  "name": "yiisoft/yii2-app-advanced",
  "description": "Yii 2 Advanced Application Template",
  "keywords": [
    "yii2",
    "framework",
    "advanced",
    "application template"
  ],
  "homepage": "http://www.yiiframework.com/",
  "type": "project",
  "license": "BSD-3-Clause",
  "support": {
    "issues": "https://github.com/yiisoft/yii2/issues?state=open",
    "forum": "http://www.yiiframework.com/forum/",
    "wiki": "http://www.yiiframework.com/wiki/",
    "irc": "irc://irc.freenode.net/yii",
    "source": "https://github.com/yiisoft/yii2"
  },
  "minimum-stability": "stable",
  "require": {
    "php": ">=5.4.0",
    "yiisoft/yii2": "*",
    "yiisoft/yii2-bootstrap": "*",
    "yiisoft/yii2-swiftmailer": "*",
    "kartik-v/yii2-icons": "*",
    "kartik-v/yii2-datecontrol": "*",
    "kartik-v/yii2-widget-select2": "*",
    "kartik-v/yii2-widget-fileinput": "*",
    "kartik-v/yii2-editable": "*",
    "kartik-v/yii2-grid": "*",
    "kartik-v/yii2-mpdf": "*",
    "kartik-v/yii2-money": "*",
    "wbraganca/yii2-dynamicform": "*",
    "philippfrenzel/yii2fullcalendar":"*",
    "uran1980/yii2-scroll-to-top": "*",
    "2amigos/yii2-ckeditor-widget" : "*",
    "alexgx/yii2-phpexcel": "dev-master",
    "bedezign/yii2-audit": "dev-master",
    "ercling/yii2-pace": "dev-master",
    "miloschuman/yii2-highcharts-widget": "dev-master"
  },
  "require-dev": {
    "yiisoft/yii2-codeception": "*",
    "yiisoft/yii2-debug": "*",
    "yiisoft/yii2-gii": "*",
    "yiisoft/yii2-faker": "*"
  },
  "config": {
    "process-timeout": 1800
  },
  "extra": {
    "asset-installer-paths": {
      "npm-asset-library": "vendor/npm",
      "bower-asset-library": "vendor/bower"
    }
  }
}

I try:

  • delete vendor folder;
  • delete composer.lock
  • composer self-update
  • composer global require "fxp/composer-asset-plugin:1.1.1"
  • composer global show -i
fxp/composer-asset-plugin v1.1.1 NPM/Bower Dependency Manager for Composer
  • composer global update
  • composer global clear-cache
  • composer update

Any ideas?

need more info

All 24 comments

Composer version:

composer -V
Composer version 1.0-dev (03299ff075236be27be356498d6c64def973fe41) 2016-01-10 20:34:53

Works fine on my local machine Widows 10, not working on production server Linux...

php -v

PHP 5.4.44 (cli)

Does composer update complete without any errors?
Please, show ls -l vendor/bower/bootstrap. Of if the dir is missing ls -l vendor

Composer complete without errors, vendor was update correctly.

ls -l vendor/bower/bootstrap
total 60
-rwxrwxrwx 1 root root   640 Jun 16  2015 bower.json
drwxrwxrwx 5 root root  4096 Jun 16  2015 dist
drwxrwxrwx 2 root root  4096 Jun 16  2015 fonts
drwxrwxrwx 2 root root  4096 Jan 11 03:50 grunt
-rwxrwxrwx 1 root root 14881 Jun 16  2015 Gruntfile.js
drwxrwxrwx 2 root root  4096 Jan 11 03:50 js
drwxrwxrwx 3 root root  4096 Jan 11 03:50 less
-rwxrwxrwx 1 root root  1084 Jun 16  2015 LICENSE
-rwxrwxrwx 1 root root   813 Jun 16  2015 package.js
-rwxrwxrwx 1 root root  2073 Jun 16  2015 package.json
-rwxrwxrwx 1 root root  6994 Jun 16  2015 README.md

It's really strange because

Make sure you have fxp plugin installed globally: http://www.yiiframework.com/doc-2.0/guide-start-installation.html#installing-via-composer

Does web server have permissions to read the files?

@samdark it is

composer global show -i
fxp/composer-asset-plugin v1.1.1 NPM/Bower Dependency Manager for Composer

@samdark , i hope this can help.

composer global require "fxp/composer-asset-plugin:~1.1.1"
Changed current directory to /root/.composer
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Nothing to install or update
Generating autoload file

and also:

composer global show -i
Changed current directory to /root/.composer
fxp/composer-asset-plugin v1.1.1 NPM/Bower Dependency Manager for Composer

@SilverFire , i change permessions to 0777 recursively for this tests..

If you've tried w/o it before, try cleaning up composer cache and deleting vendor dir before re-trying.

And kill composer.lock as well.

@samdark @SilverFire , i did that steps:

  • composer global clear-cache
Changed current directory to /root/.composer
Clearing cache (cache-dir): /root/.composer/cache
Clearing cache (cache-files-dir): /root/.composer/cache/files
Clearing cache (cache-repo-dir): /root/.composer/cache/repo
Cache directory does not exist (cache-vcs-dir):
All caches cleared.

Result is the same:

2016-01-11 11:39:29 [XX.XX.XX.XX][1][-][error][yii\base\InvalidParamException] exception 'yii\base\InvalidParamException' with message 'The file or directory to be published does not exist: /var/www/vhosts/XXXXXXXXXXXXXXXXXXX/httpdocs/backend/vendor/bower/bootstrap/dist' in /var/www/vhosts/XXXXXXXXXXXXXXXXXXX/httpdocs/vendor/yiisoft/yii2/web/AssetManager.php:452
Stack trace:
#0 /var/www/vhosts/XXXXXXXXXXXXXXXXXXX/httpdocs/vendor/yiisoft/yii2/web/AssetBundle.php(163): yii\web\AssetManager->publish('/var/www/vhosts...', Array)
#1 /var/www/vhosts/XXXXXXXXXXXXXXXXXXX/httpdocs/vendor/yiisoft/yii2/web/AssetManager.php(266): yii\web\AssetBundle->publish(Object(yii\web\AssetManager))
#2 /var/www/vhosts/XXXXXXXXXXXXXXXXXXX/httpdocs/vendor/yiisoft/yii2/web/AssetManager.php(237): yii\web\AssetManager->loadBundle('yii\\bootstrap\\B...', Array, true)
#3 /var/www/vhosts/XXXXXXXXXXXXXXXXXXX/httpdocs/vendor/yiisoft/yii2/web/View.php(284): yii\web\AssetManager->getBundle('yii\\bootstrap\\B...')

Before creating this issue, i read https://github.com/yiisoft/yii2/issues/6402 and https://github.com/yiisoft/yii2/issues/10198...

What am I forgetting??

Composer was updated correcly after deleting cache, fxp plugin is installed globally on the last version..

As described before, i have 2 environments :
1 . Local Windows 10, php 5.5.11 (cli) - WORKS FINE
2 . Production Centos 6.6, php 5.4.44 (cli) - STILL NOT WORKING

Are you running all composer-related commands via same user?

@samdark yes.. i run all command with root user, is it wrong?

If all commands are run with it, it should be kinda OK. Make sure he has home dir and that .composer is there.

.composer is under home root dir :(

cd /root/
ls -als
total 676
..................
  4 drwxr-xr-x  4 root root   4096 Jan 11 01:50 .composer
..................

I try to create a new project.

For basic application

..
composer self-update.
composer clear-cache.
composer create-project --prefer-dist yiisoft/yii2-app-basic test

and also for advanced

...
composer self-update.
composer clear-cache.
composer create-project --prefer-dist yiisoft/yii2-app-advanced test

Both projects works fine...

So i upload my files project, and:

...
rm -Rf vendor/
rm -f composer.lock
composer update

All works now... but why? Vendor folder is the same and packages installed are the same of before...

When you're running install or update w/o prior installing fxp it writes to .lock, vendor and cache. So installing fxp afterwards doesn't help. You need to clean all these. We're aware that it's a huge mess and for 2.1 we plan to do it w/o any global plugins required. For 2.0 it will stay as is...

@samdark thank you for the explanation, the important thing is solve the problem ;)
Not being so skilled with composer's dynamics, i tried other ways!
Actually i have not understood why on my local machine it works perfectly, without creating new project..!

rm -Rf vendor/
rm -f composer.lock
composer update

Fixed this issue for me.

Is there any solution without

rm -Rf vendor/
rm -f composer.lock

@pptyasar no, there is no other known solution.

None of the mentioned solutions work. You can wipe vendor, clear composer cache, remove the lock file, reinstall composer, wipe the global .composer folder, walk on your hands while juggling watermelons... The project wants the vendor folder to be inside backend or frontend no matter what you do.

What is causing this?

Looks like this is happening due to the following line:
'vendorPath' => dirname(dirname(__DIR__)) . '/vendor',

missing from the generated common main.php config file. No amount of re-updating & cache clearing will bring it back. Seems like it only gets added when calling create-project.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

skcn022 picture skcn022  路  3Comments

newscloud picture newscloud  路  3Comments

schmunk42 picture schmunk42  路  3Comments

Locustv2 picture Locustv2  路  3Comments

SamMousa picture SamMousa  路  3Comments