From 10ac98e2eacfb44135653a6b95aefcf132d7dd8e Mon Sep 17 00:00:00 2001 From: Fabian Boehm Date: Sat, 14 Dec 2024 20:23:52 +0100 Subject: [PATCH] installable: Only panic without sphinx if FISH_BUILD_DOCS=1 It's pretty annoying that this panics without sphinx, because the install itself would be *working*. So instead we tell the user that they need to clean or set $FISH_BUILD_DOCS if they want to try again. --- README.rst | 8 +++++--- build.rs | 6 +++++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/README.rst b/README.rst index 5fc9bfe9a..9e115010e 100644 --- a/README.rst +++ b/README.rst @@ -185,11 +185,13 @@ This will place the binaries in ``~/.cargo/bin/``, but you can place them wherev This build won't have the HTML docs (``help`` will open the online version) or translations. -It requires sphinx by default, if sphinx-build is not available you can build without man pages by running it with $FISH_BUILD_DOCS set to 0:: +It will try to build the man pages with sphinx-build. If that is not available and you would like to include man pages, you need to install it and retrigger the build script, e.g. by setting FISH_BUILD_DOCS=1:: - FISH_BUILD_DOCS=0 cargo install --path . + FISH_BUILD_DOCS=1 cargo install --path . -You can also link it statically (but not against glibc) and move it to other computers. +Setting it to "0" disables the inclusion of man pages. + +You can also link this build statically (but not against glibc) and move it to other computers. Contributing Changes to the Code -------------------------------- diff --git a/build.rs b/build.rs index 5422f39b3..04da46d50 100644 --- a/build.rs +++ b/build.rs @@ -378,7 +378,11 @@ fn build_man(build_dir: &Path) { // which is unfortunate - but the docs are pretty important because they're also used for --help. match Command::new("sphinx-build").args(args).spawn() { Err(x) if x.kind() == std::io::ErrorKind::NotFound => { - panic!("Could not find sphinx-build to build man pages.\nInstall sphinx or disable building the docs by setting $FISH_BUILD_DOCS=0."); + if env::var("FISH_BUILD_DOCS") == Ok("1".to_string()) { + panic!("Could not find sphinx-build to build man pages.\nInstall sphinx or disable building the docs by setting $FISH_BUILD_DOCS=0."); + } + println!("cargo:warning=Cannot find sphinx-build to build man pages."); + println!("cargo:warning=If you install it now you need to run `cargo clean` and rebuild, or set $FISH_BUILD_DOCS=1 explicitly."); } Err(x) => { // Another error - permissions wrong etc