4 ms·
For getting a users homedir I fall back to POSIX[0] (which windows follows in this instance fwiw). There are some things that I'm bitten by as a rust newbie th
by dijit 7y ago
For getting a users homedir I fall back to POSIX[0] (which windows follows in this instance fwiw).
There are some things that I'm bitten by as a rust newbie though; strings are definitely one of those, since it's more difficult to reason about strings as they're heap allocated, where as most "normal" types are not, thus to use Strings you have to learn the borrow checker..
Another issue I have is crate versions, and compiling and including _multiple versions_ of the same crate, because that crate is also a dependency on one of the crates I'm using.
Yet, another is crates that only support the nightly compiler, which you're not supposed to use for production, there needs to be some way of delineating the "stable" version of a crate with the "potential future" version of a crate.
Even if you stick to a version and the nightly compiler supercedes then you end up with the same error:
------8<------
Caused by:
process didn't exit successfully: `/Users/dijit/projects/rust/Rocket/target/debug/build/rocket_codegen-6474f79f6391da32/build-script-build` (exit code: 101)
--- stderr
Error: Rocket (codegen) requires a 'dev' or 'nightly' version of rustc.
Installed version: 1.43.1 (2020-05-04)
Minimum required: 1.33.0-nightly (2019-01-13)
------>8------
[0]: in POSIX the OS _must_ set $HOME: https://pubs.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap08.html https://pubs.opengroup.org/onlinepubs/009695399/basedefs/xbd...
- gfxgirl 7y agoI'm not sure about home dir but a thing I've needed is a standard place to store app stuff. On Windows it's a mess. There's AppData/Local, AppData/LocalLow, AppData/Remote and many apps store a ton of stuff in their app folder in c:\programs etc... On Mac I guess it's Library/Application Data but there's a bunch of other folders under Library. On Linux I read somewhere it's .config but there was no .config on my Linux installs and it seems strange to me that apps should be required to make this folder vs the OS and that the OS doesn't tell me where it is it's just convention. But in any case, I think I wish some standard library handled this.
- dijit 7y agoYes, I understand, and I feel your plight, as it stands this is what I would use: $APPDATA on windows[0] or $LOCALAPPDATA $XDG_CONFIG_HOME on linux[1], which is where you're getting the ~/.config from. For MacOS, it's a mess[2], you should probably use ~/Library/Application Support/script_name/ for most things though. [0]: https://ss64.com/nt/syntax-variables.html https://ss64.com/nt/syntax-variables.html [1]: https://wiki.archlinux.org/index.php/XDG_Base_Directory https://wiki.archlinux.org/index.php/XDG_Base_Directory [2]: https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/FileSystemOverview/FileSystemOverview.html#//apple_ref/doc/uid/TP40010672-CH2-SW1 https://developer.apple.com/library/archive/documentation/Fi...
- jcranmer 7y ago> $XDG_CONFIG_HOME on linux[1], which is where you're getting the ~/.config from. XDG_CONFIG_HOME is ~/.config if not otherwise specified.
- deleted 7y ago[deleted]
- wtetzner 7y ago> since it's more difficult to reason about strings as they're heap allocated I don't think them being heap allocated is the issue. I think the issue you're running into is that String doesn't implement the Copy trait, meaning they're not automatically copied for you. Which is what you want, because you don't want to be implicitly copying large strings without realizing it. But yes, it does mean you have to learn the borrow checker.
- steveklabnik 7y agoTwo sides of the same coin: it being heap allocated is why it does not implement Copy.
- wtetzner 7y agoI guess my point was you'd have the same issue with things that are not heap allocated, if they also did not implement Copy.