-
-
Notifications
You must be signed in to change notification settings - Fork 482
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Properly canonicalize $SAGE_ROOT #5852
Comments
comment:1
Patching
fixes the issue, since now According to mabshoff, |
On systems where "readlink -f" is supported, use that so the path for $SAGE_ROOT is fully canonicalized |
comment:2
Attachment: trac_5852.patch.gz Replying to @tornaria:
I can confirm that it does not work on MacOS X.10.4.11 (e.g. Anne Schilling's machine) A fix would be most welcome, as this makes sage -t make false reports of broken test files. |
comment:3
The readlink -f workaround is better than nothing, and should not make things worst for systems like BSD. I would vote for including it now, in waiting for a better solution. Besides, what about adding a switch to sage -t to specify manually that the given file is inside or outside the sage source tree? This would make a workaround for MacOX X, and also be occasionally be useful. For example, I often run tests from one sage source tree with another sage to compare the results. |
comment:4
Is there some equivalent of |
comment:5
Note that the version of |
comment:6
See #6146 for fixing this on systems that don't support readlink -f. |
comment:7
Merged in 4.0.rc1. |
comment:8
Question. Does
work on any platform?! It gives an error on both OS X and Linux. Why is it even there?!
I wonder who wrote this weird SAGE_ROOT code in the first place? I wrote something a long time ago, but it bears no resemblance to the current code. By the way, I've had reports of major failures caused by using There is no realpath on OS X, but that is ok since readlink doesn't work ever on OS X anyways, so no loss. -- William |
comment:9
Replying to @williamstein:
Yes it does: it reads the content of a symbolic link. It succeeds if and only if the argument is actually a symbolic link, e.g.
The option
It was there before the patch in this ticket, so that if Following my example above, here's an example where
The other major case is when there are symlinks in some of the components of the path, those get canonicalized by
Can you give a pointer to those? Not using Do you actually know that in those cases
There is no OTOH, realpath(3) seems to be a POSIX standard, and it seems to be available on OS X:
so an alternative would be to compile our own |
comment:10
It's possible that this ticket should be reverted until a major bug it causes is fixed. The reason for this ticket in the first place was the following, as given in the ticket description:
Notice the symlink of the Sage script
For the record, this is not how I meant the sage script is meant to be used. I bet this isn't documented, but it should be. The script should never be used that way. Instead one should do
and then edit the copied script to explicitly point to the ROOT. It was never my intention for somebody to run the sage script unmodified outside of SAGE_ROOT. Me not intending this means that elsewhere in the Sage build/test system this assumption is made, and the workaround on this ticket actually seriously breaks things for some users. The change in this ticket causes serious breakage for people whose home directory is NFS mounted, and for which their Sage build is on another volume that is symlinked from their home directory. i.e., this sort of setup:
I'm doing a test build for myself to confirm that this happens, and if so and I can't figure out how to fix this promptly (maybe I will be able to), then we have to revert this change, and document that one can't just symlink the sage script out. |
comment:11
Replying to @williamstein:
If you only use the script in that way, then the
branch would never be taken, and as the patch in this ticket only touches this branch, it can't break anything. In practice, it is much more convenient to just use a symlink to the script, if it can be worked out. Before this patch, it turned out that the real, canonical path for SAGE_ROOT could be identified incorrectly, and this causes doctesting to fail.
This sort of setup is exactly what used to cause breakage for me, because the
Are you expecting SAGE_ROOT above to be "/home/wstein/sage-build/sage-nnn/", or "/tmp/wstein/sage-nnn" ? Before the patch, it was the former, non canonical path; after the patch, it is the latter, which is IMO the correct canonical path. When SAGE_ROOT is non-canonical, running doctests for files in the sage library fails b/c they are not recognized as part of the sage library, etc. I don't see how the fact that this is NFS mounted could be relevant to the issue. |
comment:12
The problem with this patch isn't that it is "wrong" (which is what you're arguing with me about above). It is that it seriously breaks Sage, hence it must be reverted or the problem it causes must be fixed. I had a look, and the problem is here in local/bin/sage-doctest:
The problem is that the library_code variable is being set to False for all the code that is in the library. It is being set to false because if one does
then argv[1] is not first canonicalized, which messes everything up completely. So for this ticket to be in (which I agree with at some point), one needs to factor out this path caonicalization, and make sure it is applied everywhere (e.g,. in sage-doctest). There could be many other places where subtle problems arise -- I don't know. For now, this needs to be reverted. |
comment:13
I have reverted this patch in sage-4.1.rc0, and I'm reopening the ticket. |
Attachment: 5852_scripts.patch.gz Patch for local/bin/sage-env, SCRIPTS repository |
comment:33
Replying to @jdemeyer:
SAGE_ROOT=`cd "$SAGE_ROOT" && pwd -P`
Of course it does. You just have to
|
comment:34
Replying to @nexttime:
Again, this does not work if the executable itself is a symbolic link. It could very well be that my solution is too complicated, but your solution is certainly too simple. |
Milestone sage-4.7.3 deleted |
This comment has been minimized.
This comment has been minimized.
comment:37
How widely available is
This is what it says on sage.math, for example. I use bash there, and the built-in pwd supports the |
comment:38
(Part of the problem is that on that other machine, I'm using tcsh and it doesn't let me run 'chsh'.) |
comment:39
Has this been tested on OS X 10.4? I believe that uses an older version of bash, and so we should make sure that it has the features used in the modifications to the |
comment:40
This seems to work for me on various platforms. If someone can test on OS X 10.4, I think we can give it a positive review. (The Changelog I saw for bash doesn't discuss changes for expansions like |
comment:41
Replying to @jhpalmieri:
Yes, it works. You are right that
But it seems |
Attachment: 5852_doc.patch.gz |
This comment has been minimized.
This comment has been minimized.
comment:42
Added documentation patch attachment: 5852_doc.patch |
This comment has been minimized.
This comment has been minimized.
Reviewer: John Palmieri, Leif Leonhardy |
comment:44
This looks good to me. I'm attaching a referee patch for the documentation part. If that's okay, this can be changed to "positive review". |
Attachment: trac_5852-doc-referee.patch.gz main sage repo |
Merged: sage-4.8.alpha3 |
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$0
(the sage executable itself) is a symbolic linkreadlink -n
returns the link itself, not the canonicalized name. Example: if/usr/local/sage-4.7.1/sage
is a symbolic link tosagefoo
, thenSAGE_ROOT
would becomesagefoo
when'/usr/local/sage-4.7.1/sagefoo
is intended.$SAGE_ROOT
could end up with a non-canonical dirname, which leads to issues with testing.SAGE_ROOT
insidesage-env
does not canonicalize the pathname at all. This should be fixed as well. (The only case wheresage-env
is run withoutSAGE_ROOT
being set is when testing Sage from theMakefile
, i.e. when runningmake ptest
or similar.)Note that we should do this in a portable way, without using
realpath
,readlink -f
or the likes.See also #11704, which solves the same problem for
DOT_SAGE
.Apply:
SAGE_ROOT
local/bin
devel/sage
Depends on #11926
Depends on #11959
CC: @nexttime @kini
Component: scripts
Author: Jeroen Demeyer
Reviewer: John Palmieri, Leif Leonhardy
Merged: sage-4.8.alpha3
Issue created by migration from https://trac.sagemath.org/ticket/5852
The text was updated successfully, but these errors were encountered: