4

I recall reading somewhere that in bower you can install packages as subtrees, meaning that one project can use multiple versions of the same library.. with each version of the library acting as a dependency for other libraries that need the different versions.

as an example.. suppose I'm working on a project which uses both angular-google-maps and ui-slider.. angular-google-maps requires at least angular 1.2.18+ and ui-slider needs angular 1.0.8 ` I was hoping to get something like this (ie output of bower list):

├── angular#1.2.18
├─┬ angular-google-maps#1.1.2 extraneous (latest is 1.1.6)
│ ├── angular#1.2.18
│ └── ..
├─┬ angular-ui-slider#0.0.2
│ ├── angular#1.0.8
│ ├── ..

instead what happens is that when i attempt to install ui-slider on my existent project that already uses angular 1.2.18, I get this prompt:

Unable to find a suitable version for angular, please choose one:
    1) angular#~1.0.x which resolved to 1.0.8 and is required by angular-ui-slider#0.0.2 
    2) angular#1.2.5 which resolved to 1.2.5 and is required by angular-sanitize#1.2.5 
    3) angular#1.2.18 which resolved to 1.2.18 and is required by angular-brunch-seed 
    4) angular#>=1 which resolved to 1.2.19 and is required by angular-bootstrap#0.5.0 
    5) angular#~1.2.0 which resolved to 1.2.19 and is required by angular-masonry#0.8.1 
    6) angular#1.2.x which resolved to 1.2.19 and is required by angular-google-maps#1.1.2 
    7) angular#1.2.19 which resolved to 1.2.19 and is required by angular-animate#1.2.19 
    8) angular#* which resolved to 1.2.19 and is required by restangular#1.4.0

Prefix the choice with ! to persist it to bower.json

I naturally choose one to get 1.0.8:

[?] Answer: 1
bower angular#~1.0.x                    install angular#1.0.8
bower angular-ui-slider#~0.0.2          install angular-ui-slider#0.0.2

However when I run bower list I get:

├── angular#1.0.8 incompatible with 1.2.18 (1.2.18 available, latest is 1.3.0-build.2867+sha.f07af61)
├─┬ angular-animate#1.2.19 (latest is 1.3.0-build.2867+sha.f07af61)
│ └── angular#1.0.8 incompatible with 1.2.19 (1.2.19 available, latest is 1.3.0-build.2867+sha.f07af61)
├─┬ angular-bootstrap#0.5.0 (latest is 0.11.0)
│ └── angular#1.0.8 (1.3.0-build.2867+sha.f07af61 available)
├─┬ angular-cookies#1.2.5 (latest is 1.3.0-build.2867+sha.f07af61)
│ └── angular#1.0.8 incompatible with 1.2.5 (1.2.5 available, latest is 1.3.0-build.2867+sha.f07af61)
├─┬ angular-google-maps#1.1.2 extraneous (latest is 1.1.6)
│ ├── angular#1.0.8 incompatible with 1.2.x (1.2.19 available, latest is 1.3.0-
├─┬ angular-ui-slider#0.0.2
│ ├── angular#1.0.8 (latest is 1.3.0-build.2867+sha.f07af61)
..

question: why did bower make angular 1.0.8 the default angular and the one used for all my other libraries.. rather than keep angular 1.2.18 and just use angular 1.0.8 for angular-ui-slider?

abbood
  • 23,101
  • 16
  • 132
  • 246

1 Answers1

1

You can't have two versions of angular running at the same time. So bower asks you to choose the one you want to install. Here you choose 1, so it installs angular 1.0.8 dependency for all your package regardless of the compatibility.
It's a behaviour intended by design.

Freezystem
  • 4,494
  • 1
  • 32
  • 35
  • so is this specific to the angular library or is it for all libraries? – abbood Jun 10 '15 at 12:42
  • 1
    It's the same for all package in bower. For example : if you require angular-ui and angular-animate. They both require angular as dependency so bower will install it automatically for these packages. But bower is smart enough to ask you, when packages requires different version from the same library, what version you want to get. Telling you that angular-ui require this version of angular whereas angular-animate require that other one. You can see dependency for each package in /bower_components/name-of-package/bower.json – Freezystem Jun 10 '15 at 12:59
  • I think I did.. What I meant was that it will be the same for jQuery or any other package. Only one version of each library is downloaded in /bower_components/ because you can't load and use different version of the same library in parallel. That's not specific to angular. – Freezystem Jun 10 '15 at 13:26