-
Notifications
You must be signed in to change notification settings - Fork 24
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
Borked on *nix that isn't Linux nor Redox #1
Comments
Hey @kijikeki, thank you for the report! May I ask which kind of Unix are you running? Would you propose widening the platforms eligible to use XDG user dirs or do you have a different solution in mind? Thanks, Simon Edit: Oh, I see this is Android – would there be more appropriate directories to use there? |
Howdy there! I found a similar result when building cargo-make (this crate is in the dep tree) on FreeBSD 11.2/stable Rust (current CI failure: https://cirrus-ci.com/task/6627659522506752). I suspect this isn't a huge fix so I'll likely dig in later today and see if I can't help with a fix. For the meantime I figured I'd add context here. |
Thank you @fnichol! |
@kijikeki Can you comment on how useful these functions are on Android? I'd expect that even if it compiled that the XDG user dirs all returned If you install such an APK with native code, do you even have read access/write access to I'm currently considering either
What do you think? |
As an APK, |
I think the Linux code path should be fine as well. Looks like you'd essentially get XDG behavior which works most Unix derivatives such as FreeBSD (in my case), even on macOS (personally, I'm liking the |
Yeah, well I got a |
This change broadens the list of targets which will conditionally compile the `user_dir` and `user_dirs` functions. Prior to this change, only the Linux and Redox OS targets will compile an implementation meaning that other Unix derivatives such as Android, FreeBSD, NetBSD, Darwin, etc. would not have a compiled implementation of these functions. Once paired and consumed by the upstream `dirs` crate this would lead to a compilation failure on these "extra" targets. This change allows all Unix family targets in addition to the Redox OS target to compile the same implementation. Closes dirs-dev#1 Signed-off-by: Fletcher Nichol <[email protected]>
Well, I have a proposed fix in #2 linked above which does open the target list for Would this work in all our use cases or do we need to be more surgical with Android? Note that I tested this by creating a new crate (via |
Actually, is dirs even used in any rust APKs? |
If it is implemented, perhaps make it a feature, leave it up to the developer on what to do? E.g.: [features]
android-apk = [ "jni" ] |
@fnichol Wouldn't this change also enable macOS? |
It would, technically although only for this crate. With a stock macOS system, calls to I tested this out by creating another test crate (with a const TARGET: &str = env!("TARGET");
fn main() {
println!("target triple: {}", TARGET);
println!("desktop_dir: {:?}", dirs_sys::user_dir("DESKTOP"));
println!("pictures_dir: {:?}", dirs_sys::user_dir("PICTURES"));
} This was the fn main() {
println!(
"cargo:rustc-env=TARGET={}",
std::env::var("TARGET").unwrap()
);
} And the output, first on my Mac, and then a second time in the Rust Docker container which is based on Debian/Stretch: > cargo run
Compiling libc v0.2.55
Compiling cfg-if v0.1.9
Compiling test-dirs-sys v0.1.0 (/Users/fnichol/Projects/github.com/soc/test-dirs-sys)
Compiling dirs-sys v0.3.1 (/Users/fnichol/Projects/github.com/soc/dirs-sys-rs)
Finished dev [unoptimized + debuginfo] target(s) in 2.44s
Running `target/debug/test-dirs-sys`
target triple: x86_64-apple-darwin
desktop_dir: None
pictures_dir: None
# Sorry for the directory changing steps, but I needed my local fork present when
# compiling the project inside the Docker container
> pushd .. && docker run --rm -ti -v $(pwd):/src -w /src/test-dirs-sys rust cargo run; popd
~/Projects/github.com/soc ~/Projects/github.com/soc/test-dirs-sys
Updating crates.io index
Downloaded cfg-if v0.1.9
Downloaded libc v0.2.55
Compiling libc v0.2.55
Compiling cfg-if v0.1.9
Compiling test-dirs-sys v0.1.0 (/src/test-dirs-sys)
Compiling dirs-sys v0.3.1 (/src/dirs-sys-rs)
Finished dev [unoptimized + debuginfo] target(s) in 44.46s
Running `target/debug/test-dirs-sys`
target triple: x86_64-unknown-linux-gnu
desktop_dir: None
pictures_dir: None While I don't personally think this is too bad, I could treat macOS and any other relevant targets specifically to return I'm more than happy to go any which way here. Thoughts? Thanks! |
@fnichol Funny timing, I just committed changes, but didn't hit the publish button yet: 51b0e46 What do you think? I'd prefer not allowing macOS in the ifdef, because the implementation resides in a file called xdg_user_dirs, and just adding more stuff (e. g. in a different place) for macOS doesn't make sense imho, because dirs-rs already provides the functionality itself. |
@soc Awesome, I think that will work nicely! Thanks so much for working through this, my CI should happily light back up green again. 🍰 |
Ok, great! I published dirs-sys-rs 0.3.2, and after the CI is green for dirs-rs and directories-rs I'll publish them too. |
Things are green, publishing. Thanks! |
Green here on Android too, thanks a lot! |
Great, thank you! Closed in 51b0e46. |
dirs_sys::user_dir
is only defined for Linux and Redox.The text was updated successfully, but these errors were encountered: