Spea / SpBowerBundle

Symfony2 Bundle to handle asset dependencies with bower
231 stars 44 forks source link

Delete cache files will cause error in dev env #20

Closed sliver closed 11 years ago

sliver commented 11 years ago

Hi,

I'm use symfony 2.1.8. In the dev env, execute "rm -rf app/cache/*" will cause error. Without install sp/bower-bundle, this command would remove all cache files, and rebuild during the first request.

RuntimeException: An error occurred while executing the command 'bower' 'list' '--map'. The error was: "sh: bower: command not found" in /Users/sliver/projects/my/vendor/sp/bower-bundle/Sp/BowerBundle/Bower/Bower.php line 219 at Bower->execCommand(object(Configuration), array('list', '--map')) in /Users/sliver/projects/my/vendor/sp/bower-bundle/Sp/BowerBundle/Bower/Bower.php line 82 at Bower->createDependencyMappingCache(object(Configuration)) in /Users/sliver/projects/my/vendor/sp/bower-bundle/Sp/BowerBundle/CacheWarmer/DependencyCacheWarmer.php line 67 at DependencyCacheWarmer->warmUp('/Users/sliver/projects/my/app/cache/dev') in /Users/sliver/projects/my/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/CacheWarmer/CacheWarmerAggregate.php line 47 at CacheWarmerAggregate->warmUp('/Users/sliver/projects/my/app/cache/dev') in /Users/sliver/projects/my/app/bootstrap.php.cache line 873 at Kernel->initializeContainer() in /Users/sliver/projects/my/app/bootstrap.php.cache line 573 at Kernel->boot() in /Users/sliver/projects/my/app/bootstrap.php.cache line 616 at Kernel->handle(object(Request)) in /Users/sliver/projects/my/web/app_dev.php line 25

daFish commented 11 years ago

Check if your bower executable is callable from PHP. If not, add the path to bower to your PATH environment variable.

sliver commented 11 years ago

I try to address this issue, but no luck, can you give me some hint?

I use osx 10.8.3, php 5.4 installed by homebrew.

I add /usr/local/share/npm/bin into /etc/paths.d/ and check

$ echo $PATH
/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/share/npm/bin

Looks like it should work, but still got the same error.

Use Process to echo $PATH, return /usr/gnu/bin:/usr/local/bin:/bin:/usr/bin:.

$process = new \Symfony\Component\Process\Process('echo $PATH');
$process->run();
Spea commented 11 years ago

Can you paste your configuration from the bundle please?

sliver commented 11 years ago
sp_bower:
    bin: /usr/local/share/npm/bin/bower
    bundles:
        MyBundle: ~

node.js was installed by homebrew. bower was installed by npm and works great in command line.

daFish commented 11 years ago

Do you use php-fpm? If so, you can specify the needed environment variable:

; Pass environment variables like LD_LIBRARY_PATH. All $VARIABLEs are taken from
; the current environment.
; Default Value: clean env
;env[HOSTNAME] = $HOSTNAME
env[PATH] = /usr/local/bin:/usr/bin:/bin
;env[TMP] = /tmp
;env[TMPDIR] = /tmp
;env[TEMP] = /tmp
sliver commented 11 years ago

Thank you, @daFish

Yes, I use php-fpm. Specify the environment fixed my problem.