Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

npm adduser fails #103

Open
gmaggess opened this Issue · 12 comments

3 participants

@gmaggess

Hi Gurus,

I have installed couchdb 1.0.4 - not sure if it's supported - node v0.10.5, and npm v1.2.18. I've managed to run replicate [https://github.com/mikeal/replicate] successfully, but now I'm having issues to create adduser with npm. I only have admin setup on my server so far and secure_rewrite is false. I guess I've done my homework, but I guess something simple might be missing.

When I run 'npm adduser' I'm facing the 401 below. If the user was previously created using 'curl -X PUT 'http://admin:Welcome1@machine:5984/_users/org.couchdb.user:gmaggess' -d '{"name": "gmaggess","password": "welcome1", "type": "user","roles": ["editor"]}', then I get a 404. Does anyone have a clue about what could've been happening here?

$ sudo npm adduser --verbose --registry http://admin:Welcome1@machine:5984/registry
npm info it worked if it ends with ok
npm verb cli [ '/scratch/gmaggess/node-v0.10.5-linux-x64/bin/node',
npm verb cli '/scratch/gmaggess/node-v0.10.5-linux-x64/bin/npm',
npm verb cli 'adduser',
npm verb cli '--verbose',
npm verb cli '--registry',
npm verb cli 'http://admin:Welcome1@machine:5984/registry' ]
npm info using npm@1.2.18
npm info using node@v0.10.5
Username: gmaggess
Password:
Email: george.maggessy@gmail.com
npm verb adduser before first PUT { name: 'gmaggess',
npm verb adduser salt: 'XXXXX',
npm verb adduser password_sha: 'XXXXX',
npm verb adduser email: 'george.maggessy@gmail.com',
npm verb adduser _id: 'org.couchdb.user:gmaggess',
npm verb adduser type: 'user',
npm verb adduser roles: [],
npm verb adduser date: '2013-05-04T00:02:46.928Z' }
npm verb url raw /-/user/org.couchdb.user:gmaggess
npm verb url resolving [ 'http://admin:Welcome1@machine:5984/registry/',
npm verb url resolving './-/user/org.couchdb.user:gmaggess' ]
npm verb url resolved http://admin:Welcome1@machine:5984/registry/-/user/org.couchdb.user:gmaggess
npm info trying registry request attempt 1 at 17:02:46
npm http PUT http://admin:Welcome1@machine:5984/registry/-/user/org.couchdb.user:gmaggess
npm info retry will retry, error on last attempt: Error: Parse Error
npm info trying registry request attempt 2 at 17:02:57
npm http PUT http://admin:Welcome1@machine:5984/registry/-/user/org.couchdb.user:gmaggess
npm http 409 http://admin:Welcome1@machine:5984/registry/-/user/org.couchdb.user:gmaggess
npm verb adduser update existing user
npm verb url raw /-/user/org.couchdb.user:gmaggess
npm verb url resolving [ 'http://admin:Welcome1@machine:5984/registry/',
npm verb url resolving './-/user/org.couchdb.user:gmaggess' ]
npm verb url resolved http://admin:Welcome1@machine:5984/registry/-/user/org.couchdb.user:gmaggess
npm info trying registry request attempt 1 at 17:02:57
npm http GET http://admin:Welcome1@machine:5984/registry/-/user/org.couchdb.user:gmaggess
npm http 401 http://admin:Welcome1@machine:5984/registry/-/user/org.couchdb.user:gmaggess
npm verb adduser back [ [Error: unauthorized Name or password is incorrect.: registry/-/user/org.couchdb.user:gmaggess],
npm verb adduser { error: 'unauthorized',
npm verb adduser reason: 'Name or password is incorrect.' },
npm verb adduser '{"error":"unauthorized","reason":"Name or password is incorrect."}\n' ]
npm WARN adduser Incorrect username or password
npm WARN adduser You can reset your account by visiting:
npm WARN adduser
npm WARN adduser http://admin.npmjs.org/reset
npm WARN adduser
npm ERR! Error: unauthorized Name or password is incorrect.: registry/-/user/org.couchdb.user:gmaggess
npm ERR! at RegClient. (/scratch/gmaggess/node-v0.10.5-linux-x64/lib/node_modules/npm/node_modules/npm-registry-client/lib/request.js:269:14)
npm ERR! at Request.self.callback (/scratch/gmaggess/node-v0.10.5-linux-x64/lib/node_modules/npm/node_modules/request/index.js:142:22)
npm ERR! at Request.EventEmitter.emit (events.js:98:17)
npm ERR! at Request. (/scratch/gmaggess/node-v0.10.5-linux-x64/lib/node_modules/npm/node_modules/request/index.js:856:14)
npm ERR! at Request.EventEmitter.emit (events.js:117:20)
npm ERR! at IncomingMessage. (/scratch/gmaggess/node-v0.10.5-linux-x64/lib/node_modules/npm/node_modules/request/index.js:808:12)
npm ERR! at IncomingMessage.EventEmitter.emit (events.js:117:20)
npm ERR! at _stream_readable.js:895:16
npm ERR! at process._tickCallback (node.js:415:13)
npm ERR! If you need help, you may report this log at:
npm ERR! http://github.com/isaacs/npm/issues
npm ERR! or email it to:
npm ERR! npm-@googlegroups.com
npm ERR! System Linux 2.6.39-300.20.1.el6uek.x86_64
npm ERR! command "/scratch/gmaggess/node-v0.10.5-linux-x64/bin/node" "/scratch/gmaggess/node-v0.10.5-linux-x64/bin/npm" "adduser" "--verbose" "--registry" "http://admin:Welcome1@machine:5984/registry"
npm ERR! cwd /scratch/gmaggess
npm ERR! node -v v0.10.5
npm ERR! npm -v 1.2.18
npm verb exit [ 1, true ]
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /scratch/gmaggess/npm-debug.log
npm ERR! not ok code 0

Cheers,
George

@gmaggess

I tried to downgrade nodejs to 0.8.18 and I don't get 404s anymore. Only 401.

@isaacs
Owner
@gmaggess

I've done that, and no luck. So, where does the user/password info gets store? In ".npmrc"? I might be missing smth here. For instance, in my .npmrc there's no "auth" entry. Is it necessary? If so, how do I create it?

@isaacs
Owner

The _auth entry gets added on a successful npm adduser call.

You probably should not run it as sudo, either.

What version of couchdb do you have?

@gmaggess
@isaacs
Owner

@gmaggess I believe you need a newer couchdb. We're running 1.3.0 in production.

What do you see in the couchdb server logs when the adduser happens? Any crashes or interesting stuff?

@gmaggess
@isaacs
Owner
@gmaggess

OK. Thanks again for your continuos help.

Answering your questions:
1. What do you see when you visit /registry/_design/app/_rewrite/atbar in your browser?
{"error":"not_found","reason":"missing"}

  1. What shows up in the logs when you hit it?
    [Thu, 09 May 2013 06:03:42 GMT] [info] [<0.24827.18>] 10.159.129.246 - - GET /registry/_design/app/_rewrite/atbar 404

  2. Do you have insecure_rewrites enabled in your couchdb configs?
    Yes. secure_rewrites = false on default.ini

However, if I replace 'app' by 'scratch' in the url it seems to work fine.

Commands such as login

$ npm --registry http://slc01pvp:5984/registry/_design/scratch/_rewrite/ login
Username: (gmaggess)
Email: (george.maggessy@oracle.com)
npm http PUT http://slc01pvp:5984/registry/_design/scratch/_rewrite/-/user/org.couchdb.user:gmaggess
npm http 409 http://slc01pvp:5984/registry/_design/scratch/_rewrite/-/user/org.couchdb.user:gmaggess
npm http GET http://slc01pvp:5984/registry/_design/scratch/_rewrite/-/user/org.couchdb.user:gmaggess
npm http 200 http://slc01pvp:5984/registry/_design/scratch/_rewrite/-/user/org.couchdb.user:gmaggess
npm http PUT http://slc01pvp:5984/registry/_design/scratch/_rewrite/-/user/org.couchdb.user:gmaggess/-rev/1-d148a12a1f49423f1612a94bb8cef6d7
npm http 201 http://slc01pvp:5984/registry/_design/scratch/_rewrite/-/user/org.couchdb.user:gmaggess/-rev/1-d148a12a1f49423f1612a94bb8cef6d7

And search

$ npm --registry http://slc01pvp:5984/registry/_design/scratch/_rewrite/ search
NAME DESCRIPTION AUTHOR DATE KEYWORDS
...
abhispeak Finally, lorem ipsum worth reading. =mertonium 2011-09-22 07:27 lorem ipsum lipsum filler text
activeobject An interface for JSON objects for updating, deleting, inserting and creating properties. =mike.hemesath 2011-07-21 20:55 json node
actor Experimental library implementing scala like actors in javascript. =gozala (prehistoric) actor generators async javascript 1.7
...

They all look fine. Even publish works as well:

$ sudo npm publish generator-cagspa
Password:
npm http PUT http://slc01pvp:5984/registry/_design/scratch/_rewrite/generator-cagspa
npm http 201 http://slc01pvp:5984/registry/_design/scratch/_rewrite/generator-cagspa
npm http GET http://slc01pvp:5984/registry/_design/scratch/_rewrite/generator-cagspa
npm http 200 http://slc01pvp:5984/registry/_design/scratch/_rewrite/generator-cagspa
npm http PUT http://slc01pvp:5984/registry/_design/scratch/_rewrite/generator-cagspa/0.0.0/-tag/latest
npm http 201 http://slc01pvp:5984/registry/_design/scratch/_rewrite/generator-cagspa/0.0.0/-tag/latest
npm http GET http://slc01pvp:5984/registry/_design/scratch/_rewrite/generator-cagspa
npm http 200 http://slc01pvp:5984/registry/_design/scratch/_rewrite/generator-cagspa
npm http PUT http://slc01pvp:5984/registry/_design/scratch/_rewrite/generator-cagspa/-/generator-cagspa-0.0.0.tgz/-rev/2-e60d74f578cd908571ca6bb95b1129c7
npm http 201 http://slc01pvp:5984/registry/_design/scratch/_rewrite/generator-cagspa/-/generator-cagspa-0.0.0.tgz/-rev/2-e60d74f578cd908571ca6bb95b1129c7

  • generator-cagspa@0.0.0

This is how my .npmrc looks now:

_auth = Z21hZ2dlc3M6d2VsY29tZTE=
email = george.maggessy@oracle.com
registry = http://slc01pvp:5984/registry/_design/scratch/_rewrite
http://slc01pvp:5984/registry/_design/app/_rewrite = 0

[_token]
AuthSession = Z21hZ2dlc3M6NTE4QjQxRTU6dfnrJ2_icoDsoAKALdIeoVBq2o4
version = 1
path = /
httponly = true
expires = 1399616873655

Now, my main question is... Where does this "scratch" come from?!

Cheers,
George

@isaacs
Owner

Ohhhhh... ok. In the npmjs.org repo, when you do npm start, it prints out some further instructions. Follow those instructions.

Of course, on your little repo with a single package, it's no big deal. But, with the full registry of 30000 or so packages, view generation can take quite a long time. If you push directly to the app design doc, then users will not be able to fetch views until it's done with the view generation.

So, instead, I have it set to push to _design/scratch. Then, I make sure that my changes are good, etc, and run npm run load to trigger view generation. As of couch 1.3.0, this is no longer necessary, since the view generation happens automatically, but the load script will sit there and hang until the view generation is done, so you know that you're waiting long enough. Once it finishes, run npm run copy to do a single atomic HTTP COPY from _design/scratch to _design/app, which also changes the pointer to the generated views in a single step, so that users are not impacted while they wait for them to generate.

@gmaggess

Hold on! :) When and where should I issue the "npm start"?

I've use the replicate package (https://github.com/mikeal/replicate) to copy all packages from http://isaacs.iriscouch.com/registry/. Do I really need it? If I'm not wrong npm should pull the packages from npmjs.org if it's not found under my private repo, right?

On paragraph 3, what you are saying is that you don't push your package to the standard repo ".../app/..." right awat but to scratch. Then I believe you might install the package back pulling it from scratch to check if everything is fine. If that's the case you issue the view generation, which is not necessary for me either since I've got couchdb 1.3 as well.

Cool, I guess I'm almost there. My feeling is that the only missing thing here is where I should issue "npm start", "npm run load", and "npm run copy".

Well, I guess npmjs.org doesn't need all those steps, am I right? And I want to mimic exactly what is there. I've published and unpublished packages right away and I don't have the feeling that there was a view generation running in the background.

Cheers and thanks a bunch for your time.
George

@terinjokes
Collaborator

George:

The improvements to the README I think greatly clarifies the steps needed to be done and in what order. If you want to give it another shot, preferably with CouchDB 1.5, and let us know how it goes.

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.