'npm install express' fails on eCryptfs with ENAMETOOLONG error #2598

trinitronx opened this Issue Jul 3, 2012 · 5 comments


None yet
4 participants

Bug similar to #2592 (possibly duplicate, but I've isolated the cause... see below)


Trying to install the 'express' package on Ubuntu 12.04 with npm version 1.1.34 fails with error ENAMETOOLONG.

jcuzella@cirrus:node-express-azuredemo(master)$ sudo npm install express
npm http GET https://registry.npmjs.org/express
npm http 200 https://registry.npmjs.org/express
npm http GET https://registry.npmjs.org/express/-/express-3.0.0beta5.tgz
npm http 200 https://registry.npmjs.org/express/-/express-3.0.0beta5.tgz
npm http GET https://registry.npmjs.org/connect/2.3.6
npm http GET https://registry.npmjs.org/commander/0.6.1
npm http GET https://registry.npmjs.org/range-parser/0.0.4
npm http GET https://registry.npmjs.org/mkdirp/0.3.3
npm http GET https://registry.npmjs.org/cookie/0.0.3
npm http GET https://registry.npmjs.org/crc/0.2.0
npm http GET https://registry.npmjs.org/fresh/0.1.0
npm http GET https://registry.npmjs.org/methods/0.0.1
npm http GET https://registry.npmjs.org/debug
npm http 200 https://registry.npmjs.org/commander/0.6.1
npm http GET https://registry.npmjs.org/commander/-/commander-0.6.1.tgz
npm http 200 https://registry.npmjs.org/connect/2.3.6
npm http GET https://registry.npmjs.org/connect/-/connect-2.3.6.tgz
npm http 200 https://registry.npmjs.org/cookie/0.0.3
npm http GET https://registry.npmjs.org/cookie/-/cookie-0.0.3.tgz
npm http 200 https://registry.npmjs.org/crc/0.2.0
npm http GET https://registry.npmjs.org/crc/-/crc-0.2.0.tgz
npm http 200 https://registry.npmjs.org/methods/0.0.1
npm http GET https://registry.npmjs.org/methods/-/methods-0.0.1.tgz
npm http 200 https://registry.npmjs.org/fresh/0.1.0
npm http GET https://registry.npmjs.org/fresh/-/fresh-0.1.0.tgz
npm http 200 https://registry.npmjs.org/commander/-/commander-0.6.1.tgz
npm http 200 https://registry.npmjs.org/debug
npm http GET https://registry.npmjs.org/debug/-/debug-0.7.0.tgz
npm http 200 https://registry.npmjs.org/connect/-/connect-2.3.6.tgz
npm http 200 https://registry.npmjs.org/mkdirp/0.3.3
npm http GET https://registry.npmjs.org/mkdirp/-/mkdirp-0.3.3.tgz
npm http 200 https://registry.npmjs.org/cookie/-/cookie-0.0.3.tgz
npm http 200 https://registry.npmjs.org/crc/-/crc-0.2.0.tgz
npm http 200 https://registry.npmjs.org/range-parser/0.0.4
npm http GET https://registry.npmjs.org/range-parser/-/range-parser-0.0.4.tgz
npm http 200 https://registry.npmjs.org/methods/-/methods-0.0.1.tgz
npm http 200 https://registry.npmjs.org/fresh/-/fresh-0.1.0.tgz
npm http 200 https://registry.npmjs.org/debug/-/debug-0.7.0.tgz
npm http 200 https://registry.npmjs.org/mkdirp/-/mkdirp-0.3.3.tgz
npm http 200 https://registry.npmjs.org/range-parser/-/range-parser-0.0.4.tgz
npm http GET https://registry.npmjs.org/qs/0.4.2
npm http GET https://registry.npmjs.org/mime/1.2.4
npm http GET https://registry.npmjs.org/formidable/1.0.11
npm http GET https://registry.npmjs.org/cookie/0.0.4
npm http GET https://registry.npmjs.org/fresh/0.0.1
npm http GET https://registry.npmjs.org/bytes/0.0.1
npm http 200 https://registry.npmjs.org/fresh/0.0.1
npm http GET https://registry.npmjs.org/fresh/-/fresh-0.0.1.tgz
npm http 200 https://registry.npmjs.org/qs/0.4.2
npm http GET https://registry.npmjs.org/qs/-/qs-0.4.2.tgz
npm http 200 https://registry.npmjs.org/formidable/1.0.11
npm http GET https://registry.npmjs.org/formidable/-/formidable-1.0.11.tgz
npm http 200 https://registry.npmjs.org/mime/1.2.4
npm http GET https://registry.npmjs.org/mime/-/mime-1.2.4.tgz
npm http 200 https://registry.npmjs.org/cookie/0.0.4
npm http GET https://registry.npmjs.org/cookie/-/cookie-0.0.4.tgz
npm http 200 https://registry.npmjs.org/fresh/-/fresh-0.0.1.tgz
npm http 200 https://registry.npmjs.org/qs/-/qs-0.4.2.tgz
npm http 200 https://registry.npmjs.org/formidable/-/formidable-1.0.11.tgz
npm http 200 https://registry.npmjs.org/mime/-/mime-1.2.4.tgz
npm http 200 https://registry.npmjs.org/bytes/0.0.1
npm http GET https://registry.npmjs.org/bytes/-/bytes-0.0.1.tgz
npm http 200 https://registry.npmjs.org/cookie/-/cookie-0.0.4.tgz
npm http 200 https://registry.npmjs.org/bytes/-/bytes-0.0.1.tgz
npm ERR! Error: ENAMETOOLONG, open '/home/jcuzella/.npm/dfdb0092b001784f21c3948152a85a026bd05393--home-jcuzella-src-node-express-azuredemo-node-modules-express-node-modules-connect-node-modules-fresh.lock'
npm ERR!  { [Error: ENAMETOOLONG, open '/home/jcuzella/.npm/dfdb0092b001784f21c3948152a85a026bd05393--home-jcuzella-src-node-express-azuredemo-node-modules-express-node-modules-connect-node-modules-fresh.lock']
npm ERR!   errno: 49,
npm ERR!   code: 'ENAMETOOLONG',
npm ERR!   path: '/home/jcuzella/.npm/dfdb0092b001784f21c3948152a85a026bd05393--home-jcuzella-src-node-express-azuredemo-node-modules-express-node-modules-connect-node-modules-fresh.lock' }
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 3.2.0-26-generic
npm ERR! command "nodejs" "/usr/bin/npm" "install" "express"
npm ERR! cwd /home/jcuzella/src/node-express-azuredemo
npm ERR! node -v v0.8.1
npm ERR! npm -v 1.1.34
npm ERR! path /home/jcuzella/.npm/dfdb0092b001784f21c3948152a85a026bd05393--home-jcuzella-src-node-express-azuredemo-node-modules-express-node-modules-connect-node-modules-fresh.lock
npm ERR! message ENAMETOOLONG, open '/home/jcuzella/.npm/dfdb0092b001784f21c3948152a85a026bd05393--home-jcuzella-src-node-express-azuredemo-node-modules-express-node-modules-connect-node-modules-fresh.lock'
npm ERR! errno 49
npm ERR! 49 errno
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /home/jcuzella/src/node-express-azuredemo/npm-debug.log
npm ERR! not ok code 0

Looks like a file is trying to be opened with a 168 character filename. This is not beyond the limit for ext3 or ext4, however it appears that this eCryptfs bug is the culprit!

Here is the offending filename:


Notice that it is only 168 chars, but on an eCryptfs mounted home partition, it causes the error. From the information in the bug report:

When trying to create a new file with a relatively long filename (f. ex. dfkmqsdgjfmqsldjfmlsqkjlqkdmfsmgjlqlskdqshgpoizehmlqkbgmlqbgmqbdfkmqsdgjfmqsldjfmlsqkjlqkdmfsmgjlqlskdqshgpoizehmlqkbgmlqbgmqbdfkmqsdgjfmqsldjfmlsqkjlqkdmfsmgjlqlskdqshgpoizehmlqkbgmlqbgmqb.txt)
I get an error: file name to long, when in fact the file name is not to long, but the encrypted name created for this file is to long, so, the file was not created.

I have verified this by trying these commands:

# Filename A is on eCryptfs mounted /home
# Filename B is on ext4 /tmp partition
jcuzella@cirrus:node-express-azuredemo(master)$ filename_a='/home/jcuzella/.npm/dfdb0092b001784f21c3948152a85a026bd05393--home-jcuzella-src-node-express-azuredemo-node-modules-express-node-modules-connect-node-modules-fresh.lock'
jcuzella@cirrus:node-express-azuredemo(master)$ filename_b='/tmp/jcuzella/.npm/dfdb0092b001784f21c3948152a85a026bd05393--home-jcuzella-src-node-express-azuredemo-node-modules-express-node-modules-connect-node-modules-fresh.lock-'
jcuzella@cirrus:node-express-azuredemo(master)$ echo -n "$filename_a" | wc -m
jcuzella@cirrus:node-express-azuredemo(master)$ echo -n "$filename_b" | wc -m
jcuzella@cirrus:node-express-azuredemo(master)$ touch "$filename_a"
touch: cannot touch `/home/jcuzella/.npm/dfdb0092b001784f21c3948152a85a026bd05393--home-jcuzella-src-node-express-azuredemo-node-modules-express-node-modules-connect-node-modules-fresh.lock': File name too long

jcuzella@cirrus:node-express-azuredemo(master)$ mkdir -p /tmp/jcuzella/.npm
jcuzella@cirrus:node-express-azuredemo(master)$ touch "$filename_b"

Suggested fixes

In order to fix this, there are a couple methods:

  1. Don't use long filenames as in #2592 (not sure how long one must be to cause the encrypted one to be longer than 255 or 256, so you could potentially run into it still!)
  2. Use the statfs() syscall to check the filename length limits of eCryptfs. Shorten the filename if length limit overrun detected.

I suggest solution 2 as the most complete solution, as it is recommended in the bug report.

sukima commented Jul 5, 2012

This happens on other builds as well. Seems npm will tack on modules to the file name as dependencies nest. For example spine.app depends on hem which depends on traverse and there for attempts to use a file name of /home/suki/.npm/4ed38642cd00600411a5cd438bf0d31840c11b1d--home-suki-source-workout-node-modules-hem-node-modules-fast-detective-node-modules-burrito-node-modules-traverse.lock

Here is the full error output:

npm ERR! System Linux 3.0.0-22-generic-pae
npm ERR! command "nodejs" "/usr/bin/npm" "install" "."
npm ERR! cwd /home/suki/source/workout
npm ERR! node -v v0.8.1
npm ERR! npm -v 1.1.34
npm ERR! path /home/suki/.npm/4ed38642cd00600411a5cd438bf0d31840c11b1d--home-suki-source-workout-node-modules-hem-node-modules-fast-detective-node-modules-burrito-node-modules-traverse.lock
npm ERR! message ENAMETOOLONG, open '/home/suki/.npm/4ed38642cd00600411a5cd438bf0d31840c11b1d--home-suki-source-workout-node-modules-hem-node-modules-fast-detective-node-modules-burrito-node-modules-traverse.lock'
npm ERR! errno 49
npm ERR! 49 errno
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /home/suki/source/workout/npm-debug.log
npm ERR! not ok code 0

sukima commented Jul 5, 2012

For a workaround symlink ~/.npm to another file system. My linux is ext4 on / but eCryptFS in my user home So it moved it off the encrypted filesystem:

$ sudo mkdir -p /var/npm/suki
$ sudo chown suki: /var/npm/suki
$ mv ~/.npm/* /var/npm/suki/
$ rm -rf ~/.npm
$ ln -s /var/npm/suki ~/.npm

I successfully tested the pull request mentioned in #2592 ( fix-enametoolong branch here: mintplant/npm@ce5896b36d3129815c7bbbdb1abf5a495b185eac )

Fixes my problem ^_^


isaacs commented Jul 7, 2012

Different fix landed in master.

Doing a statfs call would be great, but we don't have a statfs binding in node currently.

@isaacs isaacs closed this Jul 7, 2012

LTe commented Aug 31, 2016

This issue is fixed in npm@2. But in npm@3 is still present.

$ npm -v 
$ 3.10.6
╰─$ npm install                                                                                                                                                                              1 ↵
npm ERR! Linux 4.4.0-36-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install"
npm ERR! node v6.5.0
npm ERR! npm  v3.10.6
npm ERR! path /home/lite/.npm/_git-remotes/git-https-x-oauth-basic-[hash]-github-com-[project-name]-git-[hash]-7b509e5b
npm ERR! errno -36
npm ERR! syscall mkdir

npm ERR! ENAMETOOLONG: name too long, mkdir '/home/lite/.npm/_git-remotes/git-https-x-oauth-basic-[hash]-github-com-[project-name]-git-[hash]-7b509e5b'
npm ERR! 
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>

npm ERR! Please include the following file with any support request:
npm ERR!     /home/lite/work/platform/npm-debug.log
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment