When running kitty from within kitty, use a full path

Fixes inability to run kitty from the shell when the users shell scripts
reset PATH. See #668
This commit is contained in:
Kovid Goyal
2018-06-22 15:33:07 +05:30
parent 82f6fbff77
commit aba84581f5
4 changed files with 25 additions and 14 deletions

View File

@@ -12,7 +12,8 @@ from .boss import Boss
from .cli import create_opts, parse_args
from .config import cached_values_for, initial_window_size_func
from .constants import (
appname, config_dir, glfw_path, is_macos, is_wayland, logo_data_file
appname, config_dir, glfw_path, is_macos, is_wayland, kitty_exe,
logo_data_file
)
from .fast_data_types import (
GLFW_MOD_SUPER, create_os_window, free_font_data, glfw_init,
@@ -199,14 +200,8 @@ def _main():
print('Failed to set locale with no LANG, ignoring', file=sys.stderr)
# Ensure kitty is in PATH
rpath = getattr(sys, 'bundle_exe_dir', None)
rpath = os.path.dirname(kitty_exe())
items = frozenset(os.environ['PATH'].split(os.pathsep))
if not rpath:
for candidate in items:
if os.access(os.path.join(candidate, 'kitty'), os.X_OK):
break
else:
rpath = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'launcher')
if rpath and rpath not in items:
os.environ['PATH'] += os.pathsep + rpath