# 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. edit retag close merge delete ## Comments Which spkgs give these messages? If they really need "sage -sh" to work, then they should be changed so that they have the scripts spkg as a prerequisite in SAGE_ROOT/spkg/standard/deps. ( 2011-08-24 16:24:14 -0500 )edit Oh, I think nearly ALL of them do! That's in the standard error message when an spkg fails to build. ( 2011-08-25 06:50:48 -0500 )edit ## 1 answer Sort by » oldest newest most voted 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:

> /bin/bash --norc
> source local/bin/sage-env

more

What would the difference between this and sage -sh be?

( 2011-08-24 15:32:09 -0500 )edit

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

( 2011-08-24 15:53:11 -0500 )edit

Note also that sage-env is in SAGE_ROOT/spkg/base, so it is there right at the start of the Sage installation.

( 2011-08-24 16:22:45 -0500 )edit

Okay, this at least clears up most of what I wanted to know. @benjaminfjones, can you add that info to the main answer so that others could find it more easily?

( 2011-08-25 06:47:33 -0500 )edit