trunk
trunk copied to clipboard
Uncaught TypeError: Bare Specifier “env” Not Remapped During Trunk Serve
Problem
Uncaught TypeError: The specifier “env” was a bare specifier, but was not remapped to anything. Relative module specifiers must start with “./”, “../” or “/”.
Details
When building my project, an error occurs indicating that a bare specifier "env" is not properly remapped, causing a TypeError in the browser console.
Reference for my Cargo.toml file
[package]
name = "pigg"
version = "0.2.0"
edition = "2021"
description = "A Graphical User Interface for interacting with local and remote Raspberry Pi Hardware"
default-run = "piggui"
authors = ["Andrew Mackenzie <[email protected]>", "Sundaram Krishnan <[email protected]>"]
license = "Apache-2.0"
documentation = "https://github.com/andrewdavidmackenzie/pigg/README.md"
repository = "https://github.com/andrewdavidmackenzie/pigg/"
readme = "README.md"
[[bin]]
name = "piggui"
path = "src/piggui.rs"
required-features = ["gui"]
[[bin]]
name = "piglet"
path = "src/piglet.rs"
[features]
default = ["fake_hw"]
pi_hw = ["rppal"]
fake_hw = []
gui = ["iced", "iced_futures", "rfd", "plotters-iced", "plotters", "getrandom/js"]
[dependencies]
# use in piggui and piglet
chrono = { version = "0.4", default-features = false, features = ["now", "wasmbind", "wasm-bindgen", "js-sys"] }
serde = { version = "1.0.203", features = ["derive"] }
serde_json = { version = "1.0.118" }
rand = { version = "0.8.5" }
clap = { version = "4.5.7" }
# for interacting with GPIO on the Raspberry Pi
rppal = { version = "0.18.0", optional = true }
# used in piglet only
log = "0.4.21"
env_logger = "0.11.3"
# used by piggui in GUI only
iced = { version = "0.12.1", default-features = false, features = ["tokio", "debug", "canvas", "advanced", "webgl"], optional = true }
iced_aw = { version = "0.9.3", default-features = false, features = ["tabs", "card", "modal", ], optional = true }
iced_futures = { version = "0.12.0", default-features = false, optional = true }
iced_native = { version = "0.10.3", optional = true }
rfd = { version = "0.14.1", optional = true }
plotters-iced = { version = "0.10", optional = true }
plotters = { version = "0.3", optional = true, default_features = false, features = [
"chrono",
"line_series",
] }
getrandom = { version = "0.2", features = ["js"]}
[dev-dependencies]
tempfile = "3"
Any help is highly appreciated! Thx in adv!
Also getting this. But it's only affecting my github actions builds and I'm unable to replicate locally with either trunk serve or build. And the actions builds were working just fine yesterday with no changes in dependencies on my end.
Running a cargo update I was able to reproduce the issue on my end locally with the following crates having updates:
Updating aho-corasick v1.0.2 -> v1.1.3
Updating autocfg v1.1.0 -> v1.3.0
Updating bitflags v2.5.0 -> v2.6.0
Updating cc v1.0.101 -> v1.0.102
Updating regex v1.9.0 -> v1.10.5
Updating regex-automata v0.3.0 -> v0.4.7
Updating regex-syntax v0.7.3 -> v0.8.4
Updating unicode-ident v1.0.10 -> v1.0.12
Out of these only cc has updated recently enough to be the culprit and indeed manually reverting cc in the cargo lock and doing a fresh build fixed it locally for me.
It looks like in my case I'm depending on cc through zstd-safe -> zstd-sys -> cc.
If your issue is also with cc you can change your Cargo.lock entry for cc to:
[[package]]
name = "cc"
version = "1.0.101"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac367972e516d45567c7eafc73d24e1c193dcf200a8d94e9db7b3d38b349572d"
dependencies = [
"jobserver",
"libc",
"once_cell",
]
Edit: Put in issue on cc for this. https://github.com/rust-lang/cc-rs/issues/1113
Thanks for the mention @Kuuuube , but the issue still persists. My cc package is still in version 1.0.101 as specified in Cargo.lock.
Can you explain where and how you get that error?
To provide context, we are exploring publishing our rust application pigg to wasm.
However, when attempting to open the browser after running trunk serve, I encounter the following error message in my console.
For reference, i have provided my Cargo.toml in the issue.
Ah I see. So trunk "only" orchestrates the build. I think a good detailed explanation for this is here: https://github.com/rustwasm/wasm-bindgen/discussions/3500
In a nutshell, you're compiling something to WASM that doesn't work on a WASM target. To my understanding, the basically is a "symbol not found" error.
You would need to find what dependency brings that in, and then ensure that creates proper code for WASM. Things like env-var, won't work on WASM.
I guess it makes sense to transform this into a discussion if that's ok with you.
Sure, will do I am closing this issue then, Thx for ur response @ctron