hyper: Can't start Hyper from terminal (/opt/homebrew/bin/hyper: line 4: /usr/bin/python: No such file or directory)

  • I am on the latest Hyper.app version
  • I have searched the issues of this repo and believe that this is not a duplicate
  • OS version and name: MacOS Monterey 12.3
  • Hyper.app version: 3.2.0
  • Link of a Gist with the contents of your .hyper.js: .hyper.js
  • Relevant information from devtools (CMD+ALT+I on macOS, CTRL+SHIFT+I elsewhere):

Issue

Attempting to invoke Hyper from the terminal (terminal.app or iTerm2) fails:

$ hyper

$ /opt/homebrew/bin/hyper: line 4: /usr/bin/python: No such file or directory
$ /opt/homebrew/bin/hyper: line 8: ./MacOS/Hyper: No such file or directory

Please note my Python installation was done via Homebrew and as I am on an M1 machine all Homebrew installs go under /opt/homebrew/bin.

Also, there’s no such ./MacOS/Hyper anywhere. Was it supposed to get created by Hyper? It’s not there.

Hyper was also installed with Homebrew.

Maybe Related:

I cannot run either Tools/Install Hyper CLI command in PATH, I get the following error:

Screenshot 2022-03-15 at 14 24 35

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 26 (13 by maintainers)

Most upvoted comments

This latest version of the patch works perfectly fine, the cli is back and fig works as well (yes, indeed fig is very neat @zcutlip, did you check how nice is to create your own shortcuts or add mixins to expand the current clis?).

No, haven’t played with it yet. Looking forward to it!

Thank you so much. Would this get overwritten on an upcoming version of Hyper?

Yes it’ll get overwritten. I’ll try to submit a PR soon so hopefully they’ll take the fix.

Hmm getting this / or similar error when running the above with or without the set -x part as well

❯ bash ./script.sh
+++++ _realpath ./script.sh
+++++ readlink -f ./script.sh
++++ dirname /Users/<USERNAME_REDACTED>/script.sh
+++ dirname /Users/<USERNAME_REDACTED>
++ dirname /Users
+ CONTENTS=/
+ ELECTRON=//MacOS/Hyper
+ CLI=//Resources/bin/cli.js
+ ELECTRON_RUN_AS_NODE=1
+ //MacOS/Hyper //Resources/bin/cli.js
./script.sh: line 10: //MacOS/Hyper: No such file or directory
+ exit 127

//MacOS/Hyper: No such file or directory seems like a reoccurring error.

This shell script expects to be in its proper home inside the Hyper.app application bundle. That’s what all the CONTENTS=, ELECTRON=, etc are doing…trying to find the path to Hyper.app relative to the hyper script. So you need to patch the script in place: Hyper.app/Contents/Resources/bin/hyper

hyper version was working for me the other day before the latest mac update to macOS Monterey 12.3

That’s because the system’s default python was removed in macOS 12.3. This has been anticipated for a couple years, but the Hyper project must not have known. More info here: https://scriptingosx.com/2020/02/wrangling-pythons/

Ah I think I spotted the problem. If you invoke hyper directly from the application bundle (i.e., not from a symlink) readlink fails. You can provide -f which actually does everything we need. From the readlink(1) manpage:

When invoked as readlink, only the target of the symbolic link is printed. If the given argument is not a symbolic link and the -f option is not specified, readlink will print nothing and exit with an error. If the -f option is specified, the output is canonicalized by following every symlink in every component of the given path recursively. readlink will resolve both absolute and relative paths, and return the absolute pathname corresponding to file. In this case, the argument does not need to be a symbolic link.

This should get you going:

#!/usr/bin/env bash
# Deeply inspired by https://github.com/Microsoft/vscode/blob/1.17.0/resources/darwin/bin/code.sh

_realpath() { readlink -f "$0"; }

CONTENTS="$(dirname "$(dirname "$(dirname "$(_realpath "$0")")")")"
ELECTRON="$CONTENTS/MacOS/Hyper"
CLI="$CONTENTS/Resources/bin/cli.js"
ELECTRON_RUN_AS_NODE=1 "$ELECTRON" "$CLI" "$@"
exit $?

Note that -f wasn’t always available on macOS’s readlink. I’m not sure when it was added so this may introduce backward compatibility issues. Stackexchange comment from 2013: https://unix.stackexchange.com/questions/24293/converting-relative-path-to-absolute-path-without-symbolic-link#comment139876_24297

Hmm getting this / or similar error when running the above with or without the set -x part as well

❯ bash ./script.sh
+++++ _realpath ./script.sh
+++++ readlink -f ./script.sh
++++ dirname /Users/<USERNAME_REDACTED>/script.sh
+++ dirname /Users/<USERNAME_REDACTED>
++ dirname /Users
+ CONTENTS=/
+ ELECTRON=//MacOS/Hyper
+ CLI=//Resources/bin/cli.js
+ ELECTRON_RUN_AS_NODE=1
+ //MacOS/Hyper //Resources/bin/cli.js
./script.sh: line 10: //MacOS/Hyper: No such file or directory
+ exit 127

//MacOS/Hyper: No such file or directory seems like a reoccurring error.

hyper version was working for me the other day before the latest mac update to macOS Monterey 12.3

Putting this in Hyper.app/Contents/Resources/bin/hyper worked for me, thank you!

Hi @TransformersWsz! That’s Ohmyzsh running the powerlevel10k theme. It will look similar across all terminals if you source the .zshrc file: iTerm2, Terminal.app, Hyper, etc.

It’s highly customizable. You can find how to place the OS logo in this section of the .p10k.zsh file:

  typeset -g POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(
    os_icon                 # os identifier
    virtualenv              # python virtual environment (https://docs.python.org/3/library/venv.html)
    dir                     # current directory
    vcs                     # git status
    prompt_char             # prompt symbol
  )

Colors are also fully customizable. Let me know if you need help. It’s a pretty big file with tons of variables.

With Hyper I use the hyper-one-dark theme, which changes some colors, but it doesn’t alter the look of powerlevel10k. You’ll need a powerfont as well. I use SauceCodePro Nerd Font.

Hope this helps!

This latest version of the patch works perfectly fine, the cli is back and fig works as well (yes, indeed fig is very neat @zcutlip, did you check how nice is to create your own shortcuts or add mixins to expand the current clis?).

Thank you so much. Would this get overwritten on an upcoming version of Hyper?

Thanks so much @zcutlip! That did the trick! 🚀 🎉

Okay, hopefully one last attempt. Since -f wasn’t available on macOS until recently, here’s a workaround:

https://unix.stackexchange.com/a/534101

#!/usr/bin/env bash

# On modern macOS there's readlink -f, but that's fairly recent so we can't rely on it.
# instead, check for failure (i.e., not a symlink) and just echo the actual path
# https://unix.stackexchange.com/a/534101
_readlink(){ readlink "$1" || echo "$1"; }

_realpath() { cd "$(dirname "$0")" && _readlink "$(pwd)"/"$(basename "$0")"; }

CONTENTS="$(dirname "$(dirname "$(dirname "$(_realpath "$0")")")")"
ELECTRON="$CONTENTS/MacOS/Hyper"
CLI="$CONTENTS/Resources/bin/cli.js"
ELECTRON_RUN_AS_NODE=1 "$ELECTRON" "$CLI" "$@"
exit $?