diff --git a/ivette/src/dome/misc/system.ts b/ivette/src/dome/misc/system.ts index 7c726722647b4feefedce7e891b83eeb2d54b824..58c8badba810a5a07a0cabb44b89caa0b66600a8 100644 --- a/ivette/src/dome/misc/system.ts +++ b/ivette/src/dome/misc/system.ts @@ -537,21 +537,23 @@ export function spawn( return new Promise((result, reject) => { const cwd = options ? options.cwd : undefined; - const env = options && options.env ? ({ ...process.env, ...options.env }) : undefined; + const opt = options ? options.env : undefined; + const env = // Forces 'PWD' env. variable for executing a non-shell process + (cwd || opt) ? { ...process.env, ...opt, 'PWD': cwd } : undefined; const stdin = stdSpec(options && options.stdin, false); const stdout = stdSpec(options && options.stdout, true); const stderr = stdSpec(options && options.stderr, true); const stdio = [stdin.io, stdout.io, stderr.io]; - const opt: Exec.ForkOptions = { cwd, env, stdio }; - const fork = options && options.fork; + const fopt: Exec.ForkOptions = { cwd, env, stdio }; + const forked = options && options.fork; const cargs = args ? args.slice() : []; let child: Exec.ChildProcess | undefined; - if (fork) { + if (forked) { stdio.push('ipc'); - child = Exec.fork(command, cargs, opt); + child = Exec.fork(command, cargs, fopt); } else { - child = Exec.spawn(command, cargs, opt); + child = Exec.spawn(command, cargs, fopt); } if (!child) reject(new Error( diff --git a/src/libraries/utils/filepath.ml b/src/libraries/utils/filepath.ml index c0070248e9f622d3f4a594834412f326ffa02341..35da51d54ec8b3402b08cfd97bf2c2e572d07d2c 100644 --- a/src/libraries/utils/filepath.ml +++ b/src/libraries/utils/filepath.ml @@ -132,7 +132,14 @@ let insert base path_name = Instead of forcing the user to always provide resolved paths, we currently choose to never resolve them. Note that, in rare situations (e.g. some Docker images), PWD does not - exist in the environment, so in that case, we fallback to Sys.getcwd. *) + exist in the environment, so in that case, we fallback to Sys.getcwd. + + REMARK[LC]: when the Frama-C binary is directly invoked by Node without + going through a shell script wrapper like ./bin/frama-c, the environment + variable "PWD" is _no more_ synchronized with Sys.getcwd. + This problem has been solved in `Dome.spawn()` by forcing the `PWD` + environement variable accordingly. +*) let cwd = insert dummy (try Sys.getenv "PWD" with Not_found -> Sys.getcwd ()) type existence =