zkat / npx

execute npm package binaries (moved)
https://github.com/npm/npx
Other
2.63k stars 105 forks source link

npx doesn't like Hamilton (Easter egg not playing nice with shell fallback) #53

Closed varjmes closed 7 years ago

varjmes commented 7 years ago

Hello dear npx maintainers.

I've just set up auto shell fallback by adding

command_not_found_handle() {
  # Do not run within a pipe
  if test ! -t 1; then
    >&2 echo "command not found: $1"
    return 127
  fi
  echo "$1 not found. Trying with npx..." >&2
  if ! [[ $1 =~ @ ]]; then
    npx --no-install "$@"
  else
    npx "$@"
  fi
  return $?
}

into my .zsh_rc file.

I then do

npx awesome-npx

and the following happens!

❯ npx awesome-npx
npm ERR! path /Users/charlotte.spencer/ 🎵 I Have the Honour to Be Your Obedient Servant,🎵 ~ npm 📜🖋
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall lstat
npm ERR! enoent ENOENT: no such file or directory, lstat '/Users/charlotte.spencer/ 🎵 I Have the Honour to Be Your Obedient Servant,🎵 ~ npm 📜🖋'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/charlotte.spencer/.npm/_logs/2017-06-27T19_24_03_425Z-debug.log
Install for awesome-npx@latest failed with code 254

The end of any npm command I do prints out

🎵 I Have the Honour to Be Your Obedient Servant,🎵 ~ npm 📜🖋

which is an npm easter egg.

It seems that npx is taking this, and thinking it is part of the directory I am working in.

Pretty funny, but surely worth looking into.

~ your obedient servant, class

varjmes commented 7 years ago

I made it work. I moved the command_not_found handler further up in my zsh_rc. I have no idea why it worked...but it did.

legodude17 commented 7 years ago

Ran into this without the shell fallback, probably because of this:

13:56:03 [jdb:~/Desktop/CIS118] 1s $ npm config get prefix
/home/jdb/.npm-packages

 🎵 I Have the Honour to Be Your Obedient Servant,🎵 ~ npm
zkat commented 7 years ago

@Charlotteis did 8.0.2 fix it?

varjmes commented 7 years ago

@zkat it seems both legodude and I have something that works now. Thank you much!