Description
If the wiki instance is installed on a file system different than the "/tmp" directory is installed on the error
OSError: [Errno 18] Invalid cross-device link
is thrown. If the same instance wiki is moved to the file system on which "/tmp" resides everything works as a charm (path are adapted appropriately). It might be that this is the same problem as described for TurboGears, see http://trac.turbogears.org/turbogears/ticket/479.
It appears that the function os.tempnam ignores it first argument "dir" and uses always "/tmp" as a prefix. This is observed on SUSE Linux 10.1 and Python 2.4.2. The Python bug list only reports something similar regarding a problem on Windows, bug 635656
The expected result of the example below is "dada/prefrYwDxF" and not "/tmp/prefrYwDxF".
> python Python 2.4.2 (#1, May 2 2006, 08:13:46) [GCC 4.1.0 (SUSE Linux)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import os >>> import warnings >>> warnings.filterwarnings("ignore", "tempnam.*security", RuntimeWarning, "MoinMoin.caching") >>> os.tempnam("dada", "pref") '/tmp/prefrYwDxF'
Since os.rename does only a rename within a file system, it fails. The above mentioned false behavior does not exist on Solaris 10 x86, Python 2.4.3. It is also not seen with a fresh build of Python 2.5 on SUSE 10.1.
Steps to reproduce
Install a dummy wiki instance on a file system differently than the "/tmp" resides.
Details
Workaround
Install wiki instance on the file system with "/tmp".
Use Apache "SetEnv TMPDIR /xxx" configuration directive to establish a temp directory on the same device as the wiki instance. Can be applied for just moin inside <Directory> sections.
Discussion
Yes, looks like a bug. Caching.py should create a file in the same directory where the cache file goes as well.
A fix could be either to use tempfile.mkstemp as done by the TurboGears programmers. But then the code is Python 2.3 or higher dependent, since the function mkstemp is new to 2.3. moin 1.5 depends on py 2.3 anyway.
Quoting the docs: On Unix, the environment variable TMPDIR overrides dir, while on Windows the TMP is used. So maybe try NOT setting TMPDIR or TMP and it will work as expected.
Just added the second "workaround" above. Now realize that perhaps this is the best way to fix the problem. Just needs to be documented in the installation procedures.
I can confirm that this was the problem and agree with your argumentation.
Plan
- Priority:
- Assigned to:
- Status:
- this is not a moin bug, but a silly stdlib function. I guess you can fix the problem by unsetting TMP(DIR) env var.
- we will use tempfile.mkstemp() in future to avoid this problem