Hyper: Still getting the $PATH issue on [email protected]

Created on 27 Jul 2016  ·  25Comments  ·  Source: vercel/hyper

Hyperterm Error

Currently running v0.7.1, getting:

screen shot 2016-07-26 at 19 43 44

This means plugins can't be installed. So plugins can't be used 😞.

npm

npm is correctly installed, and following @rauchg reccomendation:

❯ which npm
/usr/local/bin/npm

and, to confirm:

❯ npm config get prefix
/usr/local

System data:

❯ npm -v
3.10.6
❯ node -v
v6.3.1
❯ brew cask update
Already up-to-date.
❯ brew cask update hyperterm
Already up-to-date.
Bug

Most helpful comment

I too receive this error and am using zsh (or have it set to be using zsh), which seems to be the one commonality among all posters. I do not have oh-my-zsh installed, and have noticed that when running npm install from the .hyperterm_plugins folder all works fine.

Curiosities


*note: my login shell and .hyperterm.js are both set to /usr/local/bin/zsh.

# From Hyperterm

❯ echo $SHELL
/bin/bash
# From login shell - Terminal.app

❯ echo $SHELL
/usr/local/bin/zsh

Again, my .hyperterm.js file has shell set to /usr/local/bin/zsh.

npm


❯ which npm
/Users/username/.nvm/versions/node/v6.4.0/bin/npm
❯ npm config get prefix
/Users/username/.nvm/versions/node/v6.4.0
❯ npm -v
3.10.3
❯ node -v
v6.4.0
❯ $PATH
...
/usr/local/sbin:/Users/username/.rbenv/shims:/Users/username/.nvm/versions/node/v6.4.0/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

All 25 comments

Related to #440,
Do you have a different login shell?
echo $SHELL should return the shell that hyperterm is trying to run npm in

I use zsh which is set as my login shell, and npm is on my path since running npm -v works.

❯ echo $SHELL; npm -v
/bin/zsh
3.10.6

Try doing this:
cd /tmp
npm install shell-env

node -e 'require("shell-env")().then((env) => { console.log(path: ${env.PATH} n shell: ${env.SHELL}) })'

Does that look correct?

Maybe even try something like this:
node -e 'require("shell-env")().then((env) => { require("child_process").exec("npm ls", { env }, (err, stdout, stderr) => { console.error("error", err || "nope"); console.log("stdout", stdout || "nope"); console.error("stderr", stderr || "nope")}); })'

It looks correct, yes, node and npm are there:

path: /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/nacho/dev/temp/node_modules/.bin:/Users/nacho/dev/node_modules/.bin:/Users/nacho/node_modules/.bin:/Users/node_modules/.bin:/node_modules/.bin:/usr/local/Cellar/node/6.3.1/bin 
 shell: /bin/zsh

I'm really close to trying reinstalling everything (?)

Last thing: are we correctly diagnosing that npm can't be found, or is that message masking some other type of error :) ?

Does /bin/zsh -c "/usr/local/bin/npm --help" work?

Yeah @rauchg I'm starting to think there's something else wrong 😕
The plugin installation-function has kinda bad error handling 😁

I think that the message could be masking some other type of error:

if (/not a recognized/.test(err.message) || /command not found/.test(err.message)) {
   notify(
       'Error updating plugins.',
       'We could not find the `npm` command. Make sure it\'s in $PATH'
   );
...

https://github.com/zeit/hyperterm/blob/27b2cd718ef07355400d32ecc70dcfeab1a480da/app/plugins.js#L69-L73

@albinekb:

``` ~/dev/temp
❯ /bin/zsh -c "/usr/local/bin/npm --help"

Usage: npm

where is one of:

... more npm help stuff

[email protected] /usr/local/lib/node_modules/npm
```

I have this problem as well. I changed the notify output to get the real error message:

Command failed: npm prune && npm install --production
/bin/sh: npm: command not found

So it seems it is trying to use /bin/sh even though /bin/zsh is my login shell

$ echo $SHELL
/bin/zsh

The strange thing is that npm should be in the $PATH even if ran by /bin/sh

@albinekb: Resolved the issue. Oh-My-Zsh was causing the problem, I guess it was messing with the path in some way. I uninstalled it and $PATH and npm not found errors were gone. I reinstalled Oh-My-Zsh again and it's still working. I guess you need a Oh-My-Zsh reinstall after installing Hyperterm.

It seems the issue for me is I have zsh configured to spawn or attach to a tmux session when i open a terminal.

Not sure how to debug this further though. The tmux attaching is so important I will keep using another terminal.

Suggestions are very much welcome on how i can make my auto-tmux and HyperTerm coexist.

I use Oh My Zsh here and I did not have to reinstall it after "installing" HyperTerm 😅

@tg90nor I use tmux attach on login too, without a hassle!

This is the script I have on my .zshrc

# TMUX
tmux attach &> /dev/null;
if [[ ! $TERM =~ screen ]]; then
    exec tmux
fi

@matheuss Weird! But it worked for me! Uninstalling it made my hyperterm plugins install and load with no problem. Then I tried installing Oh-My-Zsh again and here we are, everything functional. I honestly don't know what happened ¯_(ツ)_/¯

@nachoaIvarez did you try to manually update plugins after reinstalling Oh-My-Zsh? HyperTerm will not try to automatically update plugins if it has done so recently.

I think I'm seeing the underlying cause of this issue manifest in a slightly different way. I do not see my PATH being imported properly. From a shell, echo $PATH|sed 's%:%\n%g':

/home/stephen/bin
/home/stephen/opt/racket/bin
/home/stephen/opt/pebble/bin
/home/stephen/opt/pebble/Pebble
/home/stephen/opt/pebble/arm-cs-tools/bin
/home/stephen/opt/flutter/bin
/home/stephen/opt/emsdk
/home/stephen/opt/emsdk/clang/fastcomp/build_master_64/bin
/home/stephen/opt/emsdk/node/4.1.1_64bit/bin
/home/stephen/opt/emsdk/emscripten/master
node_modules/.bin
/home/stephen/.node/bin
/home/stephen/.local/bin
/home/stephen/.cabal/bin
/usr/lib/go/bin
/bin
/usr/local/bin
/usr/bin
/usr/local/games
/usr/games
/home/stephen/opt/android/sdk/tools
/home/stephen/opt/android/sdk/platform-tools
/home/stephen/opt/android/sdk/build-tools/24.0.1
/home/stephen/opt/android/ndk

Launched from the same shell, ./HyperTerm:

/usr/local/bin
/usr/bin
/bin
/usr/local/games
/usr/games

These PATHs are exported in my ~/.profile which is sourced by the system at login (not by ~/.bashrc or ~/.bash_login). I'm on Debian Stretch.

If it's any help, I'm also having this problem. On a fresh install, running:

echo $PATH
gives:
/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl
whereas:
zsh; echo $PATH
gives:
/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/home/lindenk/bin/:/home/lindenk/.cabal/bin/:/home/lindenk/.go/bin/:/home/lindenk/.cargo/bin/

The problem appears to be my $PATH not getting set correctly unless I manually run my shell again. Playing around with my dotfiles, it appears that hyperterm isn't loading .zshenv when it starts with zsh as the shell.

I agree. PATH isn't honored:

$ export PATH=foo
$ ./HyperTerm
# --- In HyperTerm window now
$ echo "$PATH"
/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games

Is it possible to not require npm to be installed on the user's machine? Reason: _I use docker for everything, except obviously for GUI applications, just as a way to keep the original system "clean"._

From my understanding, npm is required for installing and updating plugins. Maybe npm can be packaged within HyperTerm and its sandboxed so that it doesn't reach out of ~/.hyperterm ?

I am seeing this same "npm not in $PATH" issue, but I'm noticing something very interesting.

In iTerm and Terminal, I see the following:

echo $SHELL
/bin/zsh

But in HyperTerm, I see:

echo $SHELL
/bin/false

My login shell is set to /bin/zsh. I've also set it to zsh in the hyperterm settings. Is this the potential cause of the problem?

I'm on Version 0.7.1 (0.7.1.36).

I too receive this error and am using zsh (or have it set to be using zsh), which seems to be the one commonality among all posters. I do not have oh-my-zsh installed, and have noticed that when running npm install from the .hyperterm_plugins folder all works fine.

Curiosities


*note: my login shell and .hyperterm.js are both set to /usr/local/bin/zsh.

# From Hyperterm

❯ echo $SHELL
/bin/bash
# From login shell - Terminal.app

❯ echo $SHELL
/usr/local/bin/zsh

Again, my .hyperterm.js file has shell set to /usr/local/bin/zsh.

npm


❯ which npm
/Users/username/.nvm/versions/node/v6.4.0/bin/npm
❯ npm config get prefix
/Users/username/.nvm/versions/node/v6.4.0
❯ npm -v
3.10.3
❯ node -v
v6.4.0
❯ $PATH
...
/usr/local/sbin:/Users/username/.rbenv/shims:/Users/username/.nvm/versions/node/v6.4.0/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

I have also noticed that when running npm install from the .hyperterm_plugins folder all works fine. And for what it's worth, I do have oh-my-zsh installed.

osx: 10.12
hyperterm: 0.7.1.36
nvm: 0.32.0

I tried (without luck) changing my default login shell in my user account under System Preferences to /bin/zsh and in ~/.hyperterm.js reverting /bin/zsh back to empty string:

    // if left empty, your system's login shell will be used by default
    shell: ''

I also tried brew cask and downloaded release both complain they cannot find npm command.

Also affected on bash, Mac OS 10.11, HyperTerm 0.8.0, and Hyper 0.8.1 & 0.8.2 & 0.8.3 & 1.0.1:

$ echo $SHELL
/bin/bash
$ echo $PATH
/usr/local/Homebrew/bin:/opt/mypaint/bin:/opt/local/bin:/opt/X11/bin:/usr/local/bin
$ which npm
/usr/local/bin/npm

I fixed this by putting

source ~/.nvm/nvm.sh

in my ~/.bashrc. I was previously lazy loading nvm.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

leo picture leo  ·  3Comments

juicygoose picture juicygoose  ·  3Comments

hxnt picture hxnt  ·  3Comments

weabot picture weabot  ·  3Comments

sarneeh picture sarneeh  ·  3Comments