When would sage -sh not work?

When is ./sage -sh NOT supposed to work? That is, where should this work in the spkg build process? My sense is that it should work almost immediately - even before Python, right? - but sometimes I get the message about it not working in the middle of a build I need to ./sage -sh in to set environment variables correctly.

I should point out that currently I have a lot of stuff built - Python, Pari, GSL, ecl, elliptic curves - but when I do what the message says (edit $SAGE_ROOT in ./sage) then I just get a message about sage-sage not existing in local/bin, which it is true, it does not.

An acceptable answer to this could include any other way to set the appropriate variables during a build.

1 answer

The script at $SAGE_ROOT/local/bin/sage-env sets the shell environment up for building spks's. Here's what it reads at the top:

###########################################################################
#
# Set environment variables for building and/or running Sage.
# You must *source* this instead of executing; see below!
#
# AUTHORS: William Stein 2005-12
# David Kirkby <david.kirkby@onetel.net> 2005-12-17
#
###########################################################################
##########################################################################
#
# If you want to set all environment variables for your shell like
# they are during the build of Sage packages, type
#
# source local/bin/sage-env
#
# from the SAGE_ROOT directory. To do the same from a /bin/bash
# script use ". local/bin/sage-env".
#
##########################################################################

Note that you should run source local/bin/sage-env from $SAGE_ROOT for it to work.

Essentially, sage -sh calls your shell (say /bin/bash) with an option to prevent loading of the user's .profile or rc file (for /bin/bash it runs the shell without sourcing .profile, .bash_profile, .bashrc) to ensure that the paths are correct. If you are using Bash, then running ./sage -sh from $SAGE_ROOT should be equivalent to doing:

Comments

Essentially, sage -sh calls your shell (say /bin/bash) with an option to prevent loading of the user's .profile or .XXXrc file (for /bin/bash it runs the shell without sourcing .profile, .bash_profile, .bashrc) to ensure that the paths are correct. If you are using Bash, then running `./sage -sh` from `$SAGE_ROOT` should be equivalent to doing: `/bin/bash --norc; source local/bin/sage-env`