Closed
Description
Describe the bug
Addressing file via ~/file
notation resolves to wrong path using facts.files.File, operations.files.file and so on
To Reproduce
- Spin up Ubuntu/Debian vm
- Create file
test.txt
in~
directory - Run
main.py
:
from pyinfra.facts import files
from pyinfra import host
relative_file = host.get_fact(files.File, '~/test.txt')
absolute_file = host.get_fact(files.File, '/home/ubuntu/test.txt')
print()
print()
print('+++\n' + str(relative_file) + '\n+++')
print('+++\n' + str(absolute_file) + '\n+++')
print()
- See output:
(...)
+++
None
+++
+++
{'user': 'ubuntu', 'group': 'ubuntu', 'mode': 664, 'atime': datetime.datetime(2023, 11, 6, 8, 5, 43), 'mtime': datetime.datetime(2023, 11, 6, 8, 5, 43), 'ctime': datetime.datetime(2023, 11, 6, 8, 5, 43), 'size': 0}
+++
(...)
- Target system information
Ubuntu 20.04.6 LTS (GNU/Linux 5.4.0-164-generic x86_64)
Debian GNU/Linux 12 (bookworm) Linux 6.1.0-13-amd64 x86-64
Expected behavior
Explicit warning/error about using of ~
in path, or support for this notation
Meta
- Include output of
pyinfra --support
.
pyinfra --support
--> Support information:
If you are having issues with pyinfra or wish to make feature requests, please
check out the GitHub issues at https://github.com/Fizzadar/pyinfra/issues .
When adding an issue, be sure to include the following:
System: Linux
Platform: Linux-6.2.0-36-generic-x86_64-with-glibc2.37
Release: 6.2.0-36-generic
Machine: x86_64
pyinfra: v2.8
Executable: /home/user/Projects/Test/venv/bin/pyinfra
Python: 3.11.4 (CPython, GCC 12.3.0)
- How was pyinfra installed (source/pip)?
pip - Include pyinfra-debug.log (if one was created)
none - Consider including output with
-vv
and--debug
.
nothing special in verbose output