Skip to content
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

process.argv undefined #119

Open
anuraaga opened this issue Dec 22, 2023 · 2 comments
Open

process.argv undefined #119

anuraaga opened this issue Dec 22, 2023 · 2 comments

Comments

@anuraaga
Copy link

anuraaga commented Dec 22, 2023

I am trying to run a very simple program using argv.

argv.js:

import { argv } from 'process';
console.log(argv);

But it seems to be undefined

 wasmedge --dir=. wasmedge_quickjs.wasm argv.js foo bar baz
undefined

Tried wasmedge --dir=. wasmedge_quickjs.wasm argv.js -- foo bar baz as well just in case but with same result.

I see argv should be set to globalThis.argv, which I assume should be initialized by quickjs itself, calling the WASI function to fetch arguments, but it seems to not be happening.

https://github.com/second-state/wasmedge-quickjs/blob/main/modules/process.js#L9C28-L9C28

env, initialized in the same pattern, seems to work fine

env.js:

import { env } from 'process';
console.log(env["ANIMAL"]);
❯ wasmedge --env ANIMAL=bear --dir=. wasmedge_quickjs.wasm env.js
bear

I have tried both the latest release wasmedge_quickjs.wasm and one I built myself from commit ebad9e74 (before TLS addition).

@alabulei1
Copy link
Member

@L-jasmine Please take a look. Thanks.

@L-jasmine
Copy link
Collaborator

@anuraaga I apologize for the confusion, and thank you for bringing up the question. I'm not very familiar with JavaScript myself, so I initially thought that arguments were obtained using 'args'.

global.set("args", args_obj.into());

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

No branches or pull requests

3 participants