Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Using an invalid version value in bower.json silently fails #439

Closed
craigjennings11 opened this Issue · 5 comments

5 participants

@craigjennings11

In the process of resolving #436, we discovered that having an invalid version value in your bower.json causes installation to silently fail.

$ bower -v
0.9.2

$ cat .bowerrc 
{
  "directory": "public/js/vendor"
}

$ cat bower.json 
{
  "name": "app",
  "version": "0.0.1",
  "dependencies": {
    "backbone-amd": "1.0.0",
    "hogan": null,
    "jquery": "1.9.1",
    "requirejs": "2.1.5",
    "requirejs-text": "2.0.5",
    "underscore-amd": "1.4.4"
  }
}

$ bower install
bower cloning git://github.com/amdjs/backbone
bower cached git://github.com/amdjs/backbone
bower fetching backbone-amd
bower cloning git://github.com/amdjs/underscore.git
bower cloning git://github.com/requirejs/text
bower cached git://github.com/amdjs/underscore.git
bower fetching underscore-amd
bower cached git://github.com/requirejs/text
bower fetching requirejs-text
bower checking out backbone-amd#1.0.0
bower copying /home/<name>/.bower/cache/backbone-amd/44d7359c7e3955d0116e5065406bfeea
bower checking out underscore-amd#1.4.4
bower copying /home/<name>/.bower/cache/underscore-amd/8e314e18ef602ee242d3d16dc2c7478d
bower checking out requirejs-text#2.0.5
bower copying /home/<name>/.bower/cache/requirejs-text/c95a5152b859fd06bd5d98f8cbf4afe9
bower cloning git://github.com/jrburke/requirejs
bower cached git://github.com/jrburke/requirejs
bower fetching requirejs
bower cloning git://github.com/components/jquery.git
bower cached git://github.com/components/jquery.git
bower fetching jquery
bower checking out jquery#1.9.1
bower warn Package jquery is still using the deprecated "component.json" file
bower copying /home/<name>/.bower/cache/jquery/29cb4373d29144ca260ac7c3997f4381
bower checking out requirejs#2.1.5
bower copying /home/<name>/.bower/cache/requirejs/ca377b0e482cd657ed20ebfa063ade1a

Notice that the hogan dependency has an invalid version of null, but instead of erroring out with a helpful message, bower silently fails when it tries to resolve the dependency. Replacing null with "*" will make bower install succeed.

@davidmaxwaterman

FYI, I've been working on this issue.

@wibblymat
Owner

@davidmaxwaterman Argh, I put in PR #480 a little while ago for this. I should have pinged this issue to say I was working on it :/

@davidmaxwaterman

FWIW, my solution was :

--- a/lib/core/package.js
+++ b/lib/core/package.js
@@ -65,7 +65,7 @@ var Package = function (name, endpoint, manager) {
       this.gitUrl = (RegExp.$1 || RegExp.$2) + '://' + RegExp.$3;
       this.tag    = RegExp.$4;

-    } else if (semver.validRange(endpoint)) {
+    } else if (semver.validRange(""+endpoint)) {
       this.tag = endpoint;
       this.explicitName = false;

@@ -115,6 +115,10 @@ var Package = function (name, endpoint, manager

     // Generate a resource id
     if (this.gitUrl) this.generateResourceId();
+  } else {
+    if (this.manager) {
+      this.manager.emit('error', new Error('Endpoint is null'));
+    }
   }

   if (this.manager) {
@SimplGy

This got me too :)

@wibblymat wibblymat referenced this issue from a commit
@wibblymat wibblymat Don't fail silently when no version specified in the JSON (#439) - Ma…
…ke having a blank version be an error.
607e160
@wibblymat wibblymat referenced this issue from a commit in wibblymat/bower
@wibblymat wibblymat Don't fail silently when no version specified in the JSON (#439) - Ma…
…ke having a blank version be an error.
ac7d6db
@satazor
Owner

Fixed in: #480

@satazor satazor closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.