Duplicate _rewrite in tarball path breaks install #51

Closed
robertjustjones opened this Issue Mar 6, 2014 · 10 comments

2 participants

@robertjustjones

I can run npm info and npm publish using a config where the first path is "http://localhost:5984/registry/_design/app/_rewrite/", but when I try to npm install against the kappa registry, it fails with 404 Not Found on the tarball. The tarball path in the info output has the kappa hostname rewritten (from util.rewrite), but the /registry/_design/app/_rewrite/ path is still there. That then gets duplicated when the path to the first server is built. The couchdb log for the local npmjs looks like
GET /registry/_design/app/_rewrite/registry/_design/app/_rewrite/<package-name>/... .tgz 404

I think the util.rewriter function needs to strip that portion of the path. Any reason why it shouldn't?

exports.rewriter = function rewriter(protocol, hostname, port) {
    return function rewrite(path) {
        if (typeof path === 'string') {
            path = url.parse(path);
            path.protocol = protocol;
            path.host = path.hostname = hostname;
            path.port = port;
            path.path = path.path.replace( /\/registry\/_design\/app\/_rewrite/, '' );
            path.pathname = path.path;
            path = path.format();
        }
        return path;
    };
};
@totherik
The kraken.js team member

Thanks @robertjustjones, this was fixed in this commit 7edc6cc. Publishing 0.14.2 is forthcoming.

@totherik
The kraken.js team member

Hey again @robertjustjones. 0.14.2 has been released which should address this issue. Please reopen if you're still having trouble. Thanks.

@totherik totherik closed this Mar 6, 2014
@robertjustjones

Hey @totherik, I just checked with 0.14.2 and now getting the error again.

npm ERR! fetch failed http://registry.whatever.com/registry/_design/app/_rewrite/my-package/-/my-package-0.3.51.tgz

My config.json has the first path as http://localhost:5984/registry/_design/app/_rewrite/.

With the fix noted above, I've got all operations working.

Thanks!

@totherik
The kraken.js team member

Did you $ npm cache clean prior to trying to install again?

Edit: If the cached metadata has the bad rewrite path, it will always get used until the cache is purged and new metadata fetched.

@totherik
The kraken.js team member

what is the registry you have configured locally? e.g. $ npm install --registry ???

@totherik totherik reopened this Mar 6, 2014
@robertjustjones

It's http://registry.<my-domain>.com.

BTW, also with the patch, I've got existing packages with many dependencies (both local and remote) working great. I was initially concerned that I'd need to re-publish using the new repo path to get the dist.tarball fixed. But this just worked with all existing local and remote pacakges.

@totherik
The kraken.js team member

Update: I have a fix in the works. Working on test cases now.

@totherik
The kraken.js team member

I was able to reproduce what I think was the issue you were seeing. This branch contains the fix and test cases. Code reviewing now and publishing 0.14.3 shortly. Feel free to give the branch a try in the mean time.

@totherik
The kraken.js team member

Should be fixed per kappa@0.14.3

@totherik totherik closed this Mar 6, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment