xxh / xxh-shell-xonsh

Use xonsh wherever you go through the SSH without installation on the host.
BSD 2-Clause "Simplified" License
46 stars 8 forks source link

Ubuntu1404: ModuleNotFoundError: No module named 'math' #19

Closed spothound closed 3 years ago

spothound commented 3 years ago

Local OS (where xxh is installed): Arch linux Destination host OS: Ubuntu1404 xxh version: xxh/0.8.6 xxh-plugins installed: xxh-shell-xonsh

Steps to Reproduce

  1. bring up the machine with the following Vagrantfile
    directory=$(mktemp -d)
    cd $directory
    wget https://gist.githubusercontent.com/grg121/4c5b060fab2f1de83043f2d69cf419bb/raw/1f5cffc6f2336ec753729493dd2efbf7906a172d/gistfile1.txt -O Vagrantfile
    vagrant up ub1404
    xxh +if +s xonsh vagrant@192.168.56.69
  2. The output log:
    ❯ xxh +if +s xonsh vagrant@192.168.56.69
    vagrant@192.168.56.69's password: 
    Install xxh-shell-xonsh to 192.168.56.69:/home/vagrant/.xxh
    Remove 192.168.56.69:/home/vagrant/.xxh/.xxh
    First time upload using rsync (this will be omitted on the next connections)
    First run xxh-shell-xonsh on 192.168.56.69
    Traceback (most recent call last):
    File "/home/vagrant/.xxh/.xxh/shells/xxh-shell-xonsh/build/xonsh", line 6, in <module>
    from xonsh.main import main
    File "/home/vagrant/.xxh/.xxh/shells/xxh-shell-xonsh/build/xonsh-squashfs/opt/python3.8/lib/python3.8/site-packages/xonsh/main.py", line 13, in <module>
    from xonsh.timings import setup_timings
    File "/home/vagrant/.xxh/.xxh/shells/xxh-shell-xonsh/build/xonsh-squashfs/opt/python3.8/lib/python3.8/site-packages/xonsh/timings.py", line 13, in <module>
    import math
    ModuleNotFoundError: No module named 'math'
  3. What is the problem

Hello there, I'm facing an issue with xxh which I could not understand. I'm trying to connect to different hosts running in virtual machines using vagrant. One with ubuntu14 and the other with centos7. While the second one works as expected, the ubuntu gives me the described problem.

I don't understand why python is complaining about math module, the Xonsh appimage is supposed to use his own Python3.8 with all the required modules, isn't it? Then, why it doesn't find math? Maybe I am not understanding something here.

I've tried downloading the app image from Xonsh manually and it runs good, so I think there must be a problem with the build script or something, nevertheless I don't understand why Xonsh is trying to look for math package without sucess.

What is more, if I run:

vagrant@metasploitable3-ub1404:~$ which python
/usr/bin/python
vagrant@metasploitable3-ub1404:~$ /usr/bin/python
Python 2.7.6 (default, Nov 23 2017, 15:49:48) 
[GCC 4.8.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import math

It seems that the default system python does have math module installed. So the problem must be with the one used by Xonsh.

I'm trying to find the cause and open this issue to write it down and in case someone could explain to me how is this Xonsh portable shell running and which Python is actually using.

Best regards.

For the community: ⬇️ Please click the 👍 reaction instead of leaving a +1 or 👍 comment

spothound commented 3 years ago

Okay, I've found that the problematic xonsh executable isn't actually a Xonsh appimage but a symbolic link to an executable:

total 25464
-rwxr-xr-x 1 vagrant vagrant     3801 Nov 14 15:50 entrypoint.sh
lrwxrwxrwx 1 vagrant vagrant       30 Nov 14 15:51 xonsh -> ./xonsh-squashfs/usr/bin/xonsh
-rw-r--r-- 1 vagrant vagrant     2039 Nov 14 15:50 xonshrc.xsh
-rwxr-xr-x 1 vagrant vagrant 26058792 Oct 16 23:16 xonsh-disabled
drwxr-xr-x 4 vagrant vagrant     4096 Nov 14 15:51 xonsh-squashfs

It seems that the appimage is being extracted in the entrypoint, here: https://github.com/xxh/xxh-shell-xonsh/blob/01dd29a3744edc0ea21aaa2aa7f6549b919a9634/entrypoint.sh#L118

And there is the python without math package. Now I need to understand why this Python (that seems to come from the appimage itself) doesn't have a required package.

Again, the downloaded appimage (which seems to be renamed to xonsh-disabled) works right:

vagrant@metasploitable3-ub1404:~/.xxh/.xxh/shells/xxh-shell-xonsh/build$ ./xonsh-disabled

                                                                                                  Welcome to the xonsh shell (0.9.24.dev89)                                                                                                  

                                                                                                   ~ This fix was trickier than expected ~                                                                                                   

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
xonfig tutorial    ->    Launch the tutorial in the browser
xonfig web         ->    Run the configuration tool in the browser and claim your shell 
(Note: Run the configuration tool or create a ~/.xonshrc file to suppress the welcome screen)

vagrant@metasploitable3-ub1404 ~/.xxh/.xxh/shells/xxh-shell-xonsh/build $
anki-code commented 3 years ago

Hi @grg121! Thank you for reporting this!

The math module should be in the package it's a good question why the exception raised.

I can't repeat this on xxh-dev:

mkdir ~/xxh && cd ~/xxh
git clone https://github.com/xxh/xxh-dev
cd xxh-dev
./xde clone -n xxh      # clone xxh repo from https://github.com/xxh/xxh
./xde build             # build docker containers
./xde up                # run docker containers
./xde g start
# root@start:~#
xxh -i ~/id_rsa root@ubuntu_kf
# root@ubuntu_kf /root/.xxh #
import math
math
# <module 'math' from '/root/.xxh/.xxh/shells/xxh-shell-xonsh/build/xonsh-squashfs/opt/python3.8/lib/python3.8/lib-dynload/math.cpython-38-x86_64-linux-gnu.so'>
exit
exit
./xde stop
./xde remove
rm -rf ~/xxh

Before continue could you please run xxh vagrant@192.168.56.69 +s xonsh +iff? The +iff argument will completely remove .xxh directory and install the xxh from scratch.

xonsh executable isn't actually a Xonsh appimage but a symbolic link to an executable

Right. The current version of xxh-shell-xonsh unpacking AppImage and create symlink to xonsh.

spothound commented 3 years ago

Hello @anki-code,

Thanks for your answer, that's weird. I did as you said a nothing changed. Then I tried removing the local xonsh shell:

rm -rf /home/grg121/.xxh/.xxh/shells/xxh-shell-xonsh

An tried again with success.

Maybe I broke something somehow on the local cloned xonsh shell... I'm not sure how. Sorry for the inconvenience, I guess this issue could be closed.

anki-code commented 3 years ago

Ok, I'll close this. But I think we'll face with this in the future. Feel free to reopen.