termux / termux-float

Termux add-on app to show the terminal in a floating terminal window.
https://f-droid.org/en/packages/com.termux.window
Other
465 stars 77 forks source link

Fish shell behaves incorrectly in Termux:Float #31

Closed ghost closed 3 years ago

ghost commented 3 years ago

Problem description When i use Termux:Float, it gives fish errors regarding with in command substitution, but in Termux app, fish works fine,

and i couldn't run any commands in termux:float when using fish, it just gives errors when i type any command (except exit)

Screenshot_2021-04-10-11-29-40-47.jpg

Steps to reproduce

  1. Install fish and use fish as a default shell

  2. Open Termux:Float app

  3. It should give strange errors about command substitution

Expected behavior Fish should work fine without issues

Additional information

Grimler91 commented 3 years ago

Error seem to be in the theme you are using, have you tried without it? Fish (without any customisation) works find in termux-float on my device.

I suppose there is some env difference between when you are running in termux-app and termux-float that causes the error. Could you post the full error?

ghost commented 3 years ago

seem to be in the theme you are using, have you tried without it?

Error still persists, although i installed oh-my-fish for my fish setup, not sure if that caused this kind of error

Could you post the full error?

Welcome to fish, the friendly interactive shell
Type help for instructions on how to use fish
The program id is not installed. Install it by executing:
 pkg install coreutils
~/.local/share/omf/themes/chain/functions/chain.links.root.fish (line 1):
id -u $USER
^
in command substitution
        called on line 5 of file ~/.local/share/omf/themes/chain/functions/chain.links.root.fish
in function 'chain.links.root'
        called on line 1 of file -
in command substitution
        called on line 4 of file -
in function '__chain_compiled_prompt'
        called on line 1 of file ~/.local/share/omf/themes/chain/functions/fish_prompt.fish
in command substitution
        called on line 21 of file ~/.local/share/omf/themes/chain/functions/fish_prompt.fish
in function 'fish_prompt'
in command substitution
~/.local/share/omf/themes/chain/functions/chain.links.root.fish (line 5): Unknown error while evaluating command substitution
  if test (id -u $USER) -eq 0
          ^
in function 'chain.links.root'
        called on line 1 of file -
in command substitution
        called on line 4 of file -
in function '__chain_compiled_prompt'
        called on line 1 of file ~/.local/share/omf/themes/chain/functions/fish_prompt.fish
in command substitution
        called on line 21 of file ~/.local/share/omf/themes/chain/functions/fish_prompt.fish
in function 'fish_prompt'
in command substitution
The program uname is not installed. Install it by executing:
 pkg install coreutils
/data/data/com.termux/files/usr/share/fish/functions/__fish_pwd.fish (line 1):
uname
^
in command substitution
        called on line 1 of file /data/data/com.termux/files/usr/share/fish/functions/__fish_pwd.fish
from sourcing file /data/data/com.termux/files/usr/share/fish/functions/__fish_pwd.fish
        called on line 1 of file /data/data/com.termux/files/usr/share/fish/functions/fish_title.fish
in command substitution
        called on line 1 of file /data/data/com.termux/files/usr/share/fish/functions/fish_title.fish
in command substitution
        called on line 6 of file /data/data/com.termux/files/usr/share/fish/functions/fish_title.fish
in function 'fish_title'
in command substitution
/data/data/com.termux/files/usr/share/fish/functions/__fish_pwd.fish (line 1): Unknown error while evaluating command substitution
switch (uname)
       ^
from sourcing file /data/data/com.termux/files/usr/share/fish/functions/__fish_pwd.fish
        called on line 1 of file /data/data/com.termux/files/usr/share/fish/functions/fish_title.fish
in command substitution
        called on line 1 of file /data/data/com.termux/files/usr/share/fish/functions/fish_title.fish
in command substitution
        called on line 6 of file /data/data/com.termux/files/usr/share/fish/functions/fish_title.fish
in function 'fish_title'
in command substitution
__fish_pwd: command not found
/data/data/com.termux/files/usr/share/fish/functions/fish_title.fish (line 1):
__fish_pwd
^
in command substitution
        called on line 6 of file /data/data/com.termux/files/usr/share/fish/functions/fish_title.fish
in function 'fish_title'
in command substitution
/data/data/com.termux/files/usr/share/fish/functions/fish_title.fish (line 6): Unknown error while evaluating command substitution
        echo (set -q argv[1] && echo $argv[1] || status current-command) (__fish_pwd)
                                                                         ^
in function 'fish_title'
in command substitution
<~>-> The program id is not installed. Install it by executing:
 pkg install coreutils
~/.local/share/omf/themes/chain/functions/chain.links.root.fish (line 1):
id -u $USER
^
in command substitution
        called on line 5 of file ~/.local/share/omf/themes/chain/functions/chain.links.root.fish
in function 'chain.links.root'
        called on line 1 of file -
in command substitution
        called on line 4 of file -
in function '__chain_compiled_prompt'
        called on line 1 of file ~/.local/share/omf/themes/chain/functions/fish_prompt.fish
in command substitution
        called on line 21 of file ~/.local/share/omf/themes/chain/functions/fish_prompt.fish
in function 'fish_prompt'
in command substitution
~/.local/share/omf/themes/chain/functions/chain.links.root.fish (line 5): Unknown error while evaluating command substitution
  if test (id -u $USER) -eq 0
          ^
in function 'chain.links.root'
        called on line 1 of file -
in command substitution
        called on line 4 of file -
in function '__chain_compiled_prompt'
        called on line 1 of file ~/.local/share/omf/themes/chain/functions/fish_prompt.fish
in command substitution
        called on line 21 of file ~/.local/share/omf/themes/chain/functions/fish_prompt.fish
in function 'fish_prompt'
in command substitution
__fish_pwd: command not found
/data/data/com.termux/files/usr/share/fish/functions/fish_title.fish (line 1):
__fish_pwd
^
in command substitution
        called on line 6 of file /data/data/com.termux/files/usr/share/fish/functions/fish_title.fish
in function 'fish_title'
in command substitution
/data/data/com.termux/files/usr/share/fish/functions/fish_title.fish (line 6): Unknown error while evaluating command substitution
        echo (set -q argv[1] && echo $argv[1] || status current-command) (__fish_pwd)
                                                                         ^
in function 'fish_title'
in command substitution

Sorry if it's too long

Grimler91 commented 3 years ago

The error starts in your oh-my-fish directory (~/.local/share/omf), so I suspect fish will work in termux-float without it (please try)

Here's a pretty similar error in the fish repo: https://github.com/fish-shell/fish-shell/issues/2806

ghost commented 3 years ago

The error starts in your oh-my-fish directory (~/.local/share/omf), so I suspect fish will work in termux-float without it (please try)

removed omf, and now it prints errors regarding fish_title

source: Error encountered while sourcing file '/data/data/com.termux/files/home/.local/share/omf/init.fish':
source: No such file or directory
  ;,           ,;      u0_a933@localhost
   ';,.-----.,;'       os     Android 10
  ,'           ',      host   aarch64
 /    O     O    \     kernel 4.14.117-perf+
|                 |    uptime 0m
'-----------------'    pkgs   370
                       memory 2145M / 3641M

Welcome to fish, the friendly interactive shell
Type help for instructions on how to use fish
The program uname is not installed. Install it by executing:
 pkg install coreutils
/data/data/com.termux/files/usr/share/fish/functions/__fish_pwd.fish (line 1):
uname
^
in command substitution
        called on line 1 of file /data/data/com.termux/files/usr/share/fish/functions/__fish_pwd.fish
from sourcing file /data/data/com.termux/files/usr/share/fish/functions/__fish_pwd.fish
        called on line 1 of file /data/data/com.termux/files/usr/share/fish/functions/fish_title.fish
in command substitution
        called on line 1 of file /data/data/com.termux/files/usr/share/fish/functions/fish_title.fish
in command substitution
        called on line 6 of file /data/data/com.termux/files/usr/share/fish/functions/fish_title.fish
in function 'fish_title'
in command substitution
/data/data/com.termux/files/usr/share/fish/functions/__fish_pwd.fish (line 1): Unknown error while evaluating command substitution
switch (uname)
       ^
from sourcing file /data/data/com.termux/files/usr/share/fish/functions/__fish_pwd.fish
        called on line 1 of file /data/data/com.termux/files/usr/share/fish/functions/fish_title.fish
in command substitution
        called on line 1 of file /data/data/com.termux/files/usr/share/fish/functions/fish_title.fish
in command substitution
        called on line 6 of file /data/data/com.termux/files/usr/share/fish/functions/fish_title.fish
in function 'fish_title'
in command substitution
__fish_pwd: command not found
/data/data/com.termux/files/usr/share/fish/functions/fish_title.fish (line 1):
__fish_pwd
^
in command substitution
        called on line 6 of file /data/data/com.termux/files/usr/share/fish/functions/fish_title.fish
in function 'fish_title'
in command substitution
/data/data/com.termux/files/usr/share/fish/functions/fish_title.fish (line 6): Unknown error while evaluating command substitution
        echo (set -q argv[1] && echo $argv[1] || status current-command) (__fish_pwd)
                                                                         ^
in function 'fish_title'
in command substitution
Grimler91 commented 3 years ago

source: Error encountered while sourcing file '/data/data/com.termux/files/home/.local/share/omf/init.fish':

Seem to still be using it. In any case, looks like PATH is not set correctly for some reason (since it cannot even execute uname)

ghost commented 3 years ago

Now fish works without oh-my-fish

Screenshot_2021-04-10-14-22-51-95.jpg

Grimler91 commented 3 years ago

What environmental variables are set in termux-float and in termux-app, when not using omf?

ghost commented 3 years ago

env output in Termux App (fish, without omf)

PWD=/data/data/com.termux/files/home/EMPTY_HOME
LOGDIR=/data/data/com.termux/files/usr/var/log
ANDROID_TZDATA_ROOT=/apex/com.android.tzdata
PREFIX=/data/data/com.termux/files/usr
PATH=/data/data/com.termux/files/usr/bin
SHLVL=2
LD_PRELOAD=/data/data/com.termux/files/usr/lib/libtermux-exec.so
DEX2OATBOOTCLASSPATH=/apex/com.android.runtime/javalib/core-oj.jar:/apex/com.android.runtime/javalib/core-libart.jar:/apex/com.android.runtime/javalib/okhttp.jar:/apex/com.android.runtime/javalib/bouncycastle.jar:/apex/com.android.runtime/javalib/apache-xml.jar:/system/framework/framework.jar:/system/framework/ext.jar:/system/framework/telephony-common.jar:/system/framework/voip-common.jar:/system/framework/ims-common.jar:/system/framework/android.test.base.jar:/system/framework/oppo-framework.jar:/system/framework/coloros-framework.jar:/system/framework/coloros-support-wrapper.jar:/system/framework/ifaamanager.jar:/system/framework/tcmiface.jar:/system/framework/telephony-ext.jar:/system/framework/qcom.fmradio.jar:/system/framework/com.nxp.nfc.nq.jar:/system/framework/QPerformance.jar:/system/framework/UxPerformance.jar:/system/framework/WfdCommon.jar
COLORTERM=truecolor
TMPDIR=/data/data/com.termux/files/usr/tmp
TERM=xterm-256color
EXTERNAL_STORAGE=/sdcard
LANG=en_US.UTF-8
BOOTCLASSPATH=/apex/com.android.runtime/javalib/core-oj.jar:/apex/com.android.runtime/javalib/core-libart.jar:/apex/com.android.runtime/javalib/okhttp.jar:/apex/com.android.runtime/javalib/bouncycastle.jar:/apex/com.android.runtime/javalib/apache-xml.jar:/system/framework/framework.jar:/system/framework/ext.jar:/system/framework/telephony-common.jar:/system/framework/voip-common.jar:/system/framework/ims-common.jar:/system/framework/android.test.base.jar:/system/framework/oppo-framework.jar:/system/framework/coloros-framework.jar:/system/framework/coloros-support-wrapper.jar:/system/framework/ifaamanager.jar:/system/framework/tcmiface.jar:/system/framework/telephony-ext.jar:/system/framework/qcom.fmradio.jar:/system/framework/com.nxp.nfc.nq.jar:/system/framework/QPerformance.jar:/system/framework/UxPerformance.jar:/system/framework/WfdCommon.jar:/apex/com.android.conscrypt/javalib/conscrypt.jar:/apex/com.android.media/javalib/updatable-media.jar
OLDPWD=/data/data/com.termux/files/home
SVDIR=/data/data/com.termux/files/usr/var/service
ANDROID_ROOT=/system
HISTCONTROL=ignoreboth
HOME=EMPTY_HOME/
TERMUX_VERSION=0.108
SHELL=/data/data/com.termux/files/usr/bin/bash
ANDROID_RUNTIME_ROOT=/apex/com.android.runtime
ANDROID_DATA=/data
USER=u0_a933

env output in Termux:Float (fish, without omf)

PWD=/data/data/com.termux/files/home/EMPTY_HOME
LD_PRELOAD=/data/data/com.termux/files/usr/lib/libtermux-exec.so
TERM=xterm-256color
LD_LIBRARY_PATH=/data/data/com.termux/files/usr/lib
PATH=/data/data/com.termux/files/usr/bin:/data/data/com.termux/files/usr/bin/applets
LOGNAME=u0_a933
LANG=en_US.UTF-8
OLDPWD=/data/data/com.termux/files/home
LOGDIR=/data/data/com.termux/files/usr/var/log
SSH_TTY=/dev/pts/2
SVDIR=/data/data/com.termux/files/usr/var/service
EXTERNAL_STORAGE=/sdcard
SSH_CONNECTION=127.0.0.1 42402 127.0.0.1 8022
USER=u0_a933
ANDROID_ROOT=/system
SSH_CLIENT=127.0.0.1 42402 8022
HOME=EMPTY_HOME/
HISTCONTROL=ignoreboth
PREFIX=/data/data/com.termux/files/usr
SHLVL=2
SHELL=/data/data/com.termux/files/usr/bin/bash
ANDROID_DATA=/data
TMPDIR=/data/data/com.termux/files/usr/tmp

P.S. I was using ssh to establish termux:float connection for copy-pasting,

Grimler91 commented 3 years ago

LD_LIBRARY_PATH is the only variable that stands out to me (termux-float needs some clean up). Try unsetting that first thing you do in your init.fish file and see if it fixes the issue when running with omf

ghost commented 3 years ago

Even with unsetting the LD_LIBRARY_PATH and i still get some errors with omf,

Screenshot_2021-04-10-16-53-13-07.jpg

Grimler91 commented 3 years ago

What does the omf init.fish file contain? For some reason PATH seem to be messed up when fish loads your omf. Since it works without those customization there must be something weird going on there, that termux-float does not like.

ghost commented 3 years ago

The omf file contains: (mostly default generated by omf)

# Set OMF_CONFIG if not set.
if not set -q OMF_CONFIG
  set -q XDG_CONFIG_HOME; or set -l XDG_CONFIG_HOME "$HOME/.config"
  set -gx OMF_CONFIG "$XDG_CONFIG_HOME/omf"
end
# Source custom before.init.fish file
test -f $OMF_CONFIG/before.init.fish
  and source $OMF_CONFIG/before.init.fish 2> /dev/null
emit perf:timer:start "Oh My Fish initialisation"
# Read current theme
test -f $OMF_CONFIG/theme
  and read -l theme < $OMF_CONFIG/theme
  or set -l theme default
# Prepare Oh My Fish paths
set -l core_function_path $OMF_PATH/lib{,/git}
set -l theme_function_path {$OMF_CONFIG,$OMF_PATH}/themes*/$theme{,/functions}
# Autoload core library
set fish_function_path $fish_function_path[1] \
                       $core_function_path \
                       $theme_function_path \
                       $fish_function_path[2..-1]
# Require all packages
emit perf:timer:start "Oh My Fish init installed packages"
require --path {$OMF_PATH,$OMF_CONFIG}/pkg/*
emit perf:timer:finish "Oh My Fish init installed packages"
# Backup key bindings
functions -q fish_user_key_bindings
  and not functions -q __original_fish_user_key_bindings
  and functions -c fish_user_key_bindings __original_fish_user_key_bindings
# Override key bindings, calling original if existent
function fish_user_key_bindings
  test -f $OMF_CONFIG/theme
    and read -l theme < $OMF_CONFIG/theme
    or set -l theme default
  test -e $OMF_CONFIG/key_bindings.fish;
    and source $OMF_CONFIG/key_bindings.fish
  # Prepare packages key bindings paths
  set -l key_bindings {$OMF_CONFIG,$OMF_PATH}/pkg/*/key_bindings.fish \
                      {$OMF_CONFIG,$OMF_PATH}/themes*/$theme/key_bindings.fish
  # Source all keybindings collected
  for file in $key_bindings
    source $file
  end
  # Call original key bindings if existent
  functions -q __original_fish_user_key_bindings
    and __original_fish_user_key_bindings
end
emit perf:timer:start "Oh My Fish init user config path"
require --no-bundle --path $OMF_CONFIG
emit perf:timer:finish "Oh My Fish init user config path"
# Load conf.d for current theme if exists
set -l theme_conf_path {$OMF_CONFIG,$OMF_PATH}/themes*/$theme/conf.d
for conf in $theme_conf_path/*.fish
  source $conf
end
emit perf:timer:finish "Oh My Fish initialisation"
ghost commented 3 years ago

I was able to fix it by setting up the PATH variable

here's the command

/system/bin/sh

$PREFIX/bin/bash

export PATH=$PREFIX/bin

fish

Screenshot_2021-04-12-18-33-42-99.jpg

Well, i had fixed it now by filling this file in $HOME/.termux/shell

#!/data/data/com.termux/files/usr/bin/bash
exec env PATH=$PREFIX/bin fish "$@"

thanks for the help,