Run bower as root, maybe? How?

I have a local development server where I test a lot of things, now I play with bower to manage library dependencies in my Symfony2 project. After installing NodeJS (v0.10.31) and bower (1.3.9), I tried to run the sp:bower:install command, which belongs to Symfony2 SpBowerBundle from the console, as root :

 Symfony > sp:bower:install Installing bower dependencies for "TemplateBundle" into "/var/www/html/tanane/src/Tanane/TemplateBundle/Resources/config/bower/../../public/components" bower ESUDO Cannot be run with sudo Additional error details: Since bower is a user command, there is no need to execute it with superuser permissions. If you're having permission errors when using bower without sudo, please spend a few minutes learning more about how your system should work and make any necessary repairs. http://www.joyent.com/blog/installing-node-and-npm https://gist.github.com/isaacs/579814 You can however run a command with sudo using --allow-root option 

I know that adding --allow-root works, since I tested directly from bash, but apparently it is not allowed from the command line of the package. Now, is the only way to run bower as root to add --allow-root or does it exist in another way?

+44
bower symfony
04 Sep '14 at 18:45
source share
7 answers

Below is the answer for the symfony framework kit , but if you come here from Google using the phrase " bower root ", you have two options for solving this problem:

  • add --allow-root for the command
  • set a global bower configuration that will allow the running gazebo to root

Option 1: you can run bower as root by typing:

 bower install --allow-root 

root is allowed by setting the -allow-root command-line option

Option 2: uses a global configuration that allows root by creating a file: /root/.bowerrc which have the following configuration:

 { "allow_root": true } 



how to do it in SpBowerBundle symfony bundle:
you may not have set sp_bower.allow_root to true in the SpBowerBundle configuration

in the bundle configuration, by default you set something like this:

 allow_root: false # optional 

but you must have:

 allow_root: true 

so in app / config / config.yml add the configuration of this package

 sp_bower: allow_root: false # optional 

link to the bundle configuration (all settings): https://github.com/Spea/SpBowerBundle/blob/master/Resources/doc/configuration_reference.md

+115
Sep 04 '14 at 20:28
source share
β€” -

I fixed a similar problem by changing directory permissions:

 sudo chown -R $USER:$GROUP ~/.npm sudo chown -R $USER:$GROUP ~/.config 
+15
Sep 07 '15 at 10:43
source share

If you encounter this problem in Docker containers, just add this line to your Docker file:

 RUN echo '{ "allow_root": true }' > /root/.bowerrc 
+8
Feb 16 '17 at 20:56 on
source share

It might be silly, but for me bower install --allow-root does not work, but bower --allow-root install did using grunt-bower-install version 1.6.0

It was on a docker running as root, maybe someone will save time :)

+3
Mar 13 '17 at 10:59 on
source share

Faced with a similar problem when installing the swagger editor. Changed the following line in package.json from

 "bower-install": "bower install" 

to

 "bower-install": "bower install --allow-root" 
+2
Oct 02 '15 at 23:21
source share

This works for me (add -u option when docker starts)

bash docker run -it -v ${PWD}:/www -w /www -u node node ./node_modules/bower/bin/bower install

0
Jun 13 '17 at 17:24
source share

For my case, this is in Pom.xml, where I added as an argument, as shown below:

 <executable>bower</executable> <arguments> <argument>install</argument> <argument>--allow-root</argument> </arguments> 

If you need to avoid this option --allow - root, we can compile from the root user

0
Jun 28 '17 at 10:34 on
source share



All Articles