Path does not exist

I just finished moving my application from the basic template to the advanced template. Everything was working smoothly, when right in front of my eyes, links started breaking for one of the classes, and then finally I got the dreaded:

Invalid Parameter – yii\base\InvalidParamException

The file or directory to be published does not exist: mysite/.../frontend/vendor/bower/jquery/dist

This problem is discussed at length here:

I have tried all of the suggested solutions, but none of them work.

-composer self-update

-cleared composer cache

-composer global show -i gives fxp/composer-asset-plugin v1.2.0 NPM/Bower (I also tried older versions of fxp)

-removed and reinstalled the vendor directory

-composer.json contains

"asset-installer-paths": {

            "npm-asset-library": "vendor/npm",

            "bower-asset-library": "vendor/bower"


vendor/bower/jquery/dist exists and contains jquery.js and jquery.min.js.

Yii Version: 2.08

Any fresh ideas as to what could be causing this?

Now I’m perplexed. I’m looking at yii2/web/AssetManager::publish, which is throwing the error.

public function publish($path, $options = [])


        $path = Yii::getAlias($path);

        if (isset($this->_published[$path])) {

            return $this->_published[$path];


        //$src = realpath($path); var_dump($path); echo '<br>'; var_dump($src); die;

        if (!is_string($path) || ($src = realpath($path)) === false) { // var_dump($path); echo '<br>'; var_dump($src); die;

            throw new InvalidParamException("The file or directory to be published does not exist: $path");


        if (is_file($src)) {

            return $this->_published[$path] = $this->publishFile($src);

        } else {

            return $this->_published[$path] = $this->publishDirectory($src, $options);



The commented items are my additions.

When I include the two var_dump() statements before the if statement, I get:

string(57) "/var/www/vhosts/mysite/vendor/yiisoft/yii2/assets"

string(57) "/var/www/vhosts/mysite/vendor/yiisoft/yii2/assets"

When I include them after the if statement, I get:

string(64) "/var/www/vhosts/mysite/frontend/vendor/bower/jquery/dist"


What gives???

EDIT: Could realpath() be using an earlier cached version of $path? Has anyone seen this before and what is the resolution?

Now I’m getting a continual “Trying to copy a directory to itself or a subdirectory.” I think it has something to do with the asset publishing. I’m ready to start with a fresh install… :angry:

I`ve own solution:
in any web config file:

'on beforeRequest' => function () {
        \Yii::setAlias('@bower', __DIR__ . '/../vendor/bower-asset');