Skip to content

Loading…

installing local-tld via npm as sudo gives errors #10

Closed
nborwankar opened this Issue · 71 comments

9 participants

@nborwankar
  • sudo npm install -g local-tld or npm install -g local-tld

ends up in a prompt that asks for my sudo passwd but doesn't recognize it.

All other sudo commands work and my passwd works on those

  • just as an A/B test I tried sudo npm install -g request that works

Even when I have just used sudo a few seconds before on another command which worked I still get asked for my passwd and it fails.

i.e. the issue is not with my passwd it seems to be with the local-tld install script.

==== long - see transcript below

npm install -g local-tld
npm http GET https://registry.npmjs.org/local-tld
npm http 304 https://registry.npmjs.org/local-tld

> local-tld@3.0.2 preuninstall /usr/local/lib/node_modules/local-tld
> ./bin/local-tld-uninstall

+ sudo launchctl unload /Library/LaunchDaemons/ie.hood.local-tld-firewall.plist
Password:
+ launchctl unload /Users/nitin/Library/LaunchAgents/ie.hood.local-tld-service.plist
+ sudo rm -f /Library/LaunchDaemons/ie.hood.local-tld-firewall.plist
+ rm -f /Users/nitin/Library/LaunchAgents/ie.hood.local-tld-service.plist
+ sudo rm -f /etc/resolver/dev

> local-tld@3.0.2 preuninstall /usr/local/lib/node_modules/local-tld
> ./bin/local-tld-uninstall

+ sudo launchctl unload /Library/LaunchDaemons/ie.hood.local-tld-firewall.plist
launchctl: Couldn't stat("/Library/LaunchDaemons/ie.hood.local-tld-firewall.plist"): No such file or directory
nothing found to unload
npm WARN continuing anyway local-tld@3.0.2 preuninstall: `./bin/local-tld-uninstall`
npm WARN continuing anyway `sh "-c" "./bin/local-tld-uninstall"` failed with 1
npm ERR! error rolling back Error: EACCES, unlink '/usr/local/lib/node_modules/local-tld/.npmignore'
npm ERR! error rolling back  local-tld@3.0.2 { [Error: EACCES, unlink '/usr/local/lib/node_modules/local-tld/.npmignore']
npm ERR! error rolling back   errno: 3,
npm ERR! error rolling back   code: 'EACCES',
npm ERR! error rolling back   path: '/usr/local/lib/node_modules/local-tld/.npmignore' }
npm ERR! Error: EACCES, unlink '/usr/local/lib/node_modules/local-tld/.npmignore'
npm ERR!  { [Error: EACCES, unlink '/usr/local/lib/node_modules/local-tld/.npmignore']
npm ERR!   errno: 3,
npm ERR!   code: 'EACCES',
npm ERR!   path: '/usr/local/lib/node_modules/local-tld/.npmignore' }
npm ERR! 
npm ERR! Please try running this command again as root/Administrator.

npm ERR! System Darwin 11.4.2
npm ERR! command "node" "/usr/local/bin/npm" "install" "-g" "local-tld"
npm ERR! cwd /Users/nitin
npm ERR! node -v v0.10.3
npm ERR! npm -v 1.2.17
npm ERR! path /usr/local/lib/node_modules/local-tld/.npmignore
npm ERR! code EACCES
npm ERR! errno 3
npm ERR! stack Error: EACCES, unlink '/usr/local/lib/node_modules/local-tld/.npmignore'
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /Users/nitin/npm-debug.log
npm ERR! not ok code 0
[00:58][nitin@nitinmacbookpro:~]$ sudo npm install -g local-tld
npm http GET https://registry.npmjs.org/local-tld
npm http 304 https://registry.npmjs.org/local-tld

> local-tld@3.0.2 preuninstall /usr/local/lib/node_modules/local-tld
> ./bin/local-tld-uninstall

+ sudo launchctl unload /Library/LaunchDaemons/ie.hood.local-tld-firewall.plist

WARNING: Improper use of the sudo command could lead to data loss
or the deletion of important system files. Please double-check your
typing when using sudo. Type "man sudo" for more information.

To proceed, enter your password, or type Ctrl-C to abort.

Password:
Sorry, try again.
Password:
Sorry, try again.
Password:
sudo: 2 incorrect password attempts

actually I went to 3 more than once no difference

  • npm install local-tld works
@jbolila

I had an identical problem, that stopped happening when I went from the iTerm to Terminal, see this from homebrew wiki.

@janl
Hoodie member

wow, that is crazy obscure!

@nborwankar
@nborwankar
@bbn
bbn commented

Exact same sudo problem for me.
In case it's helpful, here's the npm install log: https://gist.github.com/bbn/5347136

@nborwankar
@janl
Hoodie member

@bbn it looks like you are on Mountain Lion (Like I am), is that correct?

@janl
Hoodie member

Is this an OS Version issue?

Maybe :)

Can Hoodie developers say on home page what OSX version including minor
version, this actually has been tested on. Perhaps only Lion has been tested? I am on Snow Leopard.

I know we did have issues on a Snow Leopard once, but I believe we fixed them, but the developer moved to Mountain Lion now, and I haven’t checked back.

I have a Snow Leopard that I can try this with at some point, but capacity at this very moment, so for now, yes, assume Latest Mac OS X.

Also versions of Ruby, Nodejs, Homebrew.

$ ruby -v
ruby 1.8.7 (2012-02-08 patchlevel 358) [universal-darwin12.0]
$ brew -v
Homebrew 0.9.4
$ node -v
v0.8.19

Does it matter if one is using OpenDNS

Shouldn’t, but you never know, Mac OS X’s DNS resolution ways are dark and mysterious (and changing between versions a lot).

  • does this interact badly with the mdns implementation used to create local-tld?

There is no mdns in local-tld.

Also just FYI - I have been using MacOSX for about 8 years now and I have
never seen sudo behavior like this.

10 years, same here.

Finally is it OK to install without the -g flag or is global install somehow critical to Hoodie performance?

Functionality, not performance. The post-install script of hoodie needs sudo to set up a firewall route to make the magic work. You can manually disable the postinstall and do all the steps by hand, but we made it nice and bundeld for you so you don’t have to fiddle with it in the first place.

@janl
Hoodie member

@nborwankar silly question, but you don’t happen to run into having caps lock set for typing the password that one time or anything?

@bbn
@janl
Hoodie member

@bbn excellent, thanks, do you have any other oddities on your system that might help resolve this, because I literally have no fucking clue why this should happen, albeit I admit that what we are doing (sudo in an npm postinstall script is pretty dirty.

@janl
Hoodie member

I just pushed a commit (e5c3233) and version 3.0.3 to NPM that might solve this. Can you give it a shot?

Note that you are expected to run npm install -g local-tld not sudo npm… If you get permission errors, try starting from scratch by doing sudo npm uninstall -g local-tld.

@nborwankar
@janl
Hoodie member

@nborwankar can you try the latest local-tld 3.0.3 I just pushed: #10 (comment)

@nborwankar
@nborwankar
@janl
Hoodie member
@janl
Hoodie member
@janl
Hoodie member

(3.0.4 now, don’t mind me fixing)

@nborwankar
@janl
Hoodie member

lolcopter :D

rm -rf the local-tld foler in your -g node_modules and manually run the contents of https://github.com/hoodiehq/local-tld/blob/master/bin/local-tld-uninstall

@nborwankar
@nborwankar
@pagameba

The reason this is breaking is because you are running npm with sudo and within the postinstall script it is running sudo on some embedded commands. The context for sudo in the postinstall script is then incorrect and matches no known user so no password will match. I think that it should incorporate something like this:

if [ id -u -eq 0 ]
then
mkdir -p /etc/resolver
cp $ETC/resolver.dev /etc/resolver/dev
cp $ETC/ie.hood.local-tld-firewall.plist /Library/LaunchDaemons/
cp $ETC/ie.hood.local-tld-service.plist $HOME/Library/LaunchAgents/
launchctl load -Fw /Library/LaunchDaemons/ie.hood.local-tld-firewall.plist
else
sudo mkdir -p /etc/resolver
sudo cp $ETC/resolver.dev /etc/resolver/dev
sudo cp $ETC/ie.hood.local-tld-firewall.plist /Library/LaunchDaemons/
cp $ETC/ie.hood.local-tld-service.plist $HOME/Library/LaunchAgents/
sudo launchctl load -Fw /Library/LaunchDaemons/ie.hood.local-tld-firewall.plist
fi

but I'm not a bash expert. Once you've used sudo npm install -g local-tld everything is all messed up and you can't properly uninstall or reinstall without manually removing the package from /usr/local/lib/node_modules/local-tld or fixing the permissions.

@bbn

got it to work by manually wiping the install, changing the perms on my global module folder, then reinstalling without sudo.

not ideal - recommend perhaps rethinking whether this component is necessary for hood.ie

@janl
Hoodie member

local-tld is definitely part of the whole hoodie experience, there is no question. But given it’s brittle nature an trouble porting it to other systems with verbatim functionality makes me ponder making this an optional add-on for mac folks.

Before going there thought, I’d like to try and hammer out the kinks to see if it can be done :)

@janl
Hoodie member

@pagameba thanks, I committed 26870b4 which does just that, thanks :)

@pagameba

you are welcome! I came across local-tld through a link to hood.ie, which sounds awesome. I wanted to try local-tld and ran into some difficulty so I was checking the issues and thought I might be able to lend some insight on this issue, glad it was of use :) Sadly I couldn't get local-tld to do anything and I ran out of time to troubleshoot it further.

@cupofjoakim

I'm also having difficulties. Being given the typical sudo-loop just as @nborwankar. I erased everything and tried 'npm install -g local-tld' without sudo, here's the error:

npm ERR! Error: EACCES, open '/Users/joakim/.npm/8993e262-local-tld.lock'
npm ERR! { [Error: EACCES, open '/Users/joakim/.npm/8993e262-local-tld.lock']
npm ERR! errno: 3,
npm ERR! code: 'EACCES',
npm ERR! path: '/Users/joakim/.npm/8993e262-local-tld.lock' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.

npm ERR! System Darwin 12.3.0
npm ERR! command "/usr/local/Cellar/node/0.10.3/bin/node" "/usr/local/bin/npm" "install" "-g" "local-tld"
npm ERR! cwd /Users/joakim
npm ERR! node -v v0.10.3
npm ERR! npm -v 1.2.17
npm ERR! path /Users/joakim/.npm/8993e262-local-tld.lock
npm ERR! code EACCES
npm ERR! errno 3
npm ERR! stack Error: EACCES, open '/Users/joakim/.npm/8993e262-local-tld.lock'
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /Users/joakim/npm-debug.log
npm ERR! not ok code 0

I'm also running mountain lion, btw.

@pagameba

If you previously ran the command with sudo then there are likely some root-owned files left around, try deleting the lock file at /Users/joakim/.npm/8993e262-local-tld.lock manually and running it again.

@cupofjoakim

It kind of puzzles me, but /Users/joakim/.npm/8993e262-local-tld.lock doesn't exist.

@pagameba

what about permissions on /Users/joakim/.npm, is it writable by your user?

@janl
Hoodie member
@cupofjoakim

It wasn't, so I changed it and now I recieved a new error:

npm http GET https://registry.npmjs.org/local-tld
npm http 304 https://registry.npmjs.org/local-tld
npm http GET https://registry.npmjs.org/local-tld/-/local-tld-3.0.5.tgz
npm http 200 https://registry.npmjs.org/local-tld/-/local-tld-3.0.5.tgz
npm ERR! Error: EPERM, chown '/Users/joakim/.npm/local-tld/3.0.5/package.tgz'
npm ERR! { [Error: EPERM, chown '/Users/joakim/.npm/local-tld/3.0.5/package.tgz']
npm ERR! errno: 50,
npm ERR! code: 'EPERM',
npm ERR! path: '/Users/joakim/.npm/local-tld/3.0.5/package.tgz' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.

npm ERR! System Darwin 12.3.0
npm ERR! command "/usr/local/Cellar/node/0.10.3/bin/node" "/usr/local/bin/npm" "install" "-g" "local-tld"
npm ERR! cwd /Users/joakim
npm ERR! node -v v0.10.3
npm ERR! npm -v 1.2.17
npm ERR! path /Users/joakim/.npm/local-tld/3.0.5/package.tgz
npm ERR! code EPERM
npm ERR! errno 50
npm ERR! stack Error: EPERM, chown '/Users/joakim/.npm/local-tld/3.0.5/package.tgz'
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /Users/jokkegoestasty/npm-debug.log
npm ERR! not ok code 0

Should I post the contents of npm-debug?

EDIT: Going to try @janl's suggestion, hang on a minute

@isaacs
@janl
Hoodie member
@cupofjoakim

Okay, so now I've cleansed my system from node (followed guide for node to make sure everything was gone), together with all the downloaded files, reinstalled them both, but still an error.

npm http GET https://registry.npmjs.org/local-tld
npm http 304 https://registry.npmjs.org/local-tld
npm http GET https://registry.npmjs.org/local-tld/-/local-tld-3.0.5.tgz
npm http 200 https://registry.npmjs.org/local-tld/-/local-tld-3.0.5.tgz
npm ERR! Error: EPERM, chown '/Users/joakim/.npm/local-tld/3.0.5/package.tgz'
npm ERR! { [Error: EPERM, chown '/Users/joakim/.npm/local-tld/3.0.5/package.tgz']
npm ERR! errno: 50,
npm ERR! code: 'EPERM',
npm ERR! path: '/Users/joakim/.npm/local-tld/3.0.5/package.tgz' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.

npm ERR! System Darwin 12.3.0
npm ERR! command "/usr/local/Cellar/node/0.10.3/bin/node" "/usr/local/bin/npm" "install" "-g" "local-tld"
npm ERR! cwd /usr/local/Library
npm ERR! node -v v0.10.3
npm ERR! npm -v 1.2.17
npm ERR! path /Users/joakim/.npm/local-tld/3.0.5/package.tgz
npm ERR! code EPERM
npm ERR! errno 50
npm ERR! stack Error: EPERM, chown '/Users/joakim/.npm/local-tld/3.0.5/package.tgz'
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /usr/local/Library/npm-debug.log
npm ERR! not ok code 0

Fun thing is: I'm one of those front-enders who knows basically nothing about using the terminal. I'm learning loads here. I don't have any idea about how to make "all paths belong to my current user" though.

@janl
Hoodie member

Sorry this is giving you so much trouble!

npm ERR! Error: EPERM, chown '/Users/joakim/.npm/local-tld/3.0.5/package.tgz'

This means that the path /Users/joakim/.npm/local-tld/3.0.5 isn’t accessible to the current user. This is likely a permission issue in you ~/.npm/ path.

Can you try running this:

sudo chmod -R $USER ~/.npm

(assuming you are the user joakim) and then try

npm install -g local-tld

again?

Note: no sudo

@cupofjoakim

I'm getting
chmod: Invalid file mode: joakim
on the first command.

@janl
Hoodie member

Eh, sorry, brainfart on my end. The command is:

sudo chown -R $USER ~/.npm
@cupofjoakim

Hey, it worked! Thanks @janl!

@janl
Hoodie member

Wootwoot. Closing this one.

@janl janl closed this
@donaldpipowitch donaldpipowitch referenced this issue in hoodiehq/local-tld-lib
Closed

Cannot install "improper use of sudo password" #1

@donaldpipowitch

Run into the same issue which was very annoying :(

I run 3.0.5 with sudo first even if the commit message "Protect against people accidentally using sudo npm install." says this shouldn't be possible? After that I searched in the wrong repo for help (hoodiehq/local-tld-lib) and somewhere in the middle of fixing this with the terminal prompts I had to reinstall node... Now everything works, but it consumed a lot of time and I can't see (yet) why local-tld isn't optional if you just want to test hoodie...?

@bbn

+1
An unnecessary complication for hood.ie, and preventing the framework from being used by a lot of people.

@janl
Hoodie member
@nborwankar
@janl
Hoodie member
@bbn

Well, for one thing, local-tld clobbers all of the local DNS I already have set up on my machine.

@janl
Hoodie member
@bbn

It's ok. If you are going to update hood.ie so that I can use it without local-tld, I can wait for that.

@janl
Hoodie member
@nborwankar
@bbn

"brew install couchdb" not working for me either -- issue here is that it can't find the file to download. I noticed that the recipe was looking for 1.2.0, and I edited it locally to look for 1.3.0 - same same.

I do have couchdb on my machine (installed from the OS X installer) but hood.ie seems to require the command-line version to be present.

It might be worth mentioning that I would have reported this problem earlier, but I wasn't sure which of the many git repos is the right place to report this type of thing! Perhaps the hood.ie site repo?

Anywho. Very interested in the potential of hood.ie, and I understand wanting to make the experience as consistent as possible (convention over configuration or whatever). But those are lofty goals and right now I'd just like to kick the tires! :)

@nborwankar
@janl
Hoodie member
@janl
Hoodie member
@nborwankar
@janl
Hoodie member
@janl
Hoodie member
@bbn

Sure, here's a log:

bbn$ brew install couchdb
==> Downloading http://www.apache.org/dyn/closer.cgi?path=couchdb/releases/1.2.0/apache-couchdb-1.2.0.tar.gz
==> Best Mirror http://apache.mirror.iweb.ca/couchdb/releases/1.2.0/apache-couchdb-1.2.0.tar.gz

curl: (22) The requested URL returned error: 404
Error: Download failed: http://www.apache.org/dyn/closer.cgi?path=couchdb/releases/1.2.0/apache-couchdb-1.2.0.tar.gz
@janl
Hoodie member

OOOOOH, 1.2.0. That is an old release. You want to make sure your Homebrew is up to date: brew update

@bbn

Hey that helped! Seems to be installing now (although it did complain about my xcode version). Perhaps an infrequent problem, but I recommend adding "brew update" to the sequence of install instructions for those of us who don't use homebrew very often / ever.

@janl
Hoodie member

Lesson learned, will totally do, thanks!

The Xcode version is a warning that there is a newer version available, but as long as thing keep working you don’t necessarily have to upgrade.

@bbn

huzzah! hoodie running in the browser, finally!

If I wanted to contribute a better error message for the missing couchdb case, what repo should I fork?
Here's what the error looks like now:

smaller:abba bbn$ hoodie start

> abba@1.0.0 start /Users/bbn/mainsocial/hoodie/abba
> node node_modules/hoodie-app/lib/hoodie-app.js

Start local couch on port: 6008

/Users/bbn/mainsocial/hoodie/abba/node_modules/hoodie-app/node_modules/multicouch/node_modules/which/which.js:83
  throw new Error("not found: "+cmd)
        ^
Error: not found: couchdb
    at whichSync (/Users/bbn/mainsocial/hoodie/abba/node_modules/hoodie-app/node_modules/multicouch/node_modules/which/which.js:83:9)
    at new MultiCouch (/Users/bbn/mainsocial/hoodie/abba/node_modules/hoodie-app/node_modules/multicouch/lib/multicouch.js:21:40)
    at Object.<anonymous> (/Users/bbn/mainsocial/hoodie/abba/node_modules/hoodie-app/lib/hoodie-app.js:64:17)
    at Module._compile (module.js:449:26)
    at Object.Module._extensions..js (module.js:467:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.runMain (module.js:492:10)
    at process.startup.processNextTick.process._tickCallback (node.js:244:9)
npm ERR! abba@1.0.0 start: `node node_modules/hoodie-app/lib/hoodie-app.js`
npm ERR! `sh "-c" "node node_modules/hoodie-app/lib/hoodie-app.js"` failed with 1
npm ERR! 
npm ERR! Failed at the abba@1.0.0 start script.
npm ERR! This is most likely a problem with the abba package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node node_modules/hoodie-app/lib/hoodie-app.js
npm ERR! You can get their info via:
npm ERR!     npm owner ls abba
npm ERR! There is likely additional logging output above.

npm ERR! System Darwin 12.2.0
npm ERR! command "node" "/usr/local/bin/npm" "start"
npm ERR! cwd /Users/bbn/mainsocial/hoodie/abba
npm ERR! node -v v0.8.15
npm ERR! npm -v 1.1.66
npm ERR! code ELIFECYCLE
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /Users/bbn/mainsocial/hoodie/abba/npm-debug.log
npm ERR! not ok code 0
@bbn

PS. even after updating homebrew, the couch version installed was 1.2.1, not 1.3.0. Not sure if that's what you would expect.

@janl
Hoodie member
@janl
Hoodie member
@iheanyi

Sorry to re-open this, but I'm encountering the same issue with local-tld.
Here's the log

847 info postuninstall local-tld@4.0.0
848 error local-tld@4.0.0 postinstall: `./bin/local-tld-setup`
848 error Exit status 64
849 error Failed at the local-tld@4.0.0 postinstall script.
849 error This is most likely a problem with the local-tld package,
849 error not with npm itself.
849 error Tell the author that this fails on your system:
849 error     ./bin/local-tld-setup
849 error You can get their info via:
849 error     npm owner ls local-tld
849 error There is likely additional logging output above.
850 error System Darwin 13.1.0
851 error command "node" "/usr/local/bin/npm" "install" "-g" "local-tld"
852 error cwd /Volumes/Storage Drive/Users/iheanyi
853 error node -v v0.10.28
854 error npm -v 1.4.9
855 error code ELIFECYCLE
856 verbose exit [ 1, true ]
@janl
Hoodie member

local-tld can’t be installed when running under sudo. Try this:

sudo rm -rf /usr/local/lib/node_modules/local-tld
sudo chown -R $USER /usr/local/lib/node_modules/
npm install -g local-tld
@iheanyi

Hm, weird. That finally fixed it, though I tried it before. Thanks @janl!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.