From ff40cdb578b44cea6aba1bee62240e61670a5fe4 Mon Sep 17 00:00:00 2001 From: Labhansh Agrawal Date: Fri, 19 Feb 2021 18:11:41 +0530 Subject: [PATCH] Add cli to path when running from AppImage --- app/session.ts | 10 ++++++++++ app/utils/cli-install.ts | 5 +++++ 2 files changed, 15 insertions(+) diff --git a/app/session.ts b/app/session.ts index d92c88bf..9858213e 100644 --- a/app/session.ts +++ b/app/session.ts @@ -5,6 +5,8 @@ import {getDecoratedEnv} from './plugins'; import {productName, version} from './package.json'; import * as config from './config'; import {IPty, IWindowsPtyForkOptions, spawn as npSpawn} from 'node-pty'; +import {cliScriptPath} from './config/paths'; +import {dirname} from 'path'; const createNodePtyError = () => new Error( @@ -118,6 +120,14 @@ export default class Session extends EventEmitter { envFromConfig ); + // path to AppImage mount point is added to PATH environment variable automatically + // which conflicts with the cli + if (baseEnv['APPIMAGE'] && baseEnv['APPDIR']) { + baseEnv['PATH'] = [dirname(cliScriptPath)] + .concat((baseEnv['PATH'] || '').split(':').filter((val) => !val.startsWith(baseEnv['APPDIR']))) + .join(':'); + } + // Electron has a default value for process.env.GOOGLE_API_KEY // We don't want to leak this to the shell // See https://github.com/vercel/hyper/issues/696 diff --git a/app/utils/cli-install.ts b/app/utils/cli-install.ts index 6d581ddd..918672a5 100644 --- a/app/utils/cli-install.ts +++ b/app/utils/cli-install.ts @@ -134,6 +134,11 @@ export const installCLI = async (withNotification: boolean) => { logNotify(withNotification, 'Hyper CLI installation failed', `Failed to add Hyper CLI path to user PATH ${err}`); } } else if (process.platform === 'darwin' || process.platform === 'linux') { + // AppImages are mounted on run at a temporary path, don't create symlink + if (process.env['APPIMAGE']) { + console.log('Skipping CLI symlink creation as it is an AppImage install'); + return; + } try { await addSymlink(!withNotification); logNotify(withNotification, 'Hyper CLI installed', `Symlink created at ${cliLinkPath}`);