Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change bower's default cache folder?

On *nix, bower uses the ~/.bower folder for its cache (packages and so on).
I would like to change this to a different location.

The bower spec document from suggests that I configure the storage key in my .bowerrc.

I have created one in my project folder like so:

{
  "storage": {
     "cache": "~/blah/cached",
     "git": "~/blah/git_templates"
  }
}

When running bower install - i see that it still tries to save into ~/.bower.

Can anyone tell me what I am doing wrong here ? And/or if there is a different way to change the location ?

like image 802
ab.su.rd Avatar asked Jul 26 '13 12:07

ab.su.rd


2 Answers

I had the same problem, after some tries according the spec, I gave up...

So I reviewed bower's history on github and found:

  • Before v0.10.0, bower used config.cache (lib/core/ResolveCache.js) for its cache location
  • After that, satazor rewrote bower's core, now using config.storage.cache at the beginning, i bet the spec doc was written at this time. From the spec:

storage [object]

Where to store persistent data, such as cache, needed by bower. Defaults to paths that > suite the OS/platform. Valid keys are cache, registry, links, completion.

  • However, after this commit, satazor now uses config.storage.packages instead of config.storage.cache

  • After that, in the v1.0.0 release, the config is always set to config.storage.packages, but the spec has not reflected this change ever since

Solution

  • Export the environment variable bower_storage__packages
  • Use a .bowerrc such as:

    {
      "storage":{
          "packages":"/path/to/cache"
      }
    }
    

P.S.: I think that linking the spec doc in Google Docs isn't a good idea, maybe github would be a more sensible choice (since we can issue pull requests).

like image 186
knightli Avatar answered Nov 05 '22 14:11

knightli


What version of bower are you using? Bower 1.0.0 no longer uses ~/.bower. It follows the XDG spec, http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html

The "storage" property is only valid for 1.0.0.

like image 44
satazor Avatar answered Nov 05 '22 12:11

satazor