-
Notifications
You must be signed in to change notification settings - Fork 55
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
Question on usage of preopens in WASM component #194
Comments
Thanks for the report! It looks like you're using the component support which I should give a warning is a little underbaked at the moment. For example as I'm sure you've found here you're left to implement WASI yourself which can be a bit of an undertaking. This is likely where much of the complexity lies, and building WASI from scratch will mean you're opening yourself up to a number of interesting failure modes to debug. I'm not super familiar with TinyGo here, so I can't say for certain, but my guess is that the |
@alexcrichton thank you for the reply and the insight. Do you know where I can find references or examples of how to implement the class HostPreopens:
def get_directories(self):
print("in get dir")
return [] |
Sorry as I mentioned before this is all not a well-trodden path so I'm not aware of example or documentation to assist you. If that's not getting printed then I'm probably wrong about the source of the error. I can't access the repository link you posted above, so I don't know what the error is here. |
@alexcrichton I am sorry 🙏 . I didn't realize that the repo I shared was private. I made it a public repo: https://github.com/shihanng/play-wasm The code reproduces the abovementioned issue is in the I am using the following to create the WASM component and create the bindgen in the
The code that uses the WASM component is in
|
Ok I believe you're running into an issue with TinyGo where it doesn't fully support the "reactor" pattern today. I may be wrong, though, and my knowledge of TinyGo isn't great so it could be dated too. But I believe that historically the TinyGo runtime requires initialization through the I believe that because the runtime isn't fully initialized that various constructors aren't run which means that files don't work. I recall seeing a similar issue in a different repository, but I unfortunately can't remember where at this time. |
I have a Go code that writes to a temporary directory like the following. I want to compile the code into a WebAssembly component and call it from a Python code.
I can compile the code and use
python -m wasmtime.bindgen
to generate the Python code. The following is my entry point to call the WebAssembly code:When trying to execute the
main.py
, I get an error indicating that I don't have access to the temporary directory. I am guessing that I need to implement theHostPreopens
; however, I could not find documentation showing how to do so.Is
Preopens
the right approach to solve the issue above? Where can I find documentation or example code regarding providing WASM component access to the file system?Note: I put all the codes above, including the WIT-file, in this repo https://github.com/shihanng/play-wasm/tree/fs/wit for reproducibility.
Thank you.
The text was updated successfully, but these errors were encountered: