modularml / mojo

The Mojo Programming Language
https://docs.modular.com/mojo/manual/
Other
23.35k stars 2.6k forks source link

[Magic CLI]: `mojo` or `mojo debug` lead to "error while loading shared libraries: libedit.so.2" #3629

Open Julian-J-S opened 1 month ago

Julian-J-S commented 1 month ago

Issue description

When running

Getting the error: /home/julian/programming/mojo/hello2/.magic/envs/default/bin/mojo-lldb: error while loading shared libraries: libedit.so.2: cannot open shared object file: No such file or directory

However mojo main.mojo works! :green_circle:

Steps to reproduce

Setup project with magic init hello --format mojoproject Run commands from issue description

Version Info

- magic: magic 0.3.1 - (based on pixi 0.29.0)
- mojo: mojo 24.5.0 (e8aacb95)
- OS: Fedora Linux 40 (Workstation Edition)
stflavian commented 1 month ago

I am currently having the same issue on Fedora 40. As far as I can see, a workaround for missing libraries on Fedora (including this one) was already discussed here. But it would be nice if these would be covered by the installer instead of leaving them to the user to deal with.

teleporterx commented 2 days ago

I was trying out mojo following the official docs https://docs.modular.com/mojo/manual/get-started/.

I am on arch, although I feel that the workaround for the same issue I faced will help you on Fedora

$ uname -a                                    
Linux archusb 6.11.9-zen1-1-zen #1 ZEN SMP PREEMPT_DYNAMIC Sun, 17 Nov 2024 16:06:09 +0000 x86_64 GNU/Linux
$ magic init sandbox --format mojoproject # creates a new project
✔ Created /home/teleporterx/Mojo/sandbox/mojoproject.toml
✔ Added max >=24.5.0,<25

$ cd sandbox && magic shell # activates the venv

$ mojo --version
mojo 24.5.0 (e8aacb95)

However, when I try mojo, I get the same error that was mentioned

$ mojo
/home/teleporterx/Mojo/sandbox/.magic/envs/default/bin/mojo-lldb: error while loading shared libraries: libedit.so.2: cannot open shared object file: No such file or directory

and when you check the shared libs

$  ldd .magic/envs/default/bin/mojo-lldb
    linux-vdso.so.1 (0x00007776c266e000)
    liblldb20.0.0git.so => /home/teleporterx/Mojo/sandbox/.magic/envs/default/bin/../lib/liblldb20.0.0git.so (0x00007776b9024000)
    libncurses.so.6 => /home/teleporterx/Mojo/sandbox/.magic/envs/default/bin/../lib/libncurses.so.6 (0x00007776b8ffa000)
    libtinfo.so.6 => /home/teleporterx/Mojo/sandbox/.magic/envs/default/bin/../lib/libtinfo.so.6 (0x00007776b8fb6000)
    libpanel.so.6 => /home/teleporterx/Mojo/sandbox/.magic/envs/default/bin/../lib/libpanel.so.6 (0x00007776b8faf000)
    libedit.so.2 => not found
    libm.so.6 => /usr/lib/libm.so.6 (0x00007776b8ea2000)
    libstdc++.so.6 => /home/teleporterx/Mojo/sandbox/.magic/envs/default/bin/../lib/libstdc++.so.6 (0x00007776b8cc0000)
    libgcc_s.so.1 => /home/teleporterx/Mojo/sandbox/.magic/envs/default/bin/../lib/libgcc_s.so.1 (0x00007776b8ca1000)
    libc.so.6 => /usr/lib/libc.so.6 (0x00007776b8ab0000)
    /lib64/ld-linux-x86-64.so.2 => /usr/lib64/ld-linux-x86-64.so.2 (0x00007776c2670000)
    libedit.so.2 => not found
    libdl.so.2 => /usr/lib/libdl.so.2 (0x00007776b8aa9000)
    librt.so.1 => /usr/lib/librt.so.1 (0x00007776b8aa4000

libedit.so.2 => not found

I had libedit already installed (but i had the so.0 & others instead of so.2)

$ sudo pacman -Ss libedit
[sudo] password for teleporterx: 
core/libedit 20240517_3.1-1 [installed]
    Command line editor library providing generic line editing, history, and
    tokenization functions
extra/editline 1.17.1-3
    A readline() replacement for UNIX without termcap (ncurses)
extra/linenoise-ng 1.0.1-3
    A small self-contained alternative to readline and libedit that supports
    UTF-8 and Windows

$  ls /usr/lib | grep libedit                            
libeditorconfig.so
libeditorconfig.so.0
libeditorconfig.so.0.12.9
libeditorconfig_static.a
libedit.so
libedit.so.0
libedit.so.0.0.73

Workaround

** replace with your username & paths wherever appropriate.

and then try mojo

$ mojo # this is with magic shell (activated)
warning: (x86_64) /home/teleporterx/Mojo/sandbox/.magic/envs/default/lib/libstdc++.so.6 unsupported DW_FORM value: 0x1e
Welcome to Mojo! 🔥

Expressions are delimited by a blank line.
Type `:quit` to exit the REPL and `:mojo help` for further assistance.

  1>

The warning about libstdc++.so.6 is non-fatal—just an issue related to debugging or some internal symbol handling in the library.