Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add a configuration parameter for the bower cache storage directory #98

Open
ghost opened this issue Jul 12, 2014 · 14 comments
Open

add a configuration parameter for the bower cache storage directory #98

ghost opened this issue Jul 12, 2014 · 14 comments

Comments

@ghost
Copy link

ghost commented Jul 12, 2014

during the bower installation phase it creates a cache directory here:

/path/to/bundles/AcmeBundle/Resources/config/bower/../../public/components/cache

I don't think it should attempt to write anywhere except the symfony cache and the target asset location.

It is possible to configure these directories via this entry in a .bowerrc:

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

as per this stackoverflow post: http://stackoverflow.com/questions/17881116/how-to-change-bower-default-cache-git-templates-completion-folder-locations/18564317#18564317

or this with the bower command itself:

--config.storage.packages=/path/to/cache

although there could be some problems with that as per this bower issue:
bower/bower#1043 if the build system is not connected to the internet.

This is my first time using bower, so my assessment of how to solve this problem could be incorrect.

@nicodmf
Copy link

nicodmf commented Jul 14, 2014

I think this command sp:bower:install could be used to prepare a server and without the obligation to reload it after each deploy.

So to have a different cache than symfony seem to me a good idea. As i can commit the spbower cache and leave the symfony cache clear. All my server don't have php and nodejs installed together (a security hole for now : debian having not yet a prod version of nodejs)

@jrobeson Or maybe are you right with this another solution :

Even without cache the bundle should give js and css corresponding only to package name.

@Spea
Copy link
Owner

Spea commented Jul 15, 2014

The cache from bower has nothing to do with the cache from this bundle. The cache from this bundle is used to store the mapping received from bower list --json, so it is not necessary to always execute this command when a registered asset is called.

@ghost
Copy link
Author

ghost commented Jul 15, 2014

i know that, but i mean specifying the cache in the .bowerrc so bower won't try to write a cache in an unwriteable directory

@Sander-Toonen
Copy link

I agree. Every now and then I get the message: InvalidArgumentException: The directory "/foo/BarBundle/Resources/config/bower/../../public/components/cache" is not writable.

This cache folder should not be in my bundle directory structure but rather somewhere in app/cache.

@Spea
Copy link
Owner

Spea commented Jul 24, 2014

@Xatoo You can already do that

sp_bower:
    bundles:
        FooBundle:
            cache: /path/do/different/cache-dir

The cache @jrobeson describes is the one from bower itself and has nothing to do with the cache you want to change :)

@Sander-Toonen
Copy link

@Spea Ow, that is awesome! Sorry for the confusion.

@ghost
Copy link
Author

ghost commented Jul 24, 2014

@Spea : regarding your last response: but why is the default to ever write there?

@Spea
Copy link
Owner

Spea commented Jul 24, 2014

There were some errors when using the app/cache directory for this cache. Also it was kinda slow to recreate the asset-cache on every cache:warmup, thats why I decided to use another directory as the default one, but you can still change it ;)

@nicodmf
Copy link

nicodmf commented Oct 7, 2014

So i understand better as the cache works.

Event that, I have yet a problem with the actual cache :

Recreated the sp cache, demand bower list --json to be callable, and as the spcache store the absolute path, it seems to me that it is not possible to send it to a server without node.js installed.

@Spea
Copy link
Owner

Spea commented Oct 7, 2014

I will try to change this behaviour.

@Wirone
Copy link

Wirone commented Feb 24, 2015

What is the correct way to provide custom cache service? In order to fix our issue described in #123 I wanted to set service for cache:

sp_bower:
    bundles:
        OurBundle:
            cache:
                id: our_bundle.cache.bower_dependencies
our_bundle.cache.bower_dependencies:
        class: BPO\OurBundle\Service\Cache\BowerDependenciesCache
        arguments: [ "%kernel.cache_dir%/../bower_dependencies", ".sp_bower.data" ]

I always get exception:

[RuntimeException]
  Cache service with id [our_bundle.cache.bower_dependencies] not found

When I dump available services ($container->getDefinitions()) in Sp\BowerBundle\DependencyInjection\SpBowerExtension::createCache() I get:

array(9) {
  [0]=>
  string(25) "sp_bower.filesystem_cache"
  [1]=>
  string(32) "sp_bower.dependency_cache_warmer"
  [2]=>
  string(22) "sp_bower.exec_listener"
  [3]=>
  string(30) "sp_bower.cache_create_listener"
  [4]=>
  string(14) "sp_bower.bower"
  [5]=>
  string(22) "sp_bower.bower_manager"
  [6]=>
  string(32) "sp_bower.package_naming_strategy"
  [7]=>
  string(30) "sp_bower.assetic.config_loader"
  [8]=>
  string(31) "sp_bower.assetic.bower_resource"
}

So it's impossible to use custom (external) service?

@liviucmg
Copy link

liviucmg commented Jun 6, 2015

I tried using the default app/cache/(dev|env) folder, but it gets cleared on every app/console cache:clear, as @Spea mentioned.

So, I figured why not use something like app/cache/bower/(dev|env), since app/cache is already writeable and app/cache/bower does not get cleared automatically.

sp_bower:
    bundles:
        AppBundle:
            cache: %kernel.cache_dir%/../bower/%kernel.environment%

Could there be any downsides to this that I am unaware of?

Thanks!

@AlmogBaku
Copy link

@liviucmg that's actually a really good idea! +1

@AlmogBaku
Copy link

actually i discovered that @liviucmg is a very problematic solution, since the cache should not be created for every environment.
this is the best solution that i found:

sp_bower:
    bundles:
        AppBundle:
            cache: %kernel.cache_dir%/../bower

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants