Symbolic and hard links "broken" when saving files
See original GitHub issueIssue Report Checklist
- Searched the issues page for similar reports
- Read the relevant sections of the Spyder Troubleshooting Guide and followed its advice
- Reproduced the issue after updating with
conda update spyder
(orpip
, if not using Anaconda) - Tried basic troubleshooting (if a bug/error)
- Restarted Spyder
- Reset preferences with
spyder --reset
- Reinstalled the latest version of Anaconda
- Tried the other applicable steps from the Troubleshooting Guide
- Completed the Problem Description, Steps to Reproduce and Version sections below
Problem Description
I have a few files which are either symbolic or hard links pointing to other files. Before I updated spyder from ~v.3 to the latest v.4.0.1 (from my anaconda distribution), if I modified and saved the symbolic/hard link, it also modified the other links pointing to the same file accordingly. However, with v.4.0.1 if I modify a link (symbolic or hard, actually it does not matter), the link is “broken”.
As an example, if I have a file test.py and a symbolic link in another directory also called test.py, if I open the sym link, update its content and then save it, it will no longer be a sym link, but instead a new python file called test.py. The same applies for hard links, where the link no longer exists after the update (typically stat test.py would show 2 links before saving, and 1 after).
From what I have tried, just opening the file without modifying it does not break the link, only when saving the link no longer exists.
Not sure if it’s a bug or the normal behaviour, but it definitely changed between ~v.3 and v.4.1.0.
What steps reproduce the problem?
- Create a python file test.py and fill it with some lines of code
- Make a symbolic/hard link pointing to test.py, (e.g.
ln -s test.py test2.py
) - You can check if it worked with
ls -l test2.py
(you should see at the end of the line something like test2.py -> test.py) - Open test2.py with spyder, mofidy it and save it
- Check the sym link again with
ls -l test2.py
(you should only see test2.py at the end of the line)
What is the expected output? What do you see instead?
Expected output would be that symbolic or hard links would not be broken, and that modifying one link would modify the content of all the other links pointing to the same file.
Versions
- Spyder version: 4.0.1
- Python version: 3.7.6
- Qt version: 5.14.1
- PyQt version: 5.14.1
- Operating System name/version: Linux 5.3.0-40-generic (Ubuntu 19.10)
Dependencies
atomicwrites >=1.2.0 : 1.3.0 (OK)
chardet >=2.0.0 : 3.0.4 (OK)
cloudpickle >=0.5.0 : 1.3.0 (OK)
diff_match_patch >=20181111 : 20181111 (OK)
intervaltree : None (OK)
IPython >=4.0 : 7.12.0 (OK)
jedi =0.14.1 : 0.14.1 (OK)
keyring : None (OK)
nbconvert >=4.0 : 5.6.1 (OK)
numpydoc >=0.6.0 : 0.9.2 (OK)
pexpect >=4.4.0 : 4.8.0 (OK)
pickleshare >=0.4 : 0.7.5 (OK)
psutil >=0.3 : 5.6.7 (OK)
pygments >=2.0 : 2.5.2 (OK)
pylint >=0.25 : 2.4.4 (OK)
pyls >=0.31.2;<0.32.0 : 0.31.7 (OK)
xdg >=0.26 : 0.26 (OK)
zmq >=17 : 18.1.1 (OK)
qdarkstyle >=2.7 : 2.8 (OK)
qtawesome >=0.5.7 : 0.6.1 (OK)
qtconsole >=4.6.0 : 4.6.0 (OK)
qtpy >=1.5.0 : 1.9.0 (OK)
rtree >=0.8.3 : 0.9.3 (OK)
sphinx >=0.6.6 : 2.4.0 (OK)
spyder_kernels >=1.8.1;<2.0.0: 1.8.1 (OK)
watchdog : None (OK)
cython >=0.21 : 0.29.15 (OK)
matplotlib >=2.0.0 : 3.1.3 (OK)
numpy >=1.7 : 1.18.1 (OK)
pandas >=0.13.1 : 1.0.1 (OK)
scipy >=0.17.0 : 1.4.1 (OK)
sympy >=0.7.3 : 1.5.1 (OK)
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:7 (6 by maintainers)
Note: Probably we need to resolve symlinks when saving. We can use something like:
os.readlink
,os.path.realpath
orpathlib.Path.resolve
Ok, that was it!
@dalthviz, I think the usage of
atomicwrites
makes no possible to use symlinks, so we should forbid opening symlinks in the editor, even if that’s a regression with respect to Spyder 3.So please investigate first the possibility of working with symlinks and
atomicwrites
. If that’s not possible, please add a warning message saying that it’s not possible to open symlinks anymore to guarantee that files are saved correctly to disk.