-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Support installing manpages (and potentially other files) #2729
Comments
Thinking about this, I think that with the specification hashed out, this becomes an E-easy issue. Given that, I'd like to propose a more precise specification for how Cargo should handle this:
Optionally, (I think it makes sense to use convention-over-configuration for this. If someone has a use case for specifying additional manpages by filename or directory name, we can always add a new field to |
just to note that bash (or other shell) completion might be another reasonable "potential other file" for a binary to ship |
@joshtriplett yeah I agree that once we have a specification for this it's an easy bug to knock off, but unfortunately the specification is the hard part. I don't think we'll want to extend Cargo to install just man pages (if at all) as as @davidszotten mentioned there's other things like bash completions, perhaps documentation, and even files like assets in games. We don't want Cargo to become a replacement package manager for the system or other "proper" installation methods, so I'm hesitant to make progress on this as well. The purpose of This probably wants to be discussed a little more broadly before trying to tackle each of the sub-issues associated. |
@alexcrichton I can understand that, but on the other hand, cargo doesn't quite yet support the constraints of distro package managers either, though folks are working on that. And in any case, distribution package managers don't support installing into I definitely wouldn't want to use cargo to install anything systemwide into For that matter, many distribution package build systems just have the package install itself into a temporary directory via |
Yeah right now we just don't want to open the floodgates to a whole litany of various post-installation steps of Cargo just yet. It may be worth prototyping this as a new subcommand (perhaps leveraging |
We could create a .cargo/share/man directory where the cargo install can install the manpage into, depending on the section (inferred from the name of the man page - foo.N). And then, as part of the installation of rust/cargo toolchain, we could add .cargo/share/man into the MANPATH environment variable. How does that sound? |
I have a use case where I want to install extra non-manpage files, but need the binary to know the path to them somehow (ie when installed needs to point to the install location, otherwise to somewhere in the source tree). |
You don't actually need to add But otherwise, |
I'd like to see this relative to the |
I propose that we tackle this issue in two steps:
I think that part 1 would be easy and uncontroversial, since there isn't any code to write or behavior to decide on. Also, it would would be very useful on its own for downstream packagers of rust binaries. For example, tools like https://github.com/mmstick/cargo-deb could be extended to include man pages in the |
On 2/10/17 10:04 PM, Casey Rodarmor wrote:
I propose that we tackle this issue in two steps:
1.
Decide on a standard way for crate authors to ship man pages as part
of their project. I think that |man/*.[1-9]| in the crate root would
a very reasonable way to go.
2.
Later decide if we want to extend cargo to actually install man
pages and the details of how that would work.
I think that part 1 would be easy and uncontroversial, since there isn't
any code to write or behavior to decide on. Also, it would would be very
useful on its own for downstream packagers of rust binaries. For
example, tools like https://github.com/mmstick/cargo-deb could be
extended to include man pages in the |.deb|, if present.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#2729 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAAih5WT_A-xnOqPpDHk0_k6xfXpgspUks5rbTM4gaJpZM4IkmVI>.
FWIW, Gentoo and Yocto already do this with man pages appearing in
man/*.[1-9] because that's how I ship my crates.
…--
Doug Goldstein
|
If we could extend this beyond man pages to general data files, that would be great. |
I think manpages are the most useful thing to handle first, and should be tackled before handling arbitrary other files. Also, while a |
@kballard That seems reasonable. Convention first, but also a Cargo.toml key that accepts either a string or list of strings; the strings can specify either directory names (install all manpages in the directory) or filenames (install the specified manpage). |
In my opinion, once we've gone down the road of having |
I fully concur with @BartMassey on the above. |
This is a must-have feature. You might also want to check how cabal handles this:
Automagic detection of manpages is fishy, imo. Instead, there should be wildcard support in the corresponding config syntax. Also, doing this properly and increasing compatibility with package managers will also involve having more fine-grained control over the installation destination (not just I wouldn't want to give full control over the installation procedure to the crate dev. It should not be possible to define arbitrary installation destinations. There must be a set of things, most likely corresponding to the FHS, like Or to put it simple: this feature is not a substitute for package managers at all, instead it increases package manager compatibility (if done right). |
@alexcrichton Could we kindly get your thoughts on the recent developments in this discussion? 😊 |
Adding support for this was explicitly avoided in the initial RFC for this feature. To me that means that adding support will likely entail a further RFC with rationale, detailed design, etc. |
@alexcrichton I didn't see any rationale given there, however. Is there? This seems to be a much in-demand feature... perhaps someone here (more qualified than me) could take up the task of writing an RFC though. |
@alex reading through that link your provided, it sounds to me that installation and uninstallation of data is considered to be only useful for deployments/distros and not devs. As a maintainer/developer of system D-Bus services (Geoclue and gps-share), I need to install (and sometimes also uninstall) files from the source/build directory to test changes etc. It would be very annoying for folks like myself to have to create custom scripts or rpm packages for just being able to install files. |
I think that installing to a # globs supported for all paths
# paths are relative to workspace root directory
[assets]
# defaults to ["man/*.[0-9]"]
# install to mandir
manpages = ["example.1"]
# assets.data defaults to []
# assets.data.FOO = { path = "BAR" } installs BAR to datadir/FOO
[assets.data."icon.png"]
path = "img/icon.png" |
My knowledge does not extend much beyond GNU, sorry. |
As a test, I fired up an Alpine Linux Docker image and ran
This doesn't actually seem to be the correct manpage for mandoc though. I checked online and found https://mandoc.bsd.lv/man/man.1.html which does state that So basically, POSIX does not include All that said, I'm still of the opinion that anyone running a |
For the record, I have a MANPATH on my Fedora machine that appears to have been refined by |
Personally I think that making any progress on this issue would be better than stalling because there is no perfect solution. If the idea to place manpages relative to
|
Nix also only sets |
I think this suggestion is reasonable: Rustup checks the environment for a Anyhow, sounds to me like we can try to move forward now if somebody wants to do the manpage patches to Cargo. Messing with Rustup can wait until later, if ever. |
Following XDG on linux and placing man pages under |
@vilgotf Point taken. However, given that Cargo is already placing executables in |
I think we shouldn't tie the two discussions together ((1) installing manpages and (2) supporting the XDG specification). It's already hard enough to make progress on (1) (this issue will soon celebrate its 6th birthday), and it does not make sense to use XDG_DATA_HOME/man with all other files going to I think the proper way to handle this is for interested people to push both discussions independently, without interfering with each other (after checking that doing one is not a fundamental blocker for the other), following the obvious "first merge wins" principle:
|
I will agree with @gasche above and say again: the perfect is the enemy of the good. I suggest a very simple initial solution that gets slowly improved beats a never completed perfect solution. Even if the initial mechanism is extremely imperfect, it can be improved with experience. |
Every project does things differently. For example, for
Whereas Typically the way that this would be handled on the distro package management side is that they generate the man pages via XYZ build steps and specify the manifest of files that are expected to be generated. For cargo the onus is obviously on the developer as they write the build scripts, I suspect that because everyone does things differently there will be situations where cargo will fail to properly install man pages. At this point though cargo is now just replicating the functionality that is already well handled by distro package managers, I suspect a more agnostic approach is to do what people have been doing for years with Makefiles and install assets to standard directories. Binaries go in I am +1 on not overcomplicating things and just doing |
As a drive-by summary, it seems like there are some under-explored opportunities to improve the situation, which do not require coordination from Cargo, and which are not blocked on anything:
cc @rotty, it seems that what you are doing with https://gitlab.com/rotty/cargo-parcel is basically this :-) The only thing missing is advertising the thing (eg, on this very issue), so that the community can run with the idea |
This simplifies the installation of necessary data files for the thumbnailer to work, working around this long-standing RFE: rust-lang/cargo#2729 Ideally, meson would also be used to compile the binary instead of Cargo, but meson doesn't easily support external crates: mesonbuild/meson#2173
Hi. I'm from KDE exploring the potential of using Rust for our apps. This sort of issue is a dealbreaker for GUI desktops apps on Linux. The inability to install arbitrary data files to specified XDG directories means desktop apps cannot install the following using standalone Cargo:
Just installing a binary is not enough.
Which is almost what we need, so I'd like to bump visibility for this project here. GNOME has worked around this issue for years by simply using Meson on top of Cargo to install files, and COSMIC has been using Just and reimplementing the needed XDG dirs + prefix logic for each project in their justfiles. I have no idea how the other Rust GUI toolkits have been managing this sort of thing. Whether we end up having support for installing files this way via Cargo or cargo-parcel, this functionality would surely help both KDE and COSMIC (GNOME would probably just keep doing their thing supporting and contributing to Meson). I just wanted to express why this sort of functionality is needed. As for how this is done on the distribution side of things on Linux, take a look at these examples from Arch (just because they're more easily introspectable):
Basically we need an install step that already follows the XDG basedir for our downstream packagers (preferably with variables to override behavior), otherwise we end up forcing them to use a lot of Edit: for crossreferencing, this is tangentially related to #1734. |
I use Cargo to build a command-line tool written in Rust. I've also written an accompanying manpage,
command.1
. I'd like to tell Cargo about manpages via Cargo.toml, so thatcargo install
will install them to the appropriate location (gzip-compressed and installed to${root}/share/man/man1/command.1.gz
, where the section1
inman1
gets extracted from the first character of the manpage extension).Note that once Cargo has a mechanism for a post-build script, some packages may wish to use that to build the manpage. For instance, a package might parse
--help
output to generate a manpage, process some other document language to produce a manpage, or use help2man-like functionality from an argument parser. However, for a first pass, I'd just like to have support for installing manpages already written directly in manpage format.The text was updated successfully, but these errors were encountered: