modularml / mojo

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

[Magic CLI] error starting magic shell as notebook cell script (%%mojo) #3429

Open RefinedSoftwareLLC opened 2 weeks ago

RefinedSoftwareLLC commented 2 weeks ago

Issue description

Using ipython magic-action %%script to call modular's magic shell gives an error (see steps to reproduce).

Steps to reproduce

Using ipython magic-action %%script to call modular's magic shell, while offline, running a no-op comment line of #, I get the following error:

Error starting shell: Not a tty (os error 25)

---------------------------------------------------------------------------
CalledProcessError                        Traceback (most recent call last)
Cell In[2], line 1
----> 1 get_ipython().run_cell_magic('mojo', '', '#\n')

File /opt/conda/lib/python3.10/site-packages/IPython/core/interactiveshell.py:2517, in InteractiveShell.run_cell_magic(self, magic_name, line, cell)
   2515 with self.builtin_trap:
   2516     args = (magic_arg_s, cell)
-> 2517     result = fn(*args, **kwargs)
   2519 # The code below prevents the output from being displayed
   2520 # when using magics with decorator @output_can_be_silenced
   2521 # when the last Python token in the expression is a ';'.
   2522 if getattr(fn, magic.MAGIC_OUTPUT_CAN_BE_SILENCED, False):

File /opt/conda/lib/python3.10/site-packages/IPython/core/magic.py:755, in MagicAlias.__call__(self, *args, **kwargs)
    753         args_list[0] = self.magic_params + " " + args[0]
    754         args = tuple(args_list)
--> 755     return fn(*args, **kwargs)
    756 finally:
    757     self._in_call = False

File /opt/conda/lib/python3.10/site-packages/IPython/core/magics/script.py:314, in ScriptMagics.shebang(self, line, cell)
    309 if args.raise_error and p.returncode != 0:
    310     # If we get here and p.returncode is still None, we must have
    311     # killed it but not yet seen its return code. We don't wait for it,
    312     # in case it's stuck in uninterruptible sleep. -9 = SIGKILL
    313     rc = p.returncode or -9
--> 314     raise CalledProcessError(rc, cell)

CalledProcessError: Command 'b'#\n'' returned non-zero exit status 1.

The following works just fine: %%bash, %%python, %%script bash, %%script python.

Reproducible in notebook: https://www.kaggle.com/code/michaeldgibson/offline-mojo-template/notebook?scriptVersionId=194491514

After calling %alias_magic --cell mojo script -p 'magic shell', new notebook cells can start with %%mojo which should compile the cell for mojo once these errors are able to be fixed.

Version Info

magic --version
# magic 0.2.2
RefinedSoftwareLLC commented 2 weeks ago

https://ipython.readthedocs.io/en/stable/interactive/magics.html

RefinedSoftwareLLC commented 1 week ago
magic run mojo main.mojo

/kaggle/.magic/envs/default/bin/mojo-lldb: /opt/conda/lib/libtinfo.so.6: version `NCURSES6_TINFO_6.2.20211010' not found (required by /opt/conda/lib/libncurses.so.6)

I have one notebook with that checksum that is working, and another with the same checksum that is not. The error message says the file is missing, but it is there.

How do I even troubleshoot this?

sha1sum /opt/conda/lib/libtinfo.so.6

477797e683c94f335e5afafb5e71e0d6ce2dd975 /opt/conda/lib/libtinfo.so.6

sha1sum /opt/conda/lib/libncurses.so.6

3d83b47a859575daf348092eb4f7185dc5f207c1 /opt/conda/lib/libncurses.so.6