Skip to content

Loading…

Renamed binaries break npm install/update #2602

Closed
papandreou opened this Issue · 1 comment

2 participants

@papandreou

Seems like binaries that are renamed between package versions spook npm when updating. It reminds me of #1302, which was fixed ages ago.

In the assetgraph-builder package the binary bin/optimisePngs was renamed to bin/optimizePngs in 0.4.47. The bin directory is marked as binary by this fragment in the package.json:

    "directories": {
        "lib": "./lib",
        "bin": "./bin"
    },

The error is always triggered by installing version 0.4.46, then updating to 0.4.47:

andreas@papandreou:~/foo$ npm install assetgraph-builder@0.3.46
[...]
assetgraph-builder@0.3.46 node_modules/assetgraph-builder
├── bufferjs@1.0.2
├── temp@0.4.0
├── memoizer@0.0.4 (textual@0.0.1, treelib@0.0.4)
├── underscore@1.2.0
├── optimist@0.2.6 (wordwrap@0.0.2)
├── seq@0.3.5 (chainsaw@0.0.9, hashish@0.0.4)
├── uglify-js@1.2.5
├── assetgraph@0.4.35 (bufferjs@1.1.0, cssmin@0.3.1, cssom-papandreou@0.2.3-patch2, optimist@0.3.1, request@2.9.153, glob@3.1.9, underscore@1.3.1, uglify-js@1.2.6, jsdom-papandreou@0.2.14-patch2)
└── assetgraph-sprite@0.2.11 (underscore@1.2.2, canvas@0.10.0)

andreas@papandreou:~/foo$ npm install assetgraph-builder@0.3.47
[...]
npm ERR! Error: ENOENT, chmod '/home/andreas/foo/node_modules/assetgraph-builder/bin/optimisePngs'
npm ERR!  { [Error: ENOENT, chmod '/home/andreas/foo/node_modules/assetgraph-builder/bin/optimisePngs']
npm ERR!   errno: 34,
npm ERR!   code: 'ENOENT',
npm ERR!   path: '/home/andreas/foo/node_modules/assetgraph-builder/bin/optimisePngs' }
npm ERR! 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.35-30-generic
npm ERR! command "node" "/home/andreas/.local/bin/npm" "install" "assetgraph-builder@0.3.47"
npm ERR! cwd /home/andreas/foo
npm ERR! node -v v0.6.18
npm ERR! npm -v 1.1.35
npm ERR! path /home/andreas/foo/node_modules/assetgraph-builder/bin/optimisePngs
npm ERR! code ENOENT
npm ERR! message ENOENT, chmod '/home/andreas/foo/node_modules/assetgraph-builder/bin/optimisePngs'
npm ERR! errno 34
npm ERR! 34 errno
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /home/andreas/foo/npm-debug.log
npm ERR! not ok code undefined
npm ERR! not ok code 34

Also happens with npm install assetgraph-builder@0.4.46 ; npm update.

@isaacs
npm member

Ah, very interesting.

The first time it reads the package.json file, it looks up the directories.bin field, then finds all the bins in there, and sticks them on as literal "bin": { "foo": "./bin/foo" } entries, which is what npm actually works with.

It also caches the resulting data object, which is so that it doesn't have to keep reading the same package.json file repeatedly. However, this causes problems, because it's actually a new file, even though it has the same filename!

So, when removing the file, the cache has to be invalidated.

@isaacs isaacs closed this in 8d12a0f
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.