Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

0.10 released today but `n stable` still downloads 0.8.22 #105

Closed
atuttle opened this Issue Mar 11, 2013 · 22 comments

Comments

Projects
None yet
4 participants

atuttle commented Mar 11, 2013

To quote from IRC:

<deoxxa> ha, i guess n does a lexical sort

Guessing that 0.10 appears older than 0.8.22 because 8>1. :)

Collaborator

benatkin commented Mar 12, 2013

It's doing a numeric sort for me, and downloading 0.10.0 when I run "n stable". Could you try it again? Which platform are you on?

atuttle commented Mar 12, 2013

Platform is OSX 10.7.5

$ n -V
0.9.0
$ n --stable
0.8.22
$ n --latest
0.10.0
Collaborator

benatkin commented Mar 12, 2013

That's odd. I'm on OS X 10.7 too. Here's what I just got:

bat@bmamba.local:~ $ n -V
0.9.0
bat@bmamba.local:~ $ n --stable
0.10.0
bat@bmamba.local:~ $ n --latest
0.10.0
bat@bmamba.local:~ $
Owner

tj commented Mar 12, 2013

hmm I get the same as @benatkin

atuttle commented Mar 12, 2013

I thought it might have been because I was running it while on node 0.8.2, so I upgraded to 0.10 and re-checked, and get the exact same results.

Collaborator

benatkin commented Mar 12, 2013

None of it is written with node. It's a shell script.

I see that the version it reports is inaccurate. I'm going to bump it up to 0.9.2 in both package.json and in n. It doesn't look like the changes since it started reporting 0.9.0 will impact your issue, and it's likely that you do in fact have the latest version, but it will at least be accurate.

Collaborator

benatkin commented Mar 12, 2013

Just pushed n 0.9.2 out. @atuttle mind updating and running three commands again?

Collaborator

benatkin commented Mar 12, 2013

After that I think I'll give you a copy of what n is downloading for me and have you run the shell commands on it, so we can see if it's an issue with what's being downloaded (cloud caching issues?) or with how your shell commands are processing it.

atuttle commented Mar 12, 2013

AH! I had this problem when I originally tried to use n yesterday, and ended up reinstalling node and npm to fix it. since it's come back solely through the use of n, maybe I should see if it's a known issue. Sorry to sidetrack, but here we go:

$npm update n

module.js:340
    throw err;
          ^
Error: Cannot find module 'npmlog'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Module.require (module.js:362:17)
    at require (module.js:378:17)
    at /usr/local/bin/npm:19:11
    at Object.<anonymous> (/usr/local/bin/npm:87:3)
    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)

This started happening after I install a node version using n, and has happened twice now. Using n to go back to the previous version also doesn't seem to fix it; I have to uninstall node and reinstall it (I've been using the vanilla download on nodejs.org) to fix the issue. I seem to have to use sudo n for its changes to work, otherwise it spits out a lot of permission denied lines -- not sure if that's related.

Collaborator

benatkin commented Mar 12, 2013

npmlog is just the first outside module that npm tries to require. Most people I've seen with that error online started getting it when 0.8 was released. Since then, TJ has rewritten n. I think it is related to permission denied errors. When I get those I do a chown -R of the directory to fix the permissions and run it again. What may have happened is that it was able to update the cli script but not node_modules.

https://github.com/isaacs/npm/blob/master/bin/npm-cli.js

Here's how I can trace where npm gets its modules:

bat@bmamba.local:~ $ ls -l `which npm`
lrwxr-xr-x  1 root  admin  38 Nov  1 23:46 /usr/local/bin/npm -> ../lib/node_modules/npm/bin/npm-cli.js
bat@bmamba.local:~ $ cd /usr/local/bin/  # since ls gives me a relative path, I change to the directory of the symlink first
bat@bmamba.local:/usr/local/bin $ cd ../lib/node_modules/npm/bin/  # now I change to the relative path of ../lib/node_modules/npm/bin/npm-cli.js
bat@bmamba.local:/usr/local/lib/node_modules/npm/bin $ ls
node-gyp-bin        npm         npm-cli.js      npm.cmd         read-package-json.js
bat@bmamba.local:/usr/local/lib/node_modules/npm/bin $ cd .. # no package.json here, looking in the parent directory
bat@bmamba.local:/usr/local/lib/node_modules/npm $ ls
AUTHORS     Makefile    bin     configure   html        man     package.json    test
LICENSE     README.md   cli.js      doc     lib     node_modules    scripts
bat@bmamba.local:/usr/local/lib/node_modules/npm $ cd node_modules # since this is where package.json is, it uses node_modules here
bat@bmamba.local:/usr/local/lib/node_modules/npm/node_modules $ ls
abbrev          fstream-npm     minimatch       once            retry
ansi            glob            mkdirp          opener          rimraf
archy           graceful-fs     node-gyp        osenv           semver
block-stream        inherits        node-uuid       proto-list      slide
chmodr          ini         nopt            read            tar
chownr          init-package-json   npm-registry-client read-installed      uid-number
couch-login     lockfile        npmconf         read-package-json   which
fstream         lru-cache       npmlog          request
bat@bmamba.local:/usr/local/lib/node_modules/npm/node_modules $ # there is npmlog

atuttle commented Mar 12, 2013

Strange... I reinstalled node and tried to make it happen again and can't now. I'll keep that in mind in the future if it comes back, so thanks... Anyway, so now with the latest n:

$ n -V
0.9.2
$ n --latest
0.10.0
$ n --stable
0.8.22

atuttle commented Mar 12, 2013

Looking at the source, I've boiled the command down to this, stripping off the sort and tail commands:

$ wget --no-check-certificate -q -O- 2> /dev/null http://nodejs.org/dist/ | egrep -o '[0-9]+\.\d*[02468]\.[0-9]+'

I can see that 0.10.0 is not included in the results, for some reason, but I haven't been able to find anything wrong with the regex yet...

If I substitute the regex from the "latest" method, 0.10.0 is found...

atuttle commented Mar 12, 2013

It's the \d. When I replace the regex with this one it works:

 bad: egrep -o '[0-9]+\.\d*[02468]\.[0-9]+'
good: egrep -o '[0-9]+\.[0-9]*[02468]\.[0-9]+'

atuttle commented Mar 12, 2013

Not sure if it would make a difference but I'm using iTerm2 instead of the default terminal.

Collaborator

benatkin commented Mar 12, 2013

Thanks for tracking this down! I'm going to make this change and cut a new release. It seems it's caused by different egrep behavior. Would you tell me what which egrep reports?

atuttle commented Mar 12, 2013

$ which egrep
/usr/bin/egrep

# and it's not a symlink:
$ ls -l `which egrep`
-rwxr-xr-x  3 root  wheel  232064 Aug  1  2011 /usr/bin/egrep
Collaborator

benatkin commented Mar 12, 2013

Mine's a bit different:

bat@bmamba.local:~ $ ls -l `which egrep`
-rwxr-xr-x  3 root  wheel  29664 Jul 21  2012 /usr/bin/egrep
bat@bmamba.local:~ $
Collaborator

benatkin commented Mar 12, 2013

I have a relatively new Macbook Air with up-to-date XCode.

@benatkin benatkin added a commit that referenced this issue Mar 12, 2013

@benatkin benatkin reference issue #105 27f7ff6
Collaborator

benatkin commented Mar 12, 2013

I released 0.9.3, which has this fix. Please make sure it works and if it does, close the issue.

atuttle commented Mar 12, 2013

Ah, I'm pretty sure I've got an old version of xcode. I only update it when absolutely necessary. :)

atuttle commented Mar 12, 2013

Verified! Thanks for looking into it.

@atuttle atuttle closed this Mar 12, 2013

alexy commented May 21, 2013

I've had the same npmlog problem, and ended up doing some random purge/install cycle. I'm on Mac OSX, so I did this:

brew install node
npm install -g n

I had to hunt down and destroy /usr/local/bin/{node,npm,n} first. Is this a sufficient wash/rinse/repeat cycle?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment