Repository: sharkdp/bat (language: rust)

Issue:
`bat` refuses to page content
<!--

Hey there, thank you for reporting a bug!

Please note that the following bugs have already been reported:

* dpkg: error processing archive /some/path/some-program.deb (--unpack):
  trying to overwrite '/usr/.crates2.json'

  See https://github.com/sharkdp/bat/issues/938

-->

**What steps will reproduce the bug?**

`bat some-long-test-file.txt --pager more --paging always`

**What happens?**

Contents of the file are dumped to the terminal all at once.

**What did you expect to happen instead?**

Paging with `more`.

**How did you install `bat`?**

<!-- apt-get, homebrew, GitHub release, etc. -->

Cargo.

---

**bat version and environment**

#### Software version

bat 0.23.0

#### Operating system

Windows 6.2.9200

#### Command-line

```bash
bat test.cmd --pager more --paging always --diagnostic
```

#### Environment variables

```bash
SHELL=<not set>
PAGER=<not set>
LESS=<not set>
LANG=<not set>
LC_ALL=<not set>
BAT_PAGER=more
BAT_CACHE_PATH=<not set>
BAT_CONFIG_PATH=<not set>
BAT_OPTS=<not set>
BAT_STYLE=<not set>
BAT_TABS=<not set>
BAT_THEME=<not set>
XDG_CONFIG_HOME=<not set>
XDG_CACHE_HOME=<not set>
COLORTERM=<not set>
NO_COLOR=<not set>
MANPAGER=<not set>
```

#### System Config file

Could not read contents of 'C:\ProgramData\bat\config': System nie może odnaleźć określonej ścieżki. (os error 3).

#### Config file

Could not read contents of 'C:\Users\Mataha\AppData\Roaming\bat\config': System nie może odnaleźć określonej ścieżki. (os error 3).

#### Custom assets metadata

Could not read contents of 'C:\Users\Mataha\AppData\Local\bat\metadata.yaml': System nie może odnaleźć określonej ścieżki. (os error 3).

#### Custom assets

'C:\Users\Mataha\AppData\Local\bat' not found

#### Compile time information

- Profile: release
- Target triple: x86_64-pc-windows-msvc
- Family: windows
- OS: windows
- Architecture: x86_64
- Pointer width: 64
- Endian: little
- CPU features: fxsr,sse,sse2
- Host: x86_64-pc-windows-msvc


<!--
In order to reproduce your issue, please add some information about the environment
in which you're running bat. To do this, run the full `bat` command that demonstrates
the bug, and attach the `--diagnostic` option:

    bat [other options and arguments…] --diagnostic

Finally, paste the Markdown output here. Please make sure that it does not reveal any
personal information.


If you are running bat 0.17.1 or older (where --diagnostic is not available), please
run the script at

    https://github.com/sharkdp/bat/blob/master/diagnostics/info.sh

(click "Raw" to get the actual source code) and paste the Markdown output here. If you
are on Windows, please let us know your bat version and your Windows version.
-->



Discussion / hints:
https://github.com/sharkdp/bat/issues/1666
> #1666

Not applicable; `--pager more` or `set BAT_PAGER=more` should force it as override happens only when a problematic pager comes from the `PAGER` environment variable: https://github.com/sharkdp/bat/blob/master/src/pager.rs#L109-L120
Could this be a duplicate of https://github.com/sharkdp/bat/issues/2572? (or the other way around)
I had the same thought - that turned to not be the case, sadly. I've tested the following:

  - 871abd27aa91264e01539da849add0330b24cb9c ([0.23.0](https://github.com/sharkdp/bat/releases/tag/v0.23.0))
  - b420c42affe8b3b14d103ad3f066e75fc78f3f95 (before #2572)
  - 149dec695376da3a74da10ee1201e1f50a245655 (after #2572)
> Windows 6.2.9200

this is Windows Server 2012, right? (https://www.gaijin.at/en/infos/windows-version-numbers)
what terminal emulation program are you using? Not sure what difference it would make, but I know later versions of Windows have whole new `conhost.exe`  and if you are able to try something different (even MSYS2 mintty) it could be helpful to rule stuff out.
Wow, that slipped past my attention - I didn't notice it at all. I'm on Windows 10 using `conhost.exe`:

```batchfile
$ ver
Microsoft Windows [Version 10.0.19044.2965]
```

...why does `bat` think it's Windows Server 2012? Maybe that's what I should investigate first? EDIT: that seems like [an unrelated issue](https://github.com/FillZpp/sys-info-rs/issues/86).
I've finally managed to track it down. It's... hilarious, to say the least. See BurntSushi/ripgrep#2523...

Fix patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3a0915d84c..51f27b9138 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,9 +4,12 @@
 
 ## Bugfixes
 
+- Fix `more` not being found on Windows when provided via `BAT_PAGER`, see #2570, #2580, and #2651 (@mataha)
+
 ## Other
 
 - Output directory for generated assets (completion, manual) can be customized, see #2515 (@tranzystorek-io)
+- Bump MSRV to 1.70, see #2651 (@mataha)
 
 ## Syntaxes
 
diff --git a/Cargo.lock b/Cargo.lock
index c506b811d2..ee318ab6b7 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -37,16 +37,15 @@ dependencies = [
 
 [[package]]
 name = "anstream"
-version = "0.3.2"
+version = "0.5.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0ca84f3628370c59db74ee214b3263d58f9aadd9b4fe7e711fd87dc452b7f163"
+checksum = "b1f58811cfac344940f1a400b6e6231ce35171f614f26439e80f8c1465c5cc0c"
 dependencies = [
  "anstyle 1.0.0",
  "anstyle-parse",
  "anstyle-query",
  "anstyle-wincon",
  "colorchoice",
- "is-terminal",
  "utf8parse",
 ]
 
@@ -82,9 +81,9 @@ dependencies = [
 
 [[package]]
 name = "anstyle-wincon"
-version = "1.0.1"
+version = "2.1.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "180abfa45703aebe0093f79badacc01b8fd4ea2e35118747e5811127f926e188"
+checksum = "58f54d10c6dfa51283a066ceab3ec1ab78d13fae00aa49243a45e4571fb79dfd"
 dependencies = [
  "anstyle 1.0.0",
  "windows-sys 0.48.0",
@@ -105,17 +104,6 @@ dependencies = [
  "wait-timeout",
 ]
 
-[[package]]
-name = "atty"
-version = "0.2.14"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
-dependencies = [
- "hermit-abi 0.1.19",
- "libc",
- "winapi",
-]
-
 [[package]]
 name = "autocfg"
 version = "1.1.0"
@@ -148,7 +136,6 @@ dependencies = [
  "git2",
  "globset",
  "grep-cli",
- "is-terminal",
  "nix",
  "nu-ansi-term",
  "once_cell",
@@ -202,12 +189,11 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
 
 [[package]]
 name = "bstr"
-version = "1.1.0"
+version = "1.6.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b45ea9b00a7b3f2988e9a65ad3917e62123c38dba709b666506207be96d1790b"
+checksum = "6798148dccfbff0fae41c7574d2fa8f1ef3492fba0face179de5d8d447d67b05"
 dependencies = [
  "memchr",
- "once_cell",
  "regex-automata",
  "serde",
 ]
@@ -252,22 +238,21 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
 
 [[package]]
 name = "clap"
-version = "4.3.0"
+version = "4.4.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "93aae7a4192245f70fe75dd9157fc7b4a5bf53e88d30bd4396f7d8f9284d5acc"
+checksum = "1d5f1946157a96594eb2d2c10eb7ad9a2b27518cb3000209dec700c35df9197d"
 dependencies = [
  "clap_builder",
 ]
 
 [[package]]
 name = "clap_builder"
-version = "4.3.0"
+version = "4.4.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4f423e341edefb78c9caba2d9c7f7687d0e72e89df3ce3394554754393ac3990"
+checksum = "78116e32a042dd73c2901f0dc30790d20ff3447f3e3472fad359e8c3d282bcd6"
 dependencies = [
  "anstream",
  "anstyle 1.0.0",
- "bitflags",
  "clap_lex",
  "once_cell",
  "strsim",
@@ -456,17 +441,6 @@ version = "0.1.4"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "a246d82be1c9d791c5dfde9a2bd045fc3cbba3fa2b11ad558f27d01712f00569"
 
-[[package]]
-name = "errno"
-version = "0.2.8"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f639046355ee4f37944e44f60642c6f3a7efa3cf6b78c78a0d989a8ce6c396a1"
-dependencies = [
- "errno-dragonfly",
- "libc",
- "winapi",
-]
-
 [[package]]
 name = "errno"
 version = "0.3.0"
@@ -618,11 +592,10 @@ dependencies = [
 
 [[package]]
 name = "grep-cli"
-version = "0.1.7"
+version = "0.1.9"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d19fc6687bc64b6719a839cd24f2c700bcb05ffeb684d19da6a637c2455a7ba1"
+checksum = "8fe4bdbf4300c8b039f5d7eec7fbc6760d2c85bb15ac7499c4d235667f6d747a"
 dependencies = [
- "atty",
  "bstr",
  "globset",
  "lazy_static",
@@ -639,21 +612,6 @@ version = "0.12.3"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
 
-[[package]]
-name = "hermit-abi"
-version = "0.1.19"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33"
-dependencies = [
- "libc",
-]
-
-[[package]]
-name = "hermit-abi"
-version = "0.3.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286"
-
 [[package]]
 name = "idna"
 version = "0.3.0"
@@ -693,18 +651,6 @@ dependencies = [
  "windows-sys 0.45.0",
 ]
 
-[[package]]
-name = "is-terminal"
-version = "0.4.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "21b6b32576413a8e69b90e952e4a026476040d81017b80445deda5f2d3921857"
-dependencies = [
- "hermit-abi 0.3.1",
- "io-lifetimes",
- "rustix 0.36.8",
- "windows-sys 0.45.0",
-]
-
 [[package]]
 name = "itertools"
 version = "0.10.5"
@@ -780,12 +726,6 @@ version = "0.5.6"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f"
 
-[[package]]
-name = "linux-raw-sys"
-version = "0.1.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f051f77a7c8e6957c0696eac88f26b0117e54f52d3fc682ab19397a8812846a4"
-
 [[package]]
 name = "linux-raw-sys"
 version = "0.3.1"
@@ -1063,9 +1003,9 @@ dependencies = [
 
 [[package]]
 name = "regex-automata"
-version = "0.1.10"
+version = "0.3.7"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132"
+checksum = "49530408a136e16e5b486e883fbb6ba058e8e4e8ae6621a77b048b314336e629"
 
 [[package]]
 name = "regex-syntax"
@@ -1088,20 +1028,6 @@ dependencies = [
  "bytemuck",
 ]
 
-[[package]]
-name = "rustix"
-version = "0.36.8"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f43abb88211988493c1abb44a70efa56ff0ce98f233b7b276146f1f3f7ba9644"
-dependencies = [
- "bitflags",
- "errno 0.2.8",
- "io-lifetimes",
- "libc",
- "linux-raw-sys 0.1.4",
- "windows-sys 0.45.0",
-]
-
 [[package]]
 name = "rustix"
 version = "0.37.3"
@@ -1109,10 +1035,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "62b24138615de35e32031d041a09032ef3487a616d901ca4db224e7d557efae2"
 dependencies = [
  "bitflags",
- "errno 0.3.0",
+ "errno",
  "io-lifetimes",
  "libc",
- "linux-raw-sys 0.3.1",
+ "linux-raw-sys",
  "windows-sys 0.45.0",
 ]
 
@@ -1316,7 +1242,7 @@ dependencies = [
  "cfg-if",
  "fastrand",
  "redox_syscall 0.3.5",
- "rustix 0.37.3",
+ "rustix",
  "windows-sys 0.45.0",
 ]
 
@@ -1335,7 +1261,7 @@ version = "0.2.6"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "8e6bf6f19e9f8ed8d4048dc22981458ebcf406d67e94cd422e5ecd73d63b3237"
 dependencies = [
- "rustix 0.37.3",
+ "rustix",
  "windows-sys 0.48.0",
 ]
 
diff --git a/Cargo.toml b/Cargo.toml
index 9a6692d516..bf3060a519 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -10,7 +10,7 @@ version = "0.23.0"
 exclude = ["assets/syntaxes/*", "assets/themes/*"]
 build = "build.rs"
 edition = '2018'
-rust-version = "1.64"
+rust-version = "1.70"
 
 [features]
 default = ["application"]
@@ -25,7 +25,6 @@ application = [
 # Mainly for developers that want to iterate quickly
 # Be aware that the included features might change in the future
 minimal-application = [
-    "is-terminal",
     "clap",
     "dirs",
     "paging",
@@ -41,7 +40,6 @@ regex-onig = ["syntect/regex-onig"] # Use the "oniguruma" regex engine
 regex-fancy = ["syntect/regex-fancy"] # Use the rust-only "fancy-regex" engine
 
 [dependencies]
-is-terminal = { version = "0.4.4", optional = true }
 nu-ansi-term = "0.47.0"
 ansi_colours = "^1.2"
 bincode = "1.0"
@@ -62,7 +60,7 @@ path_abs = { version = "0.5", default-features = false }
 clircle = "0.4"
 bugreport = { version = "0.5.0", optional = true }
 dirs = { version = "5.0.0", optional = true }
-grep-cli = { version = "0.1.7", optional = true }
+grep-cli = { version = "0.1.9", optional = true }
 regex = { version = "1.8.3", optional = true }
 walkdir = { version = "2.3", optional = true }
 bytesize = { version = "1.2.0" }
@@ -78,7 +76,7 @@ default-features = false
 features = ["parsing"]
 
 [dependencies.clap]
-version = "4.3.0"
+version = "4.4.0"
 optional = true
 features = ["wrap_help", "cargo"]
 
@@ -98,7 +96,7 @@ tempfile = "3.5.0"
 nix = { version = "0.26.2", default-features = false, features = ["term"] }
 
 [build-dependencies.clap]
-version = "4.1.8"
+version = "4.4.0"
 optional = true
 features = ["wrap_help", "cargo"]
 
diff --git a/README.md b/README.md
index 7ec806270a..9183f9f4f7 100644
--- a/README.md
+++ b/README.md
@@ -418,7 +418,7 @@ binaries are also available: look for archives with `musl` in the file name.
 
 ### From source
 
-If you want to build `bat` from source, you need Rust 1.64.0 or
+If you want to build `bat` from source, you need Rust 1.70.0 or
 higher. You can then use `cargo` to build everything:
 
 ```bash
diff --git a/doc/README-ja.md b/doc/README-ja.md
index 35a4e46907..74ee7585f9 100644
--- a/doc/README-ja.md
+++ b/doc/README-ja.md
@@ -366,7 +366,7 @@ ansible-galaxy install aeimer.install_bat
 ### From source
 
 
-`bat` をソースからビルドしたいならば、Rust 1.64.0 以上の環境が必要です。
+`bat` をソースからビルドしたいならば、Rust 1.70.0 以上の環境が必要です。
 `cargo` を使用してビルドすることができます:
 
 ```bash
diff --git a/doc/README-ko.md b/doc/README-ko.md
index 50f1ae04e8..eeb9725c9c 100644
--- a/doc/README-ko.md
+++ b/doc/README-ko.md
@@ -416,7 +416,7 @@ scoop install bat
 
 ### 소스에서
 
-`bat`의 소스를 빌드하기 위해서는, Rust 1.64.0 이상이 필요합니다.
+`bat`의 소스를 빌드하기 위해서는, Rust 1.70.0 이상이 필요합니다.
 `cargo`를 이용해 전부 빌드할 수 있습니다:
 
 ```bash
diff --git a/doc/README-ru.md b/doc/README-ru.md
index 4adb73b331..9536887e2f 100644
--- a/doc/README-ru.md
+++ b/doc/README-ru.md
@@ -344,7 +344,7 @@ ansible-galaxy install aeimer.install_bat
 
 ### Из исходников
 
-Если вы желаете установить `bat` из исходников, вам понадобится Rust 1.64.0 или выше. После этого используйте `cargo`, чтобы все скомпилировать:
+Если вы желаете установить `bat` из исходников, вам понадобится Rust 1.70.0 или выше. После этого используйте `cargo`, чтобы все скомпилировать:
 
 ```bash
 cargo install --locked bat
diff --git a/doc/README-zh.md b/doc/README-zh.md
index e37d115d1c..06d2570c3a 100644
--- a/doc/README-zh.md
+++ b/doc/README-zh.md
@@ -372,7 +372,7 @@ scoop install bat
 
 ### 从源码编译
 
-如果你想要自己构建`bat`，那么你需要安装有高于1.64.0版本的 Rust。
+如果你想要自己构建`bat`，那么你需要安装有高于1.70.0版本的 Rust。
 
 使用以下命令编译。
 
diff --git a/src/bin/bat/app.rs b/src/bin/bat/app.rs
index fc84e2a3f2..c208b14f21 100644
--- a/src/bin/bat/app.rs
+++ b/src/bin/bat/app.rs
@@ -1,9 +1,8 @@
 use std::collections::HashSet;
 use std::env;
+use std::io::IsTerminal;
 use std::path::{Path, PathBuf};
 
-use is_terminal::IsTerminal;
-
 use crate::{
     clap_app,
     config::{get_args_from_config_file, get_args_from_env_opts_var, get_args_from_env_vars},


Test patch: