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

fix: cargo update for Rust 1.80.0 #456

Conversation

elldritch
Copy link
Contributor

cd backend && cargo build no longer works on Rust 1.80.0. Here's the error message:

   Compiling time v0.3.21
error[E0282]: type annotations needed for `Box<_>`
  --> /home/eliza/.cargo/registry/src/index.crates.io-6f17d22bba15001f/time-0.3.21/src/format_description/parse/mod.rs:83:9
   |
83 |     let items = format_items
   |         ^^^^^
...
86 |     Ok(items.into())
   |              ---- type must be known at this point
   |
   = note: this is an inference error on crate `time` caused by an API change in Rust 1.80.0; update `time` to version `>=0.3.35` by calling `cargo update`

For more information about this error, try `rustc --explain E0282`.
error: could not compile `time` (lib) due to 1 previous error
warning: build failed, waiting for other jobs to finish...

The note says this is due to an API change in Rust, and is fixed by running cargo update, so I did, and it did indeed fix the error.

@elldritch
Copy link
Contributor Author

Wait, this seems to break cd frontend && yarn build, resulting in:

yarn run v1.22.22
$ rimraf dist/ && webpack
🧐  Checking for wasm-pack...

✅  wasm-pack is installed at /home/eliza/.cargo/bin/wasm-pack.

ℹ️  Compiling your crate in release mode...

[INFO]: 🎯  Checking for the Wasm target...
[INFO]: 🌀  Compiling to Wasm...
warning: virtual workspace defaulting to `resolver = "1"` despite one or more workspace members being on edition 2021 which implies `resolver = "2"`
note: to keep the current resolver, specify `workspace.resolver = "1"` in the workspace root's manifest
note: to use the edition 2021 resolver, specify `workspace.resolver = "2"` in the workspace root's manifest
note: for more details see https://doc.rust-lang.org/cargo/reference/resolver.html#resolver-versions
   Compiling shengji-wasm v0.1.0 (/home/eliza/src/personal/shengji/frontend/shengji-wasm)
    Finished `release` profile [optimized] target(s) in 4.00s
[INFO]: ⬇️  Installing wasm-bindgen...
[INFO]: Optimizing wasm binaries with `wasm-opt`...
[INFO]: License key is set in Cargo.toml but no LICENSE file(s) were found; Please add the LICENSE file(s) to your project directory
[INFO]: ✨   Done in 14.01s
[INFO]: 📦   Your wasm pkg is ready to publish at /home/eliza/src/personal/shengji/frontend/shengji-wasm/pkg.
✅  Your crate has been correctly compiled

Browserslist: caniuse-lite is outdated. Please run:
  npx browserslist@latest --update-db
  Why you should do it regularly: https://github.com/browserslist/browserslist#browsers-data-updating
assets by status 2.98 MiB [cached] 11 assets
Entrypoint main = 407.61907f0b716cc360ef6c.js style.css main.6d89f96101ad0a9c67c8.js 3 auxiliary assets
orphan modules 2 MiB [orphan] 502 modules
runtime modules 9.76 KiB 16 modules
cacheable modules 2.88 MiB (javascript) 5.69 KiB (css/mini-extract) 592 KiB (webassembly) 234 modules

ERROR in ./shengji-wasm/pkg/shengji-core_bg.wasm
Module parse failed: Internal failure: parseVec could not cast the value
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
Error: Internal failure: parseVec could not cast the value
    at new CompileError (/home/eliza/src/personal/shengji/frontend/node_modules/@webassemblyjs/helper-api-error/lib/index.js:40:109)
    at parseVec (/home/eliza/src/personal/shengji/frontend/node_modules/@webassemblyjs/wasm-parser/lib/decoder.js:328:15)
    at parseTypeSection (/home/eliza/src/personal/shengji/frontend/node_modules/@webassemblyjs/wasm-parser/lib/decoder.js:352:29)
    at parseSection (/home/eliza/src/personal/shengji/frontend/node_modules/@webassemblyjs/wasm-parser/lib/decoder.js:1363:24)
    at Object.decode (/home/eliza/src/personal/shengji/frontend/node_modules/@webassemblyjs/wasm-parser/lib/decoder.js:1712:25)
    at decode (/home/eliza/src/personal/shengji/frontend/node_modules/@webassemblyjs/wasm-parser/lib/index.js:248:21)
    at WebAssemblyParser.parse (/home/eliza/src/personal/shengji/frontend/node_modules/webpack/lib/wasm-async/AsyncWebAssemblyParser.js:48:19)
    at /home/eliza/src/personal/shengji/frontend/node_modules/webpack/lib/NormalModule.js:1089:26
    at processResult (/home/eliza/src/personal/shengji/frontend/node_modules/webpack/lib/NormalModule.js:802:11)
    at /home/eliza/src/personal/shengji/frontend/node_modules/webpack/lib/NormalModule.js:862:5
 @ ./shengji-wasm/pkg/shengji-core.js 1:0-47 4:15-19 5:0-21
 @ ./src/WasmProvider.tsx 2:0-63 5:21-28 8:23-48 15:23-46 18:23-51 21:23-53 24:23-45 27:23-46 30:23-55 33:23-44 36:23-47 39:23-44 42:34-57
 @ ./src/index.tsx

webpack 5.76.0 compiled with 1 error in 34092 ms
(node:819460) [DEP_WEBPACK_DEPRECATION_ARRAY_TO_SET] DeprecationWarning: Compilation.modules was changed from Array to Set (using Array method 'reduce' is deprecated)
(Use `node --trace-deprecation ...` to show where the warning was created)
(node:819460) [DEP_WEBPACK_MODULE_ERRORS] DeprecationWarning: Module.errors was removed (use getErrors instead)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

This update might be overzealous. I think it might have updated some WASM thing.

@elldritch
Copy link
Contributor Author

Hmm, this might be webpack/webpack#15566?

@rbtying
Copy link
Owner

rbtying commented Nov 29, 2024

oh, thank you for doing this! Will need to fiddle with the build, I think WASM stuff has changed a bit…

@rbtying
Copy link
Owner

rbtying commented Dec 2, 2024

I think I fixed the issues (needed a webpack upgrade too), but for your context you can do cargo update -p ${package_name} to do a more targeted upgrade

@rbtying rbtying closed this Dec 2, 2024
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

Successfully merging this pull request may close these issues.

2 participants