#5852: The detection of SAGE_ROOT in $SAGE_ROOT/sage and local/bin/sage-env 
should
expand symlinks recursively
-------------------------------+--------------------------------------------
    Reporter:  tornaria        |         Owner:  jdemeyer    
        Type:  defect          |        Status:  needs_review
    Priority:  major           |     Milestone:  sage-4.7.2  
   Component:  distribution    |    Resolution:              
    Keywords:                  |   Work_issues:              
    Upstream:  N/A             |      Reviewer:              
      Author:  Jeroen Demeyer  |        Merged:              
Dependencies:                  |  
-------------------------------+--------------------------------------------
Description changed by jdemeyer:

Old description:

> Currently, {{{$SAGE_ROOT/sage}}} uses (first among other alternate
> methods) {{{readlink -n}}} to detect the directory where the script lives
> (that's $SAGE_ROOT), but that is broken because
>  - It only works when `$0` (the sage executable itself) is a symbolic
> link
>  - If the sage executable is a symbolic link, then `readlink -n` returns
> the link itself, not the canonicalized name.  Example: if
> `/usr/local/sage-4.7.1/sage` is a symbolic link to `sagefoo`, then
> `SAGE_ROOT` would become `sagefoo` when `'/usr/local/sage-4.7.1/sagefoo`
> is intended.
>  - The symlink expansion may not be completely done, and {{{$SAGE_ROOT}}}
> could end up with a non-canonical dirname, which leads to issues with
> testing.
>  - The code to detect `SAGE_ROOT` inside `sage-env` does not canonicalize
> the pathname at all.  This should be fixed as well. (The only case where
> `sage-env` is run without `SAGE_ROOT` being set is when testing Sage from
> the `Makefile`, i.e. when running `make ptest` or similar.)
>
> Note that we should do this in a portable way, without using `realpath`,
> `readlink -f` or the likes.  See attachments for two bash scripts to
> solve this problem (either of them should suffice).
>
> Apply:
>  1. [attachment:5852_sage_root.patch] to `SAGE_ROOT`
>  1. [attachment:5852_scripts.patch] to `local/bin`

New description:

 Currently, {{{$SAGE_ROOT/sage}}} uses (first among other alternate
 methods) {{{readlink -n}}} to detect the directory where the script lives
 (that's $SAGE_ROOT), but that is broken because
  - It only works when `$0` (the sage executable itself) is a symbolic link
  - If the sage executable is a symbolic link, then `readlink -n` returns
 the link itself, not the canonicalized name.  Example: if
 `/usr/local/sage-4.7.1/sage` is a symbolic link to `sagefoo`, then
 `SAGE_ROOT` would become `sagefoo` when `'/usr/local/sage-4.7.1/sagefoo`
 is intended.
  - The symlink expansion may not be completely done, and {{{$SAGE_ROOT}}}
 could end up with a non-canonical dirname, which leads to issues with
 testing.
  - The code to detect `SAGE_ROOT` inside `sage-env` does not canonicalize
 the pathname at all.  This should be fixed as well. (The only case where
 `sage-env` is run without `SAGE_ROOT` being set is when testing Sage from
 the `Makefile`, i.e. when running `make ptest` or similar.)

 Note that we should do this in a portable way, without using `realpath`,
 `readlink -f` or the likes.  See attachments for two bash scripts to solve
 this problem (either of them should suffice).

 See also #11704, which solves the same problem for `DOT_SAGE`.

 Apply:
  1. [attachment:5852_sage_root.patch] to `SAGE_ROOT`
  1. [attachment:5852_scripts.patch] to `local/bin`

--

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/5852#comment:27>
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