58

I was updating my yii2 via composer then reverted back to the old beta version.

Here is the error on my composer:

Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - The requested package bower-asset/jquery could not be found in any version, there may be a typ
o in the package name.

Potential causes:
 - A typo in the package name
 - The package is not available in a stable-enough version according to your minimum-stability setti
ng
   see <https://groups.google.com/d/topic/composer-dev/_g3ASeIFlrc/discussion> for more details.

Read <http://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.

Tried searching for bower-asset/jquery at packagist but it is not found.

Thanks for the help :)

Jefren Inocando
  • 1,616
  • 2
  • 12
  • 13
  • 1
    They are re factoring the asset managet part. There have been changes several hours ago. https://github.com/yiisoft/yii2-app-advanced/commit/457b8730e2bc99ce91e35f063c240668ed938647 – Mihai P. Sep 17 '14 at 06:37
  • 2
    Damn. This is not the time to experiment and make newcomers give up on Yii. Many people will probably try other frameworks if their first install doesn't 'just work'. – Felipe Oct 15 '14 at 03:18

8 Answers8

101

Finally fixed it, just followed the steps on the UPGRADE.md doc

If you are using Composer to upgrade Yii, you should run the following command first (once for all) to install the composer-asset-plugin:

composer global require "fxp/composer-asset-plugin:^1.2.0"

(See http://www.yiiframework.com/doc-2.0/guide-start-installation.html#installing-from-composer for latest version.)

You may also need to add the following code to your project's composer.json file :

"extra": {
    "asset-installer-paths": {
        "npm-asset-library": "vendor/npm",
        "bower-asset-library": "vendor/bower"
    }
}

Hopes this helps :)

Chloe
  • 21,167
  • 37
  • 143
  • 289
Jefren Inocando
  • 1,616
  • 2
  • 12
  • 13
  • 1
    I had to run php composer.phar global require "fxp/composer-asset-plugin:1.0.0-beta1" instead of php composer.phar global require "fxp/composer-asset-plugin:1.0.*@dev" – VeYroN Sep 20 '14 at 17:20
  • Thank you this helped me a lot :) – user3640056 Apr 23 '15 at 11:11
  • I found that if I already ran `composer update` before doing this, I had to remove the `vendor/` folder or the error would persist. – cornernote Aug 17 '15 at 07:31
  • As of 06/23/2017... I had to do the following `sudo composer self-update` & `composer global require "fxp/composer-asset-plugin:^1.3.1"` I did not have to add the "extra" section to composer.json. – Craig London Jun 23 '17 at 13:53
  • 1
    Note: Bower has changed their registry URL some time ago and has now announced to [deprecate the old URL](https://twitter.com/bower/status/921039231623024640). Old registry will be disabled on October 31, 2017. In order for your work not to be affected make sure to update your composer asset plugin to the latest version: `composer global require "fxp/composer-asset-plugin:^1.4.2"` – Gianpaolo Scrigna Nov 02 '17 at 08:08
17

For me helps to remove folder ~/.composer and execute command:

php composer.phar global require "fxp/composer-asset-plugin:1.*"

Then just run again

php composer.phar update
s_mart
  • 705
  • 7
  • 21
Ilya Kolesnikov
  • 544
  • 6
  • 15
  • 1
    Or to get the latest stable version: php composer.phar global require "fxp/composer-asset-plugin" – sonofagun Feb 06 '16 at 23:15
  • 1
    If you don't have a composer.phar this should also work: composer global require "fxp/composer-asset-plugin:~1.1" – jsh Jun 07 '16 at 17:57
11

Found a cleaner solution. Just add following repository in your composer.json file

"repositories": [
 {
  "type": "composer",
  "url": "https://asset-packagist.org"
 }
]

and watch the magic

Shahzad Malik
  • 461
  • 4
  • 6
  • It solved my bower-asset/amcharts-stock composer updation error....! Many Thanks..!!!!!! – Gru Jun 29 '18 at 09:53
  • This no longer works. asset-packagist.org appears like an abandoned project. The packages are often unavailable, so you must manually go to that website and "update" each and every one of them. – mae Oct 26 '19 at 14:56
5

If you don't want to use fxp/composer-asset-plugin then all you have to do is to follow these simple instructions from Yii2 documentation.

Using asset-packagist repository

This way will satisfy requirements of the majority of projects, that need NPM or Bower packages.

Note: Since 2.0.13 both Basic and Advanced application templates are pre-configured to use asset-packagist by default, so you can skip this section.

In the composer.json of your project, add the following lines:

"repositories": [
    {
        "type": "composer",
        "url": "https://asset-packagist.org"
    }
]

Adjust @npm and @bower aliases in you application configuration:

$config = [
    ...
    'aliases' => [
        '@bower' => '@vendor/bower-asset',
        '@npm'   => '@vendor/npm-asset',
    ],
    ...
];

Visit asset-packagist.org to know, how it works.

hserge
  • 795
  • 1
  • 8
  • 10
1

If you don't need the update for bower-asset, you can require yidas/yii2-composer-bower-skip before yiisoft/yii2. in composer.json file:

"require": {
    "php": ">=5.4.0",
    "yidas/yii2-composer-bower-skip": "~2.0.0",
    "yiisoft/yii2": "~2.0.5",
    "yiisoft/yii2-bootstrap": "~2.0.0"
}

After that, you can update Composer smoothly without bower-asset.

See https://github.com/yidas/yii2-composer-bower-skip

Nick Tsai
  • 2,961
  • 28
  • 32
0

As described in YII2 repository documentation: https://asset-packagist.org/site/about We can solve this problem by adding aliases on those folders in our config. It will looks like that:

   $config = [
      ...
     'aliases' => [
        '@bower' => '@vendor/bower-asset',
        '@npm'   => '@vendor/npm-asset',
     ],
     ...
  ];

It works perfectly!

0

Simple and clean solution:

In composer.json just replace the bower-asset/jquery line with: "yidas/yii2-bower-asset":"*"


I propose we add also bower-asset/datatables to the yidas/yii2-bower-asset


My Problems with accepted solution of adding fxp/composer-asset-plugin are that the plugin is significantly slowing down the composer system, impacts everywhere, isn't always portable across operating systems and environments, has errors with PHP7.2 relating to inconsistent method names. So, I prefer my quicker to develop, faster at runtime, more local, and more compatible solution.

Aditya Mittal
  • 1,505
  • 13
  • 11
0

I tried all the mentioned steps like adding following in main.php

$config = [
    ...
    'aliases' => [
        '@bower' => '@vendor/bower-asset',
        '@npm'   => '@vendor/npm-asset',
    ],
    ...
];

composer.json

"repositories": [
 {
  "type": "composer",
  "url": "https://asset-packagist.org"
 }
]

Doing "composer install/update" was still not installing bower packages given by yii2-bootstrap.

I found, I was using composer.phar 2x to set this up. I downgraded composer.phar to 1x and all works well without having the need of fxp/composer-asset-plugin plugin.

Terry
  • 177
  • 10