diff --git a/back/loaders/deps.ts b/back/loaders/deps.ts index fafa290a..1e61fc96 100644 --- a/back/loaders/deps.ts +++ b/back/loaders/deps.ts @@ -1,5 +1,6 @@ import path from 'path'; import fs from 'fs/promises'; +import os from 'os'; import chokidar from 'chokidar'; import config from '../config/index'; import { fileExist, promiseExec, rmPath } from '../config/util'; @@ -17,8 +18,24 @@ async function linkToNodeModule(src: string, dst?: string) { } async function linkCommand() { - const commandPath = await promiseExec('which node'); - const commandDir = path.dirname(commandPath); + const homeDir = os.homedir(); + const userBinDir = path.join(homeDir, 'bin'); + + // Create ~/bin directory if it doesn't exist + try { + await fs.mkdir(userBinDir, { recursive: true }); + } catch (error) { + // If we can't create ~/bin, fall back to system directory + const commandPath = await promiseExec('which node'); + const commandDir = path.dirname(commandPath); + await linkCommandToDir(commandDir); + return; + } + + await linkCommandToDir(userBinDir); +} + +async function linkCommandToDir(commandDir: string) { const linkShell = [ { src: 'update.sh', diff --git a/docker/docker-entrypoint.sh b/docker/docker-entrypoint.sh index b06b9abb..9b79bdf9 100755 --- a/docker/docker-entrypoint.sh +++ b/docker/docker-entrypoint.sh @@ -1,5 +1,8 @@ #!/bin/bash +# Add ~/bin to PATH for non-root users +export PATH="$HOME/bin:$PATH" + dir_shell=/ql/shell . $dir_shell/share.sh . $dir_shell/env.sh