Skip to content

Commit 9ba9169

Browse files
committed
Merge pull request #677 from Ptival/master
workerLib's spawn should preserve the environment
2 parents 9740e2b + 5163741 commit 9ba9169

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

lib/worker/lib/workerLib.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,10 +231,19 @@ export class Parent extends RequesterResponder {
231231
/** start worker */
232232
startWorker(childJsPath: string, terminalError: (e: Error) => any, customArguments: string[]) {
233233
try {
234+
/** At least on NixOS, the environment must be preserved for
235+
dynamic libraries to be properly linked.
236+
On Windows/MacOS, it needs to be cleared, cf. atom/atom#2887 */
237+
var spawnEnv = (process.platform === 'linux') ? Object.create(process.env) : {};
238+
spawnEnv['ATOM_SHELL_INTERNAL_RUN_AS_NODE'] = '1';
234239
this.child = spawn(this.node, [
235240
// '--debug', // Uncomment if you want to debug the child process
236241
childJsPath
237-
].concat(customArguments), { cwd: path.dirname(childJsPath), env: { ATOM_SHELL_INTERNAL_RUN_AS_NODE: '1' }, stdio: ['ipc'] });
242+
].concat(customArguments), {
243+
cwd: path.dirname(childJsPath),
244+
env: spawnEnv,
245+
stdio: ['ipc']
246+
});
238247

239248
this.child.on('error', (err) => {
240249
if (err.code === "ENOENT" && err.path === this.node) {

0 commit comments

Comments
 (0)