Skip to content

process.env (wasi) not working #2914

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
vm-001 opened this issue Mar 27, 2025 · 2 comments
Closed

process.env (wasi) not working #2914

vm-001 opened this issue Mar 27, 2025 · 2 comments
Labels

Comments

@vm-001
Copy link

vm-001 commented Mar 27, 2025

Question

How to access environment variables in assemblyscript?

process.env.get("key1")

I noticed that the env variables access can be done in other languages(such as rust and tinygo) when .wasm was built with the wasip1 target. How to build wasm with wasip1 support in AssemblyScript?

@mattjohnsonpint
Copy link
Contributor

Use the WASI shim. Yes, it still works.

Your host will still need to expose the desired environment variables via the appropriate WASI host functions.

@vm-001 vm-001 closed this as completed Mar 28, 2025
@vm-001
Copy link
Author

vm-001 commented Mar 28, 2025

My asconfig.json ends up looks like this

{
  "extends": "./node_modules/@assemblyscript/wasi-shim/asconfig.json",
  "targets": {
    "release": {
      "outFile": "index.wasm",
      "textFile": "index.wat",
      "optimizeLevel": 3,
      "shrinkLevel": 0,
      "converge": false,
      "noAssert": false
    }
  },
  "options": {
    "bindings": "esm",
    "use": "abort=abort_proc_exit"
  }
}

process.env.get and process.env.keys() now works

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants