Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kitty: command not found #3063

Closed
pckilgore opened this issue Oct 26, 2020 · 21 comments
Closed

kitty: command not found #3063

pckilgore opened this issue Oct 26, 2020 · 21 comments
Labels

Comments

@pckilgore
Copy link
Sponsor

pckilgore commented Oct 26, 2020

Describe the bug
The kitty executable is not in $PATH inside kitty (or any terminal) on mac.

$ kitty
-bash: kitty: command not found
$ which kitty
$ echo $?
1
$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:/Applications/Postgres.app/Contents/Versions/latest/bin

To Reproduce
Steps to reproduce the behavior:

  1. Remove any RC files / restore kitty.conf to default.
  2. Launch kitty (0.19.1) from finder
  3. Try to use kitty command
  4. See error

Expected behavior
kitty executable in path

Screenshots
image

Environment details
OS: mac/darwin 10.15.7 (19H2)
Kitty: v0.19.1 (also confirmed in 0.18.4, 0.18.0, but not in 0.17.4)

# Not possible for obvious reasons.
Output of kitty --debug-config
@pckilgore pckilgore added the bug label Oct 26, 2020
@pckilgore
Copy link
Sponsor Author

Oh, a reinstall of kitty (curl -L https://sw.kovidgoyal.net/kitty/installer.sh | sh /dev/stdin) didn't fix it.

@pckilgore
Copy link
Sponsor Author

Also: kitty is still authorized as a developer tool with full disk access in Security & Privacy settings.

@pckilgore pckilgore reopened this Oct 26, 2020
@Luflosi
Copy link
Contributor

Luflosi commented Oct 26, 2020

What happens, when you execute /Applications/kitty.app/Contents/MacOS/kitty in kitty or alternatively in a different terminal emulator? Do you see any error messages? Is the PATH the same in the second kitty instance?

@pckilgore
Copy link
Sponsor Author

In both instances I get expected behavior but still the bug: A new kitty window opens, but which kitty still exits with 1, and a $PATH identical to the one above.

@Luflosi
Copy link
Contributor

Luflosi commented Oct 26, 2020

In the terminal where you executed /Applications/kitty.app/Contents/MacOS/kitty, do you see any error messages there?

@pckilgore
Copy link
Sponsor Author

I'm used to seeing some warnings there about ignoring font features, but yeah, this might be new?:

[300 13:55:36.663140] [PARSE ERROR] Unknown OSC code: 7

@pckilgore
Copy link
Sponsor Author

If it helps: I recently upgrades to version 19 from 17. This error does not occur on version 0.17.0 which I just reverted back to.

@pckilgore
Copy link
Sponsor Author

If it helps: I recently upgrades to version 19 from 17. This error does not occur on version 0.17.0 which I just reverted back to.

I just bisected release versions based on this. This bug does not happen for me on version 0.17.4, but does happen on 0.18.0

@Luflosi
Copy link
Contributor

Luflosi commented Oct 26, 2020

I read through the changeling and skimmed the diff but I couldn't find anything suspicious except added Notarisation.
One more thing you could try is to remove and then re-add kitty in the full-disk-access system preferences panel. This could help because when you change the kitty app, the permission doesn't automatically apply to that new app as it's different from the old app.

@pckilgore
Copy link
Sponsor Author

remove and then re-add kitty in the full-disk-access system preferences panel

Good idea, but doesn't fix it 😞

@Luflosi
Copy link
Contributor

Luflosi commented Oct 26, 2020

Add shell python3 -c 'import os; print(os.environ["PATH"]); input("Press Enter to quit...")' to your kitty.conf, then restart kitty. This will show you the PATH before your shell touches it. See if it is the same. Beware that this will make kitty pretty much useless until you remove that line again, you will have to edit the file with something else later.

@pckilgore
Copy link
Sponsor Author

pckilgore commented Oct 26, 2020

Comparing notes with a friend, I tried installing via the homebrew cask, instead of the install script.

This works, but does automatically what I was about to do manually -- add a wrapper script:
image


(removed and reinstalling the binary via curl -L https://sw.kovidgoyal.net/kitty/installer.sh | sh /dev/stdin ...)

Add shell python3 -c 'import os; print(os.environ["PATH"]); input("Press Enter to quit...")' to your kitty.conf, then restart kitty. This will show you the PATH before your shell touches it. See if it is the same. Beware that this will make kitty pretty much useless until you remove that line again, you will have to edit the file with something else later.

I get:

/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:/Applications/Postgres.app/Contents/Versions/latest/bin

(that is, the same PATH as above)

@Luflosi
Copy link
Contributor

Luflosi commented Oct 26, 2020

@kovidgoyal I can reproduce the problem. When executing the the provided binary for kitty 0.19.1, kitty doesn't add itself to the PATH but when I compile from source, it works as expected.
@pckilgore that means, that you can compile from source to work around this problem but that's not very user-friendly. If the wrapper script provided by the cask works for you, you can use that until we find a proper fix.

@pckilgore
Copy link
Sponsor Author

Yep, I can work around until a fix, thanks @Luflosi / Kovid.

@pckilgore
Copy link
Sponsor Author

Thanks @kovidgoyal !!

@dj1020
Copy link

dj1020 commented Jun 7, 2021

Using this way for now:

ln -s /Applications/kitty.app/Contents/MacOS/kitty ~/bin/kitty

~/bin is under $PATH

not sure if any side effects.

@ibehnam
Copy link

ibehnam commented May 1, 2022

I can confirm that this issue still exists on the latest version (I'm on Mac).

@page-down
Copy link
Contributor

@ibehnam

That's because the system-wide or your shell rc startup file changed the PATH.

You can open the kitty shell by pressing Ctrl+Shift+Esc and run the following command to check if kitty is already in the PATH.

launch --hold sh -c 'printenv PATH; command -v kitty;'

@jsparedes
Copy link

Running the command suggested by @page-down i got:

/Applications/kitty.app/Contents/MacOS:/usr/bin:/bin:/usr/sbin:/sbin
/Applications/kitty.app/Contents/MacOS/kitty

Press Enter or Esc to exit

@jsparedes
Copy link

Installing kitty using homebrew and running the suggested command by @page-down I got the same result:

/Applications/kitty.app/Contents/MacOS:/usr/bin:/bin:/usr/sbin:/sbin
/Applications/kitty.app/Contents/MacOS/kitty

Press Enter or Esc to exit

However, this time the kitty command was found.

@page-down
Copy link
Contributor

@jsparedes

However, this time the kitty command was found.

You can see that the results are the same for both runs, indicating that kitty has correctly added itself to the PATH.

Why does it look like kitty can be found in the second approach?
That's because the Homebrew install script puts a shell script kitty (executing exec /path/to/kitty) into a directory in the PATH (e.g. /usr/local/bin/kitty).
And this approach is not recommended.

In short, any user experiencing this issue should simply add the kitty bin directory to the PATH, or create a symbolic link to kitty in a directory in the PATH.

ln -s /Applications/kitty.app/Contents/MacOS/kitty /usr/local/bin/kitty

If you want to understand why, and get to the root cause:

  • Launching kitty via launchd (e.g. Launchpad, Dock, Spotlight), kitty gets only /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin in PATH. (If you start from another app, there is not even /usr/local/bin).
    • PATH: /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
  • kitty will check itself for the existence in PATH and prepend its bin folder path to PATH.
    • PATH: /Applications/kitty.app/Contents/MacOS:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
  • The shell will be launched by kitty as a command line program.
  • If you write export PATH=/usr/local/bin:/bin:... in the shell rc file without the original PATH value, or any system global rc file that resets the PATH, then it will remove the path to the kitty bin folder that kitty automatically adds.
    • PATH: /some/other/bin/path:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
  • kitty does not add itself to /usr/local/bin, and the kitty you find here is the exec /path/to/kitty script added by Homebrew (e.g. /opt/homebrew/bin/kitty), which is not recommended.
  • Finally, just fix the PATH in your shell, you don't need any symbolic links or additional shell scripts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants