Ask Your Question

Revision history [back]

Calling the sage executable in a Mac OS X terminal

Sage for Mac OS X: app vs non-app version

On OS X there are several ways to install Sage: download the app, or the non-app binary, or build from source.

In any case, you can call the command-line version of Sage by typing the full path to it in the terminal. This could be (adapt the path to reflect where you installed Sage, and the name of the app):

  • for the non-app version:

    $ /Applications/sage-6.3/sage
    
  • for the app version (the executable is hidden inside the .app bundle):

    /Applications/Sage-6.3-OSX-64bit-10.9.app/Contents/Resources/sage/sage
    

You can add options such as -v or -ipython notebook to such a call.

Typing 'sage' in the terminal

What happens when you type 'sage' in the terminal depends on whether an alias 'sage' exists, and what it points to, and whether 'sage' can be found in your PATH, and what this 'sage' is (an executable, a symlink...).

Type alias sage to check if you have an alias called 'sage' and what it aliases to. This will output a line

alias sage='xxx'

if an alias is set, otherwise no output will appear and you will just get the terminal prompt.

If the alias is set, it could be defined in a configuration file such as .bashrc or .bash_profile in your home directory.

Type which sage to check if some 'sage' can be found in your PATH. If for example you get:

$ which sage
/usr/local/bin/sage

this will tell you that 'sage' is found in /usr/local/bin/ and you can investigate further by typing

$ ls -alF /usr/local/bin/sage

which, if this 'sage' is a symlink, will tell you what it points to, for example:

/usr/local/bin/sage@ -> /Applications/sage-6.3/sage

I would recommend not using an alias, but a symlink in /usr/local/bin/ pointing to the sage executable.

To create such a symlink, type the following in a terminal

$ sudo ln -s /Applications/sage-6.3/sage /usr/local/bin/sage

(adapt according to the location of your Sage installation).

If you already had a symlink (to a previous version of sage), first do

$ sudo rm -f /usr/local/bin/sage

The last two commands start by 'sudo' because the /usr/local/bin/ you need administrator rights to write in /usr/local/bin/ (you will be asked to authenticate when you issue these commands).