I was getting into Rust and looking at these simple instructions for Yew framework (a frontend framework for Rust).
(Found at: https://yew.rs/docs/tutorial)
I followed the instructions up until the command
trunk serve --open
However, something somewhere fails.
This is what I'm getting:
2022-05-06T19:07:54.087214Z INFO 📦 starting build
2022-05-06T19:07:54.087870Z INFO spawning asset pipelines
2022-05-06T19:07:54.168329Z INFO building yew-app
Finished dev [unoptimized + debuginfo] target(s) in 0.01s
2022-05-06T19:07:54.232154Z INFO fetching cargo artifacts
2022-05-06T19:07:54.295124Z INFO processing WASM for yew-app
2022-05-06T19:07:54.301974Z INFO downloading wasm-bindgen version="0.2.80"
2022-05-06T19:07:54.302269Z ERROR ❌ error
error from HTML pipeline
Caused by:
0: error from asset pipeline
1: failed downloading release archive
2: unsupported architecture
2022-05-06T19:07:54.302531Z INFO 📡 serving static assets at -> /
2022-05-06T19:07:54.302591Z INFO 📡 server listening at http://127.0.0.1:8080
This is my Cargo.toml file:
[package]
name = "yew-app"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
yew = "0.19"
Output after I run rustup target list --installed command:
aarch64-apple-darwin
wasm32-unknown-unknown
Machine: M1 Mac (with Apple Silicon chip)
Rust version: 1.60.0
trunk version: 0.15.0
Any help would be appreciated as I'm just getting into Rust and Web Assembly.
Thanks
Fix it by installing wasm-bindgen-cli:
cargo install --locked wasm-bindgen-cli
This is mentioned in this PR on trunk's GitHub: https://github.com/thedodd/trunk/pull/375
Related
enter image description here
**I create rust project by "cargo new [name]" and install rust-analyzer in vsCode.But when I open the project by vscode,there's an error "rust-analyzer failed to load workspace: Failed to read Cargo metadata from Cargo.toml file e:\rustBlog\server\Cargo.toml, cargo 1.60.0 (d1fd9fe2c 2022-03-01): Failed to parse edition 2021: invalid edition: "2021"".How to resolve it? **
cargo --version 1.60.0
rustc --version 1.60.0
rust-analyzer version 0.2.297
I resolve it by update vsCode to newest version "1.67.1" and uninstall vscode extension named "Rust".The two of them are in conflict!
I am trying to build a basic application for the Adafruit CLUE using Rust.
When using the peripheral access crate (PAC) everything works fine, but I would like to use the HAL crate from Nordic Semiconductors.
I set up a very basic project which uses their nrf52840-hal crate. When running cargo build, I get the following error (full build log with --verbose):
Updating crates.io index
Compiling semver-parser v0.7.0
Compiling cortex-m v0.7.4
Compiling proc-macro2 v1.0.37
Compiling nb v1.0.0
Compiling unicode-xid v0.2.3
Compiling syn v1.0.92
Compiling vcell v0.1.3
Compiling void v1.0.2
Compiling bitfield v0.13.2
Compiling cortex-m-rt v0.7.1
Compiling critical-section v0.2.7
Compiling typenum v1.15.0
info: syncing channel updates for 'nightly-2021-08-18-x86_64-unknown-linux-gnu'
Compiling az v1.2.0
Compiling nrf52840-pac v0.11.0
info: latest update on 2021-08-18, rust version 1.56.0-nightly (30a0a9b69 2021-08-17)
Compiling fixed v1.15.0
Compiling cfg-if v1.0.0
info: component 'rust-src' is up to date
info: component 'rust-std' for target 'riscv32imac-unknown-none-elf' is up to date
info: component 'rust-std' for target 'riscv32imc-unknown-none-elf' is up to date
info: component 'rust-std' for target 'thumbv6m-none-eabi' is up to date
info: component 'rust-std' for target 'thumbv7em-none-eabi' is up to date
info: component 'rustfmt' for target 'x86_64-unknown-linux-gnu' is up to date
warning: Force-skipping unavailable component 'rust-std-avr-specs/avr-atmpeg328p.json'
Compiling bare-metal v1.0.0
error: unknown `--json` option `future-incompat`
Compiling half v1.8.2
error: could not compile `critical-section`
warning: build failed, waiting for other jobs to finish...
error: build failed
I am using rustup with the stable toolchain on Ubuntu 20.04 (using nighly 2022-05-03 does not change anything to the error message). Rustup version output is:
rustup 1.24.3 (ce5817a94 2021-05-31)
info: This is the version for the rustup toolchain manager, not the rustc compiler.
info: The currently active `rustc` version is `rustc 1.60.0 (7737e0b5c 2022-04-04)`
The full project is available here.
My .cargo/config.toml file is:
[build]
target = "thumbv7em-none-eabihf"
rustflags = [
"-C", "link-arg=-Tlink.x",
]
The Cargo.toml is:
[package]
name = "hal-test"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
cortex-m-rt = "0.7.1"
nrf52840-hal = "0.15.0"
panic-halt = "0.2.0"
and the src/main.rs file is:
#![no_std]
#![no_main]
use panic_halt as _;
#[cortex_m_rt::entry]
fn main() -> ! {
loop {}
}
I tried to go through the dependency tree but I failed to find where this future-incompat option is added, given that it is passed plenty of times to rustc and it succeeds.
I would appreciate any pointers as to where to look further.
Update 2022-05-06: building the project with the exact same toolchain version on Ubuntu 21.04 works, I'll have to investigate further.
The issue was fixed by switching away from the rustup snap and using the recommended installation method of running the shell script (https://www.rust-lang.org/tools/install).
I am very new to Rust. I have an issue with installing image crate:
[dependencies]
image = "0.23.14"
cargo 1.57.0 (b2e52d7ca 2021-10-21)
rustc 1.57.0 (f1edd0429 2021-11-29)
Microsoft Windows 10 Home
OS Version: 10.0.19043 N/A Build 19043
I get following compiling error:
error: failed to run custom build command for crc32fast v1.3.0
Probably some dependency is missing.
As it turned out, the problem was due to Kaspersky Anti Virus deleting the .exe file in build/crc32fast folder.
After adjusting Kaspersky I was able to compile.
Windows 10
rustup 1.23.1 (3df2264a9 2020-11-30)
default rustc 1.50.0 (cb75ad5db 2021-02-10)
project rustc 1.52.0-nightly (4a8b6f708 2021-03-11)
rocket = "0.4.4"
I'm trying to build a rust project with rocket but I always get this error when compiling, even after successfully overwriting the project's toolchain:
D:\GitHub\Learning-Rust\poke_api> rustup override set nightly
info: using existing install for 'nightly-x86_64-pc-windows-msvc'
info: override toolchain for 'D:\GitHub\Learning-Rust\poke_api' set to 'nightly-x86_64-pc-windows-msvc'
nightly-x86_64-pc-windows-msvc unchanged - rustc 1.52.0-nightly (4a8b6f708 2021-03-11)
PS D:\GitHub\Learning-Rust\poke_api> cargo build
Compiling winapi v0.3.9
Compiling serde_derive v1.0.124
Compiling rocket v0.4.7
Compiling pear_codegen v0.1.4
Compiling rocket_codegen v0.4.7
Compiling proc-macro2 v1.0.24
Compiling pq-sys v0.4.6
Compiling aho-corasick v0.6.10
Compiling serde_json v1.0.64
error: failed to run custom build command for `pear_codegen v0.1.4`
Caused by:
process didn't exit successfully: `D:\GitHub\Learning-Rust\poke_api\target\debug\build\pear_codegen-e182711746033ac9\build-script-build` (exit code: 101)
--- stderr
Error: Pear requires a 'dev' or 'nightly' version of rustc.
Installed version: 1.48.0 (2020-11-16)
Minimum required: 1.31.0-nightly (2018-10-05)
thread 'main' panicked at 'Aborting compilation due to incompatible compiler.', C:\Users\gabre\.cargo\registry\src\github.com-1ecc6299db9ec823\pear_codegen-0.1.4\build.rs:24:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
error: build failed
I had a similar issue while using rocket. Same error message too, Error: Pear requires a 'dev' or 'nightly' version of rustc.
If you get to the get-started page on rocket framework website. It says, "Rocket makes abundant use of Rust's syntax extensions and other advanced, unstable features. Because of this, we'll need to use a nightly version of Rust."
My issue was I was not using a nightly version of rust. Running this on my terminal in my project directory did it for me.
rustup override set nightly
If you check the cargo version for that directory after,
cargo version
you will confirm it has switched to nightly version
Failed compilation even with nightly
It looks like you have some outdated dependencies (pear-codegen probably being the one that causes trouble), updating these may resolve the compilation issues.
General notes on how to override the toolchain
Using rustups override works fine, but it is bound to your local rustup configuration and not specified inside the project.
In order to achieve this, thereby making the project more portable and allowing others to always use the correct toolchain, I would recommend the toolchain file. It can look something like this (example taken from linked page) and will accurately specify the required toolchain only for the containing project.
# rust-toolchain.toml
[toolchain]
channel = "nightly-2020-07-10"
components = [ "rustfmt", "rustc-dev" ]
targets = [ "wasm32-unknown-unknown", "thumbv2-none-eabi" ]
profile = "minimal"
For your purposes a simple configuration like this will most likely be all you need, although adding the components you want to use would be beneficial.
[toolchain]
channel = "nightly"
My issue was with rust-analyser that wouldn't start because multiple rocket dependencies needed nightly or dev version of rustc.
These steps fixed my issue:
Switch to nightly for my rocket project by running rustup override set nightly inside the app folder.
Remove all target folders in my project. (I also had one in root)
Manually remove the faulty cached packages from cargo cache. cd ~/.cargo/registry/cache/github.com-xxxxxxxxxxxx && rm -r pear_codegen-0.1.5/
On the git repository for Datafusion, it says to add the following to the Cargo.toml file to use it as a library:
[dependencies]
datafusion = "1.0.0-SNAPSHOT"
I get this as an output when running cargo build
Updating crates.io index
error: failed to select a version for the requirement `datafusion = "^1.0.0-SNAPSHOT"`
candidate versions found which didn't match: 0.17.0, 0.16.0, 0.15.1, ...
location searched: crates.io index
required by package `hello_cargo v0.1.0 (/Users/jay/Projects/hello_cargo)`
I then tried to use 0.17.0 and ran cargo +nightly build:
error: failed to run custom build command for `arrow-flight v0.17.0`
Caused by:
process didn't exit successfully: `/Users/jay/Projects/hello_cargo/target/debug/build/arrow-flight-46000fbc5b8b474b/build-script-build` (exit code: 1)
--- stderr
Error: "Failed to locate format/Flight.proto in any parent directory"
warning: build failed, waiting for other jobs to finish...
error: build failed
It seems to work when I use version 0.16.0
As Cargo tells you:
candidate versions found which didn't match: 0.17.0, 0.16.0, 0.15.1, ...
There are no versions called 1.0.0-SNAPSHOT of this crate published to crates.io. If you wish to use unreleased code from a git repository, you need to use a git dependency:
[dependencies]
rand = { git = "https://github.com/apache/arrow/" }
See also:
Can I add a dependent crate that is a subdirectory in a git repository?