#10469: Don't (effectively) source sage-env more than once
--------------------------------------------------------+-------------------
    Reporter:  leif                                     |         Owner:  
GeorgSWeber                
        Type:  defect                                   |        Status:  
closed                     
    Priority:  major                                    |     Milestone:  
sage-4.7.1                 
   Component:  build                                    |    Resolution:  fixed 
                     
    Keywords:  environment variables sage-sage scripts  |   Work_issues:        
                     
    Upstream:  N/A                                      |      Reviewer:  Ivan 
Andrus, Jeroen Demeyer
      Author:  Ivan Andrus, John Palmieri, Keshav Kini  |        Merged:  
sage-4.7.1.alpha0          
Dependencies:                                           |  
--------------------------------------------------------+-------------------

Comment(by leif):

 Some funny side effect, i.e. a bug that only gets really visible with
 #11021 (substituting almost all instances of `build` in `sage-spkg` with
 `$BUILD`, which by itself is pretty ok, but also replacing the odd
 `mymkdir()` with `mkdir -p`, the latter then finally showing the bug):

 {{{
 leif@portland:~/Sage/sage-4.7.1.alpha4$ ./sage -i flint-1.5.0.p5.spkg
 Installing flint-1.5.0.p5.spkg
 Calling sage-spkg on flint-1.5.0.p5.spkg
 Warning: Attempted to overwrite SAGE_ROOT environment variable
 mkdir: cannot create directory `': No such file or directory
 flint-1.5.0.p5
 Machine:
 Linux portland 2.6.28-19-generic #66-Ubuntu SMP Sat Oct 16 18:00:58 UTC
 2010 x86_64 GNU/Linux
 sage: /home/leif/Sage/sage-4.7.1.alpha4/flint-1.5.0.p5.spkg is already
 installed
 }}}

 The error originates from `mkdir -p "$BUILD"`, previously `mymkdir
 "$BUILD"`, which incidentally didn't try to create the "empty" directory,
 because its test in advance `[ ! -d $1 ]` evaluates to `false` (although
 the directory of course does not exist).

 The following `cd "$BUILD"` becomes a no-op, and most other instances of
 `$BUILD` happen to be `.../$BUILD`, so don't raise an error either. Only
 `rm` also fails when trying to remove the temporary files in the wrong
 directory (still `.../build/...`).

 Note that previously, after merging this ticket (#10469), the error just
 didn't show up because during the build `sage-spkg` gets called directly,
 hence fully sourcing `sage-env` (such that `$BUILD` gets `build`),
 creating the `build` directory, which can later be used when otherwise its
 creation and therefore also references to it would fail.

 Long story, for short:

 If `sage-env` is (effectively) sourced only once, all variables must be
 exported, since the script first sourcing it can call other scripts that
 source `sage-env` again, but if `sage-env` then returns early, the second
 script doesn't get non-exported variables set.

 (At least) `BUILD` is one such variable that currently doesn't get
 exported.

 I'll provide a patch to `sage-env` at #11021.

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/10469#comment:24>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sage-trac?hl=en.

Reply via email to