Skip to content

Commit fe7b977

Browse files
Fix disco_datadir variable not recognized after wizer
1 parent e7c9e4d commit fe7b977

2 files changed

Lines changed: 8 additions & 10 deletions

File tree

src/Eval.hs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,10 @@ resolveModule' = resolveModule
4646

4747
initDisco :: IO ()
4848
initDisco = do
49-
putStrLn $ "Printing Environment"
50-
xs <- getEnvironment
51-
forM_ xs $ \(a,b) -> putStrLn $ a <> " = " <> b
52-
53-
let filename = "/stdlib/num.disco"
54-
putStrLn $ "Printing " <> filename
55-
putStrLn =<< readFile filename
49+
-- NOTE: We set path environment variables here,
50+
-- because processing the .wasm module with `wizer` may bake
51+
-- them into the code.
52+
setEnv "disco_datadir" "stdlib"
5653

5754
s <- runM $ resolveModule' FromStdlib "num"
5855
print s

www/runtime.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,11 @@ export async function runWASM() {
3030
await addLibFile("prop", fs);
3131
await addLibFile("string", fs);
3232

33+
// NOTE: env: may not work on a .wasm module that was
34+
// processed with the `wizer` tool.
35+
// For this reason,
36+
// we set some environment variables inside the .wasm module.
3337
const wasi = new WASI({
34-
env: {
35-
disco_datadir: "stdlib"
36-
},
3738
fs: fs,
3839
stdout: (out) => console.log("[wasm stdout]", out),
3940
});

0 commit comments

Comments
 (0)