termux-packages icon indicating copy to clipboard operation
termux-packages copied to clipboard

[Bug]: `tcdrain failed` when using the `streampager`

Open ErichDonGubler opened this issue 1 month ago • 7 comments

Problem description

streampager is a neat little pager project written in Rust that is particularly useful for paging large files. I like it, because it's cross-platform, even usable on Windows! It's also the default pager shipped with Jujutsu since jj's 0.26.0 release. That's what caused me to discover this issue in the first place.

I'm not sure if this is a problem with sp's support for Termux, the way the jj's package's binaries are built, the termwiz library in the crash that gets generated, or if this is actually an environmental problem with Termux itself. I suspect this is a termwiz issue, but I'm filing this issue here, since it definitely affects users of this package.

What steps will reproduce the bug?

  1. Use cargo binstall jj-cli to install jj v0.26.0 or later.

  2. Ensure that jj will use streampager for subsequent steps by clearing the pager TOML field, if set.

  3. Run a command that uses paging, i.e., jj log -r 'all()'. Observe that an error like the following is emitted:

    thread '<unnamed>' panicked at /data/data/com.termux/files/home/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/termwiz-0.23.3/src/terminal/unix.rs:539:28:
     Custom { kind: Other, error: "tcdrain failed" }
    note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
    Warning: builtin pager crashed.
    

What is the expected behavior?

jj should be able to jj log, etc. and page output without any issues.

System information

Termux Variables:
TERMUX_APP_PACKAGE_MANAGER=apt
TERMUX_APP__APK_FILE=/data/app/~~fKWK5CdDkDlB628FR3nBEA==/com.termux-FRon2QT5is1ZY8BPn7Ny4w==/base.apk
TERMUX_APP__APK_RELEASE=F_DROID
TERMUX_APP__APP_VERSION_CODE=1022
TERMUX_APP__APP_VERSION_NAME=0.119.0-beta.3
TERMUX_APP__DATA_DIR=/data/user/0/com.termux
TERMUX_APP__IS_DEBUGGABLE_BUILD=false
TERMUX_APP__IS_INSTALLED_ON_EXTERNAL_STORAGE=false
TERMUX_APP__LEGACY_DATA_DIR=/data/data/com.termux
TERMUX_APP__PACKAGE_NAME=com.termux
TERMUX_APP__PID=30464
TERMUX_APP__SE_FILE_CONTEXT=u:object_r:app_data_file:s0:c243,c257,c512,c768
TERMUX_APP__SE_INFO=default:targetSdkVersion=28:complete
TERMUX_APP__TARGET_SDK=28
TERMUX_VERSION=0.119.0-beta.3
TERMUX__APPS_DIR=/data/user/0/com.termux/termux/apps
TERMUX__HOME=/data/data/com.termux/files/home
TERMUX__PREFIX=/data/data/com.termux/files/usr
TERMUX__ROOTFS_DIR=/data/data/com.termux/files
TERMUX__SE_PROCESS_CONTEXT=u:r:untrusted_app_27:s0:c243,c257,c512,c768
TERMUX__UID=10499
TERMUX__USER_ID=0
Packages CPU architecture:
aarch64
Subscribed repositories:
# sources.list
deb https://packages-cf.termux.dev/apt/termux-main stable main
Updatable packages:
gh/stable 2.83.1 aarch64 [upgradable from: 2.83.0]
libluajit/stable 1:2.1.1762795099 aarch64 [upgradable from: 1:2.1.1762617240]
nano/stable 8.7 aarch64 [upgradable from: 8.6-1]
readline/stable 8.3.1-2 aarch64 [upgradable from: 8.3.1-1]
rust-std-aarch64-linux-android/stable 1.91.1 all [upgradable from: 1.91.0]
rust/stable 1.91.1 aarch64 [upgradable from: 1.91.0]
utf8proc/stable 2.11.1 aarch64 [upgradable from: 2.11.0]
termux-tools version:
1.45.0
Android version:
15
Kernel build information:
Linux localhost 5.10.226-android12-9-30958166-abS908U1UES8FYI2 #1 SMP PREEMPT Thu Sep 4 04:08:49 UTC 2025 aarch64 Android
Device manufacturer:
samsung
Device model:
SM-S908U1
Supported ABIs:
SUPPORTED_ABIS: arm64-v8a,armeabi-v7a,armeabi
SUPPORTED_32_BIT_ABIS: armeabi-v7a,armeabi
SUPPORTED_64_BIT_ABIS: arm64-v8a
LD Variables:
LD_LIBRARY_PATH=
LD_PRELOAD=/data/data/com.termux/files/usr/lib/libtermux-exec-ld-preload.so
Installed termux plugins:
com.termux.tasker versionCode:1002
com.termux.api versionCode:1002
com.termux.styling versionCode:1000

ErichDonGubler avatar Nov 14 '25 16:11 ErichDonGubler

We don't have a package for jujutsu in this repository. This should probably be transferred to the TUR.

TomJo2000 avatar Nov 14 '25 16:11 TomJo2000

Correct,

  • also the TUR package for jujutsu is pkg install jujutsu not pkg install jj
  • also it is currently version 0.29 not 0.26
  • also when I use LD_LIBRARY_PATH=$PREFIX/lib jj log -r 'all()' (it currently has a different bug that prevents using it without setting LD_LIBRARY_PATH), it appears to work without showing tcdrain failed

If it's not inconvenient for you, could you provide a script that can reproduce your error in clean installed Termux?

robertkirkman avatar Nov 14 '25 16:11 robertkirkman

@ErichDonGubler could you try the artifacts from this PR when it finishes and let me know if that fixes the problem for you?

  • https://github.com/termux-user-repository/tur/pull/2053

robertkirkman avatar Nov 15 '25 17:11 robertkirkman

We don't have a package for jujutsu in this repository. This should probably be transferred to the TUR.

Ah, yes, I'd forgotten that I'd installed the jj-cli Rust crate via cargo binstall. I've updated the OP to indicate such, sorry about the noise.

ErichDonGubler avatar Dec 03 '25 14:12 ErichDonGubler

@robertkirkman: Just pkg install tur-repo && pkg install jujutsu, which installs jj 0.35.0 (so I'm pretty sure that PR is consumed). I can still reproduce this issue with that binary.

ErichDonGubler avatar Dec 03 '25 14:12 ErichDonGubler

@ErichDonGubler I'm sorry, I wasn't able to reproduce the original issue, so I am not sure how to fix it yet,

do you think you might be able to write a more detailed script that I could run which would automatically reproduce the problem on any clean-installed Termux, assuming there aren't differences between devices external to the Termux App influencing the problem?

robertkirkman avatar Dec 04 '25 00:12 robertkirkman

I cannot reproduce on Samsung Galaxy S9 (Android 10), Samsung Galaxy A70 (Android 13), or Samsung Galaxy S8+ (Android 14),

Where would the "pager TOML field" you mentioned be, if present? I have been looking in .jj/repo/config.toml this whole time and I've never seen it.

robertkirkman avatar Dec 04 '25 00:12 robertkirkman