Skip to content

Commit

Permalink
Merge pull request #445 from ExpressLRS/ignore-pythonhome-pythonpath-env
Browse files Browse the repository at this point in the history
Ignore PYTHONPATH & PYTHONHOME env variables when using platformio
  • Loading branch information
jurgelenas authored Dec 14, 2022
2 parents cf93d88 + 1a1ca50 commit e357f69
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions src/api/src/library/Platformio/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,33 @@ const prependPATH = (pth: string, item: string): string => {
return item;
};

const envFilter = (
env: NodeJS.ProcessEnv,
blacklist: string[]
): NodeJS.ProcessEnv => {
const result: NodeJS.ProcessEnv = {};
Object.keys(env).forEach((key) => {
if (!blacklist.includes(key)) {
result[key] = env[key];
}
});
return result;
};

export default class Platformio {
private env: NodeJS.ProcessEnv;

constructor(
private getPlatformioPath: string,
private stateTempStoragePath: string,
private PATH: string,
private env: NodeJS.ProcessEnv,
env: NodeJS.ProcessEnv,
private logger: LoggerService
) {}
) {
// Fix for https://github.com/ExpressLRS/ExpressLRS-Configurator/issues/440
const blacklistedEnvKeys = ['PYTHONPATH', 'PYTHONHOME'];
this.env = envFilter(env, blacklistedEnvKeys);
}

async install(onUpdate: OnOutputFunc = NoOpFunc): Promise<CommandResult> {
const pyExec = await this.findPythonExecutable(this.PATH);
Expand Down

0 comments on commit e357f69

Please sign in to comment.