Automate launching Sage notebook with mamba in WSL

asked 1 year ago

Road gravatar image

updated 1 year ago

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.

Preview: (hide)

Comments

Try using a login shell, i.e. adding #!/bin/bash --login at the top of your shell script.

rburing gravatar imagerburing ( 1 year ago )

This doesn't work. ubuntu run "source ~/sage_nb.sh" and "ubuntu run ~/sage_nb.sh" still result in mamba: command not found and sage: command not found.

Road gravatar imageRoad ( 1 year ago )