meh / rust-terminfo

Terminal information for Rust.
Other
40 stars 15 forks source link

Does not Work in Termux #11

Closed mitnk closed 4 years ago

mitnk commented 5 years ago

Hello,

Termux has ncurses (use command pkg search ncurses) packages. But rust-terminfo does not work on it. I tried with the simple example binary.

$ RUST_BACKTRACE=1 ./simple
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: NotFound', src/libcore/result.rs:999:5
stack backtrace:
   0: <unknown>
   1: <unknown>
   2: <unknown>
   3: <unknown>
   4: <unknown>
   5: <unknown>
   6: <unknown>
   7: <unknown>
   8: <unknown>
   9: <unknown>
  10: <unknown>
  11: <unknown>
  12: <unknown>
  13: <unknown>
  14: <unknown>
  15: <unknown>
  16: main
  17: __libc_init
  18: <unknown>

Possible solution?

meh commented 5 years ago

Any chance I could get a real stack trace? :panda_face:

mitnk commented 5 years ago

Seems caused by non standard FHS.

https://wiki.termux.com/wiki/Differences_from_Linux

Let me dig more on it.

mitnk commented 5 years ago

Found that in Termux, which is not following FHS, has

$ env
SHELL=/data/data/com.termux/files/usr/bin/bash
PREFIX=/data/data/com.termux/files/usr
PWD=/data/data/com.termux/files/home
LOGNAME=u0_a301
EXTERNAL_STORAGE=/sdcard
LD_PRELOAD=/data/data/com.termux/files/usr/lib/libtermux-exec.so
HOME=/data/data/com.termux/files/home
LANG=en_US.UTF-8
TMPDIR=/data/data/com.termux/files/usr/tmp
ANDROID_DATA=/data
TERM=xterm-256color
USER=u0_a301
SHLVL=1
ANDROID_ROOT=/system
PATH=/data/data/com.termux/files/usr/bin:/data/data/com.termux/files/usr/bin/applets
SSH_TTY=/dev/pts/2

And I found db file xterm-256color located at:

/data/data/com.termux/files/usr/share/terminfo/x/xterm-256color

So this solution works for me: Add "${PREFIX}/share/terminfo" (i.e. "/data/data/com.termux/files/usr/share/terminfo") into search path list @ src/database.rs#L177.

meh commented 5 years ago

That seems reasonable, do you want to write a pull request or should I do it?

mitnk commented 5 years ago

PR created.