TylerBrock / mongo-hacker

MongoDB Shell Enhancements for Hackers
tylerbrock.github.io/mongo-hacker
MIT License
1.79k stars 235 forks source link

Installation permission problems #154

Closed emrahgunduz closed 5 years ago

emrahgunduz commented 8 years ago

When I tried to install via npm, both installation and uninstall fails with permission errors. Even though I'm the root, script is not able to run as su. Trying with sudo also fails. Deleting current .mongorc.js file does not solve the problem.

> mongo-hacker@0.0.12 install /usr/lib/node_modules/mongo-hacker
> make install

cat config.js base.js hacks/color.js hacks/common.js hacks/aggregation.js hacks/old_aggregation.js hacks/uuid.js hacks/find_and_modify.js hacks/prompt.js hacks/auto_complete.js hacks/dbref.js hacks/helpers.js hacks/cmd_search.js hacks/show.js hacks/verbose.js hacks/api.js hacks/index_paranoia.js hacks/sh_status.js hacks/count.js > mongo_hacker.js
INSTALLATION
Linking MongoHacker to .mongorc.js in your home directory:
ln -sf "/usr/lib/node_modules/mongo-hacker/mongo_hacker.js" ~/.mongorc.js
ln: failed to access ‘/root/.mongorc.js’: Permission denied
Makefile:13: recipe for target 'install' failed
make: *** [install] Error 1
npm ERR! Linux 4.2.0-16-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install" "-g" "mongo-hacker"
npm ERR! node v4.3.1
npm ERR! npm  v2.14.12
npm ERR! code ELIFECYCLE

npm ERR! mongo-hacker@0.0.12 install: `make install`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the mongo-hacker@0.0.12 install script 'make install'.
npm ERR! This is most likely a problem with the mongo-hacker package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     make install
npm ERR! You can get their info via:
npm ERR!     npm owner ls mongo-hacker
npm ERR! There is likely additional logging output above.

> mongo-hacker@0.0.12 postuninstall /usr/lib/node_modules/mongo-hacker
> make uninstall

rm -f ~/.mongorc.js
rm: cannot remove ‘/root/.mongorc.js’: Permission denied
Makefile:27: recipe for target 'uninstall' failed
make: *** [uninstall] Error 1
npm WARN continuing anyway mongo-hacker@0.0.12 postuninstall: `make uninstall`
npm WARN continuing anyway Exit status 2

npm ERR! Please include the following file with any support request:
npm ERR!     /root/npm-debug.log
alx741 commented 8 years ago

Same here

Pavel-Evdokimov commented 8 years ago

I've same issue

97 error Linux 4.2.0-34-generic 98 error argv "/usr/bin/nodejs" "/usr/bin/npm" "install" "-g" "mongo-hacker" 99 error node v4.4.0 100 error npm v2.14.20 101 error code ELIFECYCLE 102 error mongo-hacker@0.0.13 install: make install 102 error Exit status 2 103 error Failed at the mongo-hacker@0.0.13 install script 'make install'. 103 error This is most likely a problem with the mongo-hacker package, 103 error not with npm itself. 103 error Tell the author that this fails on your system: 103 error make install 103 error You can get information on how to open an issue for this project with: 103 error npm bugs mongo-hacker 103 error Or if that isn't available, you can get their info via: 103 error 103 error npm owner ls mongo-hacker 103 error There is likely additional logging output above. 104 verbose exit [ 1, true ] 105 verbose unbuild lib/node_modules/mongo-hacker 106 info preuninstall mongo-hacker@0.0.13

jsdevtom commented 8 years ago

I can also confirm

jacksonfraga commented 8 years ago

have any solutions? old version?

jacksonfraga commented 8 years ago

git clone https://github.com/TylerBrock/mongo-hacker.git cd mongo-hacker edit file as commit https://github.com/TylerBrock/mongo-hacker/pull/156/commits/2a771e981f36561f1d4f951859901eb69440d3d2 sudo npm install -g

vacantgeologist commented 8 years ago

jacksonfraga: That's not working for me, I get prompted for a password for the user 'nobody', Ubuntu 16.04 LTS

The way I got around this was setting up npm install -g to not require sudo in the first place. Instructions with two options available at https://docs.npmjs.com/getting-started/fixing-npm-permissions

emrahgunduz commented 8 years ago

the error is still ongoing on some machines. the log is from amazon linux. even with root, creating the js file throws permission error.

is this a make error? you should remove make and just cat the js files to a single file.

> mongo-hacker@0.0.14 install /usr/lib/node_modules/mongo-hacker
> make install
cat config.js base.js hacks/color.js hacks/common.js hacks/aggregation.js hacks/old_aggregation.js hacks/uuid.js hacks/find_and_modify.js hacks/prompt.js hacks/auto_complete.js hacks/dbref.js hacks/helpers.js hacks/cmd_search.js hacks/show.js hacks/verbose.js hacks/randomise.js hacks/api.js hacks/index_paranoia.js hacks/sh_status.js hacks/count.js > mongo_hacker.js
INSTALLATION
Linking MongoHacker to .mongorc.js in your home directory:
ln -sf "/usr/lib/node_modules/mongo-hacker/mongo_hacker.js" ~/.mongorc.js
ln: failed to access ‘/root/.mongorc.js’: Permission denied
make: *** [install] Error 1
npm ERR! Linux 4.4.19-29.55.amzn1.x86_64
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "install" "-g" "mongo-hacker"
npm ERR! node v4.5.0
npm ERR! npm  v2.15.9
npm ERR! code ELIFECYCLE
npm ERR! mongo-hacker@0.0.14 install: `make install`
npm ERR! Exit status 2
npm ERR! 
npm ERR! Failed at the mongo-hacker@0.0.14 install script 'make install'.
npm ERR! This is most likely a problem with the mongo-hacker package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     make install
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs mongo-hacker
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! 
npm ERR!     npm owner ls mongo-hacker
npm ERR! There is likely additional logging output above.
> mongo-hacker@0.0.14 postuninstall /usr/lib/node_modules/mongo-hacker
> make uninstall
rm -f ~/.mongorc.js
rm: cannot remove ‘/root/.mongorc.js’: Permission denied
make: *** [uninstall] Error 1
npm WARN continuing anyway mongo-hacker@0.0.14 postuninstall: `make uninstall`
npm WARN continuing anyway Exit status 2
npm ERR! Please include the following file with any support request:
npm ERR!     /root/npm-debug.log
raulfdm commented 7 years ago

I was having the same problem, then I use the npm tutorial and it solve my problem. Thank's @vacantgeologist

sabrehagen commented 7 years ago

Still getting this issue:

➜  ~ git:(master) ✗ sudo npm install -g mongo-hacker

> mongo-hacker@0.0.15 install /usr/lib/node_modules/mongo-hacker
> make install

cat config.js base.js hacks/color.js hacks/ps.js hacks/aggregation.js hacks/old_aggregation.js hacks/uuid.js hacks/show.js hacks/find_and_modify.js hacks/prompt.js hacks/auto_complete.js hacks/dbref.js hacks/helpers.js hacks/cmd_search.js hacks/common.js hacks/verbose.js hacks/randomise.js hacks/api.js hacks/index_paranoia.js hacks/sh_status.js hacks/count.js > mongo_hacker.js
INSTALLATION
Linking MongoHacker to .mongorc.js in your home directory:
ln -sf "/usr/lib/node_modules/mongo-hacker/mongo_hacker.js" ~/.mongorc.js
ln: failed to access '/home/jackson/.mongorc.js': Permission denied
Makefile:13: recipe for target 'install' failed
make: *** [install] Error 1
npm ERR! Linux 4.4.0-75-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install" "-g" "mongo-hacker"
npm ERR! node v7.7.2
npm ERR! npm  v4.1.2
npm ERR! code ELIFECYCLE

npm ERR! mongo-hacker@0.0.15 install: `make install`
npm ERR! Exit status 2
npm ERR! 
npm ERR! Failed at the mongo-hacker@0.0.15 install script 'make install'.
gyscos commented 7 years ago

Apparently scripts are expected to be run as user nobody if npm is run as root. The nobody user doesn't seem to have write access to the target directory, hence the error.

A solution is to run npm as a regular user, but with write access to the install directory:

$ mkdir -p /usr/local/lib/node_modules
$ sudo chmod 777 /usr/local/lib/node_modules
$ npm install -g mongo-hacker
$ sudo chmod 755 /usr/local/lib/node_modules

Editted to fix permissions afterward.

Note that it's a pretty crappy hacky workaround, far from ideal from a security viewpoint. It shouldn't be required, and is not a real solution to this issue.

andersonn-roberto commented 6 years ago

I'm using Utuntu 16.04 here and with the steps below I installed mongo-hacker. $ sudo chmod ugo+x /usr/lib/node_modules $ npm install -g mongo-hacker

dantehemerson commented 5 years ago

If the folder /usr/lib/node_modules/mongo-hacker does not exist then create it. $ sudo mkdir /usr/lib/node_modules/mongo-hacker Then execute: $ sudo chmod 777 /usr/lib/node_modules/mongo-hacker $ npm install -g mongo-hacker

This work's for me I'm using Debian9