-
Notifications
You must be signed in to change notification settings - Fork 409
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
env dependency not provided #743
Comments
@ashleygwilliams Passing through and dropping a possible clue
printed in
Should env be process.env? |
I am running into the same issue. Cannot run my binary on node because of |
Don't know if it helps, but happens only on release. (with target web, so I should be able to run it on the browser as generated - no npm install) |
@cedeber Yea, this is related to the |
I use the |
Looks like the culpable is, or one of the optimizations in Cargo.toml (I used |
Hm interesting. It should not be caused by the opt-level nor the lto, cause I am also compiling for
I see here you are simply calling |
I have
so I tried:
|
If I'm using rustc 1.44.1 I have to remove |
Not sure why but I am using nightly and lto works perfectly fine for me. |
This problem went away for me by updating to Rust 1.46 |
@jakearchibald Do you know why it's fixed? Cause it still |
No idea, sorry 😢 |
Any new insights to this? Running into the same issue.. |
Same here! Also, do we know what exactly within Rust code triggers whether |
What're the odds of this being fixed in a timely fashion? My options are this being fixed this week or rewriting in JS... |
I personally think this is a bug with wasm-bindgen that generates the |
Perhaps specific versions fo wasm-bindgen don't have this issue and could be used as a stop gap measure? |
I have the same issue. I am using rust 1.46. It just appeared and wasn't there before. |
I'm encountering this problem (currently observable in this commit) in the WASM file itself:
I do not have
|
rustwasm/wasm-bindgen#2160 is a promising-looking thread. |
In my case, Amanieu/parking_lot#269 was the root cause; an errant
|
We were having this issue when trying to build rust-secp256k1 on MacOS (we did not experience this issue on ubuntu). We were able to work around it by installing llvm and using
before running
|
For those using |
I'm getting a similar issue when targeting Build command: I have all optimizations and such turned off. I've tried enabling them in different combinations based on advice in this and other threads but nothing has worked so far.
$ rustup show
...
active toolchain
----------------
nightly-x86_64-apple-darwin (default)
rustc 1.60.0-nightly (89b9f7b28 2022-01-10)
|
is there any progress or solution |
I had the same problem and then solved it by doing the following // Remove the next line
// import * as __wbg_star0 from "env";
const __wbg_star0 = {
global: {},
env: {
memory: new Memory({ initial: 10, maximum: 100 }),
table: new Table({ initial: 0, element: "anyfunc" }),
abort: () => {
console.error("abort in wasm!");
throw new Error("Unsupported wasm api: abort");
},
// Any other functions you need to inject with WebAssembly.instantiateStreaming(module, importObject)
},
}; My wasm project requires some functions to be injected via the env object, you can upload your wasm file via this website and see which functions need to be injected via the env object Trying to figure out why this line of code is being created |
The solution should not be to have to manually edit the bindgen files. @alexcrichton attempted a fix of this years ago, yet many of us are still seeing this error under certain The most robust workaround I have seen to this so far is from: Amanieu/parking_lot#269 (comment) [features]
# `instant/wasm-bindgen` makes sure it will use `js_sys` for getting the system time
# `instant/inaccurate` uses `Date.now()` instead of `performance.now()`
default = ["instant/wasm-bindgen", "instant/inaccurate"]
[dependencies]
instant = "0.1.12" |
This is the workaround I'm currently using: https://gist.github.com/nicolas-sabbatini/8af10dddc96be76d2bf24fc671131add#file-wasm-bindgen-macroquad-L132-L135 Apparently it helps to just remove the imports - at least for some cases. |
🐛 Bug description
Error: Cannot find module 'env'
Require stack:
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:780:15)
at Function.Module._load (internal/modules/cjs/loader.js:685:27)
at Module.require (internal/modules/cjs/loader.js:838:19)
at require (internal/modules/cjs/helpers.js:74:18)
at Object. (/Users/d056831/Development/hdbconnect-wasm/pkg/hdbconnect_wasm_bg.js:6:18)
at Module._compile (internal/modules/cjs/loader.js:945:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:962:10)
at Module.load (internal/modules/cjs/loader.js:798:32)
at Function.Module._load (internal/modules/cjs/loader.js:711:12)
at Module.require (internal/modules/cjs/loader.js:838:19)
In the file
./pkg/hdbconnect_wasm_bg.js
there is arequire("env")
, but it is not inpackage.json
I tried a
npm install env
with no success.👟 Steps to reproduce
git clone https://github.com/PSeitz/hdbconnect-wasm
wasm-pack build --target nodejs
ts-node test.ts
🌍 Your environment
Include the relevant details of your environment.
wasm-pack version: tested with master and 0.8.1
rustc version: rustc 1.40.0-nightly (1423bec54 2019-11-05)
The text was updated successfully, but these errors were encountered: