No such file or directory in the fake filesystem: b'/tmp'
See original GitHub issueDescribe the bug
pyfakefs complains that /tmp directory does not exists, despite the docs stating that “This means that any newly created fake file system will always have either a directory named /tmp when running on Linux or Unix systems”
How To Reproduce Please have a look at this small repo: https://github.com/Wenzel/bug_pyfakefs
smply run python -m pytest -v to reproduce the bug:
venv/lib/python3.8/site-packages/pyfakefs/fake_filesystem.py:4624: in open
return fake_open(file, mode, buffering, encoding, errors,
venv/lib/python3.8/site-packages/pyfakefs/fake_filesystem.py:5202: in __call__
return self.call(*args, **kwargs)
venv/lib/python3.8/site-packages/pyfakefs/fake_filesystem.py:5263: in call
file_object = self._init_file_object(file_object,
venv/lib/python3.8/site-packages/pyfakefs/fake_filesystem.py:5330: in _init_file_object
file_object = self.filesystem.create_file_internally(
venv/lib/python3.8/site-packages/pyfakefs/fake_filesystem.py:2608: in create_file_internally
self.raise_os_error(errno.ENOENT, parent_directory)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <pyfakefs.fake_filesystem.FakeFilesystem object at 0x7f94c2304ac0>, errno = 2, filename = b'/tmp', winerror = None
def raise_os_error(self, errno, filename=None, winerror=None):
"""Raises OSError.
The error message is constructed from the given error code and shall
start with the error string issued in the real system.
Note: this is not true under Windows if winerror is given - in this
case a localized message specific to winerror will be shown in the
real file system.
Args:
errno: A numeric error code from the C variable errno.
filename: The name of the affected file, if any.
winerror: Windows only - the specific Windows error code.
"""
message = self._error_message(errno)
if (winerror is not None and sys.platform == 'win32' and
self.is_windows_fs):
raise OSError(errno, message, filename, winerror)
> raise OSError(errno, message, filename)
E FileNotFoundError: [Errno 2] No such file or directory in the fake filesystem: b'/tmp'
venv/lib/python3.8/site-packages/pyfakefs/fake_filesystem.py:1010: FileNotFoundError
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Going up in the stacktrace:

We see here that an error is raised because /tmp is not found.
Your environment Please run the following and paste the output.
Linux-5.4.0-73-generic-x86_64-with-glibc2.29
Python 3.8.5 (default, Jan 27 2021, 15:41:15)
[GCC 9.3.0]
pyfakefs 4.4.0
Thanks for your help !
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
No such file or directory in the fake filesystem: b'/tmp' #595
Describe the bug pyfakefs complains that /tmp directory does not exists, despite the docs stating that "This means that any newly created ...
Read more >pam_lastlog is complaining about corruption in /var/log/btmp file.
Mostly this corruption issue happens if filesystem where /var/log/ is mounted doesn't have enough space left. Diagnostic Steps. Check if the ...
Read more >How do I mock the filesystem in Python unit tests?
I am mostly concerned about creating, opening and deleting files and directories. In other languages the whole file-system can be mocked. – ...
Read more >debug1: Unable to open the btmp file /var/log/btmp: No such ...
Hello, I think it is not mandatory to have the btmp file in the tree; take for example the output of the lastb...
Read more >Linux: /var/log/wtmp - No such file or directory quick fix and ...
Perhaps this file was removed by the operator to prevent logging last info. Then this might be a sure indicator that some malicious...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@Wenzel - shall be fixed now in master, please check!
Thanks - you are welcome!