Skip to content
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

OSError when saving files on Linux #10208

Closed
matthew-shin opened this issue Sep 16, 2019 · 3 comments · Fixed by #10236
Closed

OSError when saving files on Linux #10208

matthew-shin opened this issue Sep 16, 2019 · 3 comments · Fixed by #10236

Comments

@matthew-shin
Copy link

matthew-shin commented Sep 16, 2019

Problem Description

Attempting to save a .py script in spyder4 beta5 leads to error.

Save Error
Unable to save file 'test_save.py'
Error message:
[Errno 22] Invalid argument

Apologies if simple issue.

What steps reproduce the problem?

  1. Open spyder4 in terminal
  2. Create new script
  3. Attempt to save script

What is the expected output? What do you see instead?

Expect to save script without problem.
Instead, see error box as above, resulting in no save.

Paste Traceback/Error Below (if applicable)

ERROR:spyder.plugins.editor.widgets.autosaveerror:Error while autosaving /scratch/yms23/netscratch/PhD/Python/Scripts/test_save.py to /home/yms23/.config/spyder-py3-dev/autosave/test_save.py
Traceback (most recent call last):
  File "/home/yms23/.conda/envs/spyder4beta/lib/python3.7/site-packages/spyder/plugins/editor/widgets/editor.py", line 1818, in save
    self._write_to_file(finfo, finfo.filename)
  File "/home/yms23/.conda/envs/spyder4beta/lib/python3.7/site-packages/spyder/plugins/editor/widgets/editor.py", line 1777, in _write_to_file
    fileinfo.encoding = encoding.write(txt, filename, fileinfo.encoding)
  File "/home/yms23/.conda/envs/spyder4beta/lib/python3.7/site-packages/spyder/utils/encoding.py", line 251, in write
    textfile.write(text)
  File "/home/yms23/.conda/envs/spyder4beta/lib/python3.7/contextlib.py", line 119, in __exit__
    next(self.gen)
  File "/home/yms23/.conda/envs/spyder4beta/lib/python3.7/site-packages/atomicwrites/__init__.py", line 159, in _open
    self.commit(f)
  File "/home/yms23/.conda/envs/spyder4beta/lib/python3.7/site-packages/atomicwrites/__init__.py", line 192, in commit
    replace_atomic(f.name, self._path)
  File "/home/yms23/.conda/envs/spyder4beta/lib/python3.7/site-packages/atomicwrites/__init__.py", line 93, in replace_atomic
    return _replace_atomic(src, dst)
  File "/home/yms23/.conda/envs/spyder4beta/lib/python3.7/site-packages/atomicwrites/__init__.py", line 50, in _replace_atomic
    _sync_directory(os.path.normpath(os.path.dirname(dst)))
  File "/home/yms23/.conda/envs/spyder4beta/lib/python3.7/site-packages/atomicwrites/__init__.py", line 44, in _sync_directory
    _proper_fsync(fd)
OSError: [Errno 22] Invalid argument

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/yms23/.conda/envs/spyder4beta/lib/python3.7/site-packages/spyder/plugins/editor/utils/autosave.py", line 362, in autosave
    self.stack._write_to_file(finfo, autosave_filename)
  File "/home/yms23/.conda/envs/spyder4beta/lib/python3.7/site-packages/spyder/plugins/editor/widgets/editor.py", line 1777, in _write_to_file
    fileinfo.encoding = encoding.write(txt, filename, fileinfo.encoding)
  File "/home/yms23/.conda/envs/spyder4beta/lib/python3.7/site-packages/spyder/utils/encoding.py", line 251, in write
    textfile.write(text)
  File "/home/yms23/.conda/envs/spyder4beta/lib/python3.7/contextlib.py", line 119, in __exit__
    next(self.gen)
  File "/home/yms23/.conda/envs/spyder4beta/lib/python3.7/site-packages/atomicwrites/__init__.py", line 159, in _open
    self.commit(f)
  File "/home/yms23/.conda/envs/spyder4beta/lib/python3.7/site-packages/atomicwrites/__init__.py", line 192, in commit
    replace_atomic(f.name, self._path)
  File "/home/yms23/.conda/envs/spyder4beta/lib/python3.7/site-packages/atomicwrites/__init__.py", line 93, in replace_atomic
    return _replace_atomic(src, dst)
  File "/home/yms23/.conda/envs/spyder4beta/lib/python3.7/site-packages/atomicwrites/__init__.py", line 50, in _replace_atomic
    _sync_directory(os.path.normpath(os.path.dirname(dst)))
  File "/home/yms23/.conda/envs/spyder4beta/lib/python3.7/site-packages/atomicwrites/__init__.py", line 44, in _sync_directory
    _proper_fsync(fd)
OSError: [Errno 22] Invalid argument
Traceback (most recent call last):
  File "/home/yms23/.conda/envs/spyder4beta/lib/python3.7/site-packages/spyder/plugins/editor/utils/autosave.py", line 116, in do_autosave
    stack.autosave.autosave_all()
  File "/home/yms23/.conda/envs/spyder4beta/lib/python3.7/site-packages/spyder/plugins/editor/utils/autosave.py", line 374, in autosave_all
    self.maybe_autosave(index)
  File "/home/yms23/.conda/envs/spyder4beta/lib/python3.7/site-packages/spyder/plugins/editor/utils/autosave.py", line 338, in maybe_autosave
    autosave_hash = self.file_hashes[autosave_filename]
KeyError: '/home/yms23/.config/spyder-py3-dev/autosave/test_save.py'

Versions

  • Spyder version: 4.0.0b5
  • Python version: 3.7.4
  • Qt version: 5.9.6
  • PyQt version: 5.9.2
  • Operating System name/version: Linux 4.4.0-161-generic

Dependencies

cloudpickle >=0.5.0 : 1.2.1 (OK)
pygments >=2.0 : 2.4.2 (OK)
qtconsole >=4.5.5 : 4.5.5 (OK)
nbconvert >=4.0 : 5.5.0 (OK)
sphinx >=0.6.6 : 2.1.2 (OK)
pylint >=0.25 : 2.3.1 (OK)
psutil >=0.3 : 5.6.3 (OK)
qtawesome >=0.5.7 : 0.5.7 (OK)
qtpy >=1.5.0 : 1.9.0 (OK)
pickleshare >=0.4 : 0.7.5 (OK)
zmq >=17 : 18.1.0 (OK)
chardet >=2.0.0 : 3.0.4 (OK)
numpydoc >=0.6.0 : 0.9.1 (OK)
spyder_kernels >=1.5.0;<2.0.0: 1.5.0 (OK)
qdarkstyle >=2.7 : 2.7 (OK)
atomicwrites >=1.2.0 : 1.3.0 (OK)
diff_match_patch >=20181111 : 20181111 (OK)
watchdog : None (OK)
keyring : None (OK)
pexpect >=4.4.0 : 4.7.0 (OK)
pympler : None (OK)
sympy >=0.7.3 : None (NOK)
cython >=0.21 : None (NOK)
IPython >=4.0 : 7.7.0 (OK)
matplotlib >=2.0.0 : 3.1.0 (OK)
pandas >=0.13.1 : 0.25.0 (OK)
numpy >=1.7 : 1.16.4 (OK)
scipy >=0.17.0 : 1.3.1 (OK)
pyls >=0.28.2;<0.29.0 : 0.28.3 (OK)
xdg >=0.26 : 0.26 (OK)
rtree >=0.8.3 : 0.8.3 (OK)

@ccordoba12
Copy link
Member

ccordoba12 commented Sep 16, 2019

This happens because some filesystems don't support the option to sync directories (e.g. network file systems), as described in issue untitaker/python-atomicwrites#17

@andfoy, please take care of this one. We basically need to catch the error thrown by atomicwrites and perform a regular write instead. Code to catch that error is shown in PR untitaker/python-atomicwrites#28

@matthew-shin, until this problem is fixed I'm afraid you'll have to keep using Spyder 3.3.6.

@ccordoba12 ccordoba12 changed the title Saving issue in spyder 4.0.0b5 OSError when saving files on Linux Sep 16, 2019
@matthew-shin
Copy link
Author

Unfortunate. Will revert to spyder3; thanks for the response!

@ccordoba12 ccordoba12 assigned steff456 and unassigned andfoy Sep 16, 2019
@ccordoba12
Copy link
Member

Sorry @andfoy, let's assign this one to @steff456 because it should be relatively easy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants