Automate launching Sage notebook with mamba in WSL
In WSL (Ubuntu), I have created a shell script ~/sage_nb.sh
:
mamba activate sageforge
cd /mnt/g/<somepath>
sage -n jupyter --NotebookApp.use_redirect_file=False
However, simply running the script via the command ~/sage_nb.sh
results in errors:
Run 'mamba init' to be able to run mamba activate/deactivate and st art a new shell session. Or use conda to activate/deactivate.
I found out that running source ~/sage_nb.sh
would work. However, this assumes that I manually launch ubuntu WSL and then run source ~/sage_nb.sh
. I would like to automate this entire process.
Creating and running a Window batch script with the command ubuntu run "source ~/sage_nb.sh"
results in error:
mamba: command not found
I believe this is because mamba needs some preprocessing that is usually done by launching ubuntu manually.
Try using a login shell, i.e. adding
#!/bin/bash --login
at the top of your shell script.This doesn't work.
ubuntu run "source ~/sage_nb.sh"
and"ubuntu run ~/sage_nb.sh"
still result inmamba: command not found
andsage: command not found
.