Skip to content

Commit

Permalink
Experimental Nix-managed NPM detection for better errors
Browse files Browse the repository at this point in the history
  • Loading branch information
jiribenes committed Sep 17, 2024
1 parent 8a32b5d commit b3d30d0
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/effektManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,17 @@ export class EffektManager {
}

private async runNpmInstall(): Promise<void> {
// 1) Check if the npm root is managed by Nix in order to produce a better error
const npmRoot = await this.execCommand('npm root -g');
if (npmRoot.startsWith("/nix/store")) {
this.logMessage('ERROR', 'NPM root is in the read-only Nix store. Installation is not possible.')
throw new Error('Detected Nix environment: NPM global modules are stored in a read-only directory managed by Nix. Installation cannot proceed.');
}

// 2) Actually run `npm install -g ...`
const npmInstallCommand = `npm install -g ${this.effektNPMPackage}@latest`;
const npmOutput = await this.execCommand(npmInstallCommand);

this.logMessage('INFO', `Ran '${npmInstallCommand}'; stdout: ${npmOutput}`);
}

Expand Down

0 comments on commit b3d30d0

Please sign in to comment.