cargo: home does not compile on wasm
Problem
The home crate does not build for wasm32-unknown-unknown. I encountered this through a transitive dependency from another crate.
Steps
$ cargo new bugreport
$ cd bugreport
$ echo 'home = "0.5"' >> Cargo.toml
$ cargo build --target wasm32-unknown-unknown
results in error:
error[E0425]: cannot find function `home_dir_inner` in the crate root
--> .cargo/registry/src/index.crates.io-6f17d22bba15001f/home-0.5.5/src/env.rs:33:16
|
33 | crate::home_dir_inner()
| ^^^^^^^^^^^^^^ not found in the crate root
Possible Solution(s)
Home has no obvious place in wasm, so I suggest adding the following (and I’m happy to add this myself, along with CI test on wasm target)
#[cfg(target_arch = "wasm32")]
fn home_dir_inner() -> Option<PathBuf> {
None
}
Notes
No response
Version
No response
About this issue
- Original URL
- State: open
- Created a year ago
- Comments: 20 (17 by maintainers)
I’m going to cancel the FCP here since I don’t think it is likely to move forward.
@rfcbot cancel
The team would like to see someone open an ACP as mentioned above in https://github.com/rust-lang/cargo/issues/12297#issuecomment-1707097192. @joshtriplett (who is also on the libs team) has also indicated they would like to see that route move forward.
Yup, I’ll see if I can squeeze out an ACP.
@djc we talked about this in the cargo team meeting and we are interested in the help. Additionally, we feel more of that time should probably be spent towards an ACP to merge this into the standard library as there is interest in such a thing
Independent of helping with
home, is that something you’d be willing to take on?Sorry I was taking a break for a while and this issue then escaped me. I think adding support for wasm doesn’t make much sense anyways since its not a nix or windows platform. In addition, I don’t think any of us have the bandwidth to figure that out at the moment.
My take is that
homeis primarily for rustup and cargo. I checked my box on this change because it is a relatively small change with what I think is little impact. But I think I would be against larger changes unless they are specifically to support cargo and rustup. So my perspective is to provide support on an as-available basis (like very small changes), but otherwise not accept larger changes.We should have tagged @LucioFranco, since they said they would help with maintaining it. That’s not a process we have handled too well.
I am pretty into this suggestion, similar to what you’ve proposed.
std::env::home_diralso returns aNoneon unsupported platforms despite its deprecation.I want to expand the proposal to align with things mentioned above — returns
Noneon currently unsupported platforms. Simply starting from this:Let’s do a quick poll.
@rfcbot fcp merge