fxpio / composer-asset-plugin

NPM/Bower Dependency Manager for Composer
MIT License
893 stars 156 forks source link

Bootstrap 3.3.6 can not be installed together with jQuery 2.1.4 #170

Closed SDKiller closed 8 years ago

SDKiller commented 8 years ago

I have plugin version 1.1.1 and updated to latest composer version.

I've noticed that in my Yii2 project bootstrap is not beeing updated to version 3.3.6 so I tried to define its version explicitly:

- Installation request for bower-asset/bootstrap 3.3.6 -> satisfiable by bower-asset/bootstrap[v3.3.6].
- bower-asset/bootstrap v3.3.6 requires bower-asset/jquery >=1.9.1,<=2 -> no matching package found.

To reproduce you can just:

    "require": {
        "bower-asset/jquery": "2.1.4",
        "bower-asset/bootstrap": "3.3.6"
    },

As I can see - problem was introduced by twbs bower.json change https://github.com/twbs/bootstrap/commit/9b1a213cf758e1b60e20c59a721a63e13da098f7

   "dependencies": {
      "jquery": "1.9.1 - 2"
   }

And there were related #129, #137 and the problem was reported to be fixed.

But in this particular case version contraint is misinterpreted - according to https://github.com/bower/spec/blob/master/json.md#dependencies

Value must be a valid semver range...

with reference to https://github.com/npm/node-semver#hyphen-ranges-xyz---abc where we see in example:

1.2.3 - 2 := >=1.2.3 <3.0.0

So all 2.x.x versions should satisfy.

SDKiller commented 8 years ago

Another example to reproduce:

    "require": {
        "bower-asset/startbootstrap-sb-admin-2": "1.0.8"
    },

Output:

...
- bower-asset/startbootstrap-sb-admin-2 v1.0.8 requires bower-asset/bootstrap ~3.3.6 -> satisfiable by bower-asset/bootstrap[v3.3.6].
- bower-asset/startbootstrap-sb-admin-2 v1.0.8 requires bower-asset/morrisjs ~0.5.1 -> satisfiable by bower-asset/morrisjs[0.5.1].
...
- bower-asset/bootstrap v3.3.6 requires bower-asset/jquery >=1.9.1,<=2 -> satisfiable by bower-asset/jquery[2.0.0, 1.11.3, 1.11.2, 1.11.1, 1.11.0, 1.10.2, 1.10.1, 1.10.0, 1.9.1].
...
- bower-asset/morrisjs 0.5.1 requires bower-asset/jquery >=2.1.0 -> satisfiable by bower-asset/jquery[2.1.4, 2.1.3, 2.1.2, 2.1.1, 2.1.0].
...

Only bootstrap:

    "require": {
        "bower-asset/bootstrap": "3.3.6"
    },

Output:

  - Installing bower-asset/jquery (2.0.0)
    Downloading: 100%

  - Installing bower-asset/bootstrap (v3.3.6)
    Downloading: 100%
francoispluchino commented 8 years ago

Indeed, there is a problem.

jmontoyaa commented 8 years ago

Maybe the problem is that in bootstrap they use the letter "v" in the name of the tag "v3.3.x"? jquery just use numbers ...

SDKiller commented 8 years ago

@jmontoyaa

As far as I see, the problem is in different interpretation of hyphen ranges with composer and bower / npm.

For composer range 1.9.1 - 2 means ">= 1.9.1 and <= 2.0.0" And for bower / npm - ">= 1.9.1 and < 3.0.0"

francoispluchino commented 8 years ago

Fixed by 2bc14ef31b302d05fe84bd4ef88d5ba2314580bf.

SDKiller commented 8 years ago

Great!

Updating dependencies (including require-dev)
  - Removing bower-asset/jquery (2.1.4)
  - Installing bower-asset/jquery (2.2.4)
    Downloading: 100%

  - Removing bower-asset/bootstrap (v3.3.5)
  - Installing bower-asset/bootstrap (v3.3.6)
    Downloading: 100%
sokai commented 8 years ago

@SDKiller How did you make it?

I just updated the global composer-asset-plugin to dev-master an have the following in my local composer.json:

[…]
"bower-asset/bootstrap": "^3",
"bower-asset/jquery": "^2",
[…]

After the local update I have the following versions installed:

12:42 $ composer global show
    […]
    fxp/composer-asset-plugin dev-master 7f3338b NPM/Bower Dependency Manager for Composer
12:42 $ composer show
    […]
    bower-asset/bootstrap               v3.3.5  The most popular front-end framework for developing responsive, mobile first projects on the web.
    bower-asset/jquery                  2.2.4

→ What I'm missing?

Thanks and best regards!

SDKiller commented 8 years ago

@sokai

Try to check - may there is another dependency which prevents bootstrap from updating.

Btw, I updated after 2bc14ef31b302d05fe84bd4ef88d5ba2314580bf

sokai commented 8 years ago

@SDKiller thanks for your reply!

Here are my packages – maybe that can help:

    "require": {
        "slim/slim": "^3",
        "slim/twig-view": "^2",
        "tracy/tracy": "^2",
        "illuminate/database": "^5",
        "vlucas/valitron": "^1",
        "respect/validation": "^1",
        "slim/csrf": "^0.6",
        "slim/flash": "^0.1",
        "fxp/composer-asset-plugin": "^1",
        "bower-asset/bootstrap": "^3",
        "bower-asset/font-awesome": "^4",
        "bower-asset/jquery": "^2",
        "bower-asset/moment": "^2",
        "bower-asset/perfect-tooltip": "^1.6",
        "bower-asset/datatables.net": "^1",
        "bower-asset/datatables.net-bs": "^1"
    },
    "extra": {
      "asset-installer-paths": {
        "bower-asset-library": "public/assets/components",
        "npm-asset-library": "public/assets/components"
      }
    }
SDKiller commented 8 years ago

Why do you include fxp/composer-asset-plugin in your project composer.json? It makes no sense in project scope.

Btw, fresh install with you require succeeded:

...
  - Installing bower-asset/jquery (2.2.4)
    Loading from cache

  - Installing bower-asset/bootstrap (v3.3.6)
    Loading from cache
...

Try to clean composer cache, remove composer.lock and installed.json. Sometimes only deleting entire vendor folder helps.

sokai commented 8 years ago

@SDKiller Well done! :-) Thanks a lot!