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

Can javy receive command line args / env. Are they in scope? #592

Open
ieugen opened this issue Jan 23, 2024 · 11 comments
Open

Can javy receive command line args / env. Are they in scope? #592

ieugen opened this issue Jan 23, 2024 · 11 comments
Labels
question Further information is requested

Comments

@ieugen
Copy link

ieugen commented Jan 23, 2024

What is your question?

This is probably a noob question, but here it goes:

Would it be possible to pass command line options to a wasm module?
How about environment variables ?!

I've read https://github.com/bytecodealliance/javy#invoking-javy-generated-modules-programatically .

@ieugen ieugen added the question Further information is requested label Jan 23, 2024
@jeffcharles
Copy link
Collaborator

WASI preview 1 supports environment variables and command line arguments and Javy modules are compiled as WASI preview 1 Wasm modules. However, Javy does not currently expose APIs to read environment variables or command line arguments to the JavaScript source code it runs.

We'd be open to a contribution adding those APIs! But I'd recommend proposing and aligning on what those APIs would look like before writing too much code given there isn't a standard API in JavaScript for reading environment variables and command line arguments.

@ieugen
Copy link
Author

ieugen commented Jan 23, 2024

Hi @jeffcharles ,

Can be added under Javy object? https://github.com/bytecodealliance/javy/blob/main/npm/javy/src/index.ts

The API could be the same / similar API that nodejs exposes. but under Javy:

The data is an array and a map / JS object .
WDYT?

@jeffcharles
Copy link
Collaborator

Have you read through https://github.com/bytecodealliance/javy/blob/main/docs/contributing-architecture.md#javy-apis?

The APIs you're proposing make sense to me!

I guess before we go too far down this path, what's your use case for getting command line arguments and environment variables?

@ieugen
Copy link
Author

ieugen commented Jan 24, 2024

Have you read through https://github.com/bytecodealliance/javy/blob/main/docs/contributing-architecture.md#javy-apis?

No I haven't . Just discovered the process yesterday and I made this https://github.com/ieugen/cherry-wasm-demo .
Right now I want to experiment and see how far can I go with Clojure(Script) and wasm.

I do DevOps so my focus will be on making some CLI's and tooling to help with that.

== Some time into the future
My big dream is to be push WASM apps to something like a OCI registry https://opencontainers.org/posts/blog/2023-07-07-summary-of-upcoming-changes-in-oci-image-and-distribution-specs-v-1-1/ .

This should make app distribution on systems very robust and easy (one tool to install any app / software package you want) . being wasm should work on any architecture.
There are also offerings of private OCI registry hosting so you can get a highly available one if you need.
And also self hosted versions.

@jeffcharles
Copy link
Collaborator

No I haven't . Just discovered the process yesterday and I made this https://github.com/ieugen/cherry-wasm-demo .

Alright, take a look at the process for adding a new API there and let me know if you have any questions!

My big dream is to be push WASM apps to something like a OCI registry https://opencontainers.org/posts/blog/2023-07-07-summary-of-upcoming-changes-in-oci-image-and-distribution-specs-v-1-1/ .

Have you taken a look at warg?

@ieugen
Copy link
Author

ieugen commented Jan 24, 2024

Alright, take a look at the process for adding a new API there and let me know if you have any questions!

Can you teach me rust ? :D

Have you taken a look at warg?
I am looking now. thanks.

@jeffcharles
Copy link
Collaborator

Can you teach me rust ? :D

Unfortunately I would not have time haha! I used Rustlings and Exercism to learn in the past. And fortunately the changes involved are not too difficult in terms of the amount of Rust knowledge that would be necessary to learn.

@ieugen
Copy link
Author

ieugen commented Feb 5, 2024

I was able to build javy on my system.
Will see what I can do with the others.
Thanks.

@ieugen
Copy link
Author

ieugen commented Feb 5, 2024

@jeffcharles : Is wasmtime 17 necessary for this work? https://github.com/bytecodealliance/wasmtime/releases/tag/v17.0.0

It does include wasi preview 2 with env vars and cli args and other things.
I noticed javy uses wasmtime 16 for now.

If that is the case, is there a plan /estimate to update to wasmtime 17 ?

@jeffcharles
Copy link
Collaborator

Wasmtime 17 shouldn't be necessary since Javy will continue to target WASI preview 1 for now.

@jachstet-sea
Copy link

I would also have an interest in reading the arguments passed to the WASM runtime in the JavaScript code.
Our use case: We have existing C source code that is compiled to WASM and we would like to re-write that in JavaScript, exposing the same behaviour in the and.

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

No branches or pull requests

3 participants