Is there a way to reprovision a Trellis/Lima project?

On the Vagrant/VirtualBox version of Trellis if something went pear shaped I would just reprovision the server and start fresh. I’ve had some issues with the Lima version where that would be a handy feature, but I’ve had to delete the VM entirely and start fresh, losing any DB changes along with it. Maybe I’m misunderstanding something about the way this works, but in my mind being able to reprovision the server without nuking the whole machine would be beneficial. As of right now when I run trellis vm start after a failed attempt at creating the build, it simply says that the machine is already running/ready.

Can you explain what these failed attempts are? As in, how or why did they fail?

You can reprovision any server and a Lima VM is no different. If the instance/VM is actually running, trellis provision development should work the same as it would for Vagrant.

1 Like

Oh awesome! I guess I did fundamentally misunderstand something. I thought the provision commands were specific to the Vagrant machines.

The failures happened in like a dozen different places, I’ve been meaning to create a list to bring to the discourse but I haven’t got around to it yet. I do now have it working consistently if I restart my machine before running trellis vm start, but without the restart it pretty much never works (on an M2 machine specifically). I’m about to test the reprovisioning commands and will start a doc of errors also. Thanks again.

Does it hang waiting for the SSH requirement? That’s been the most common issue so far.

Okay so I made a couple of attempts to run trellis vm start on fresh projects to see what error messages I got. Both times I did get errors, and both times upon restarting the machine the command worked properly. Apologies in advance for the giant wall of error text, I’m not savvy enough on this end of things to know what’s important here.

First attempt:

TASK [php : Install PHP and extensions] ****************************************
changed: [default] => (item=php8.1-bcmath)
changed: [default] => (item=php8.1-cli)
changed: [default] => (item=php8.1-curl)
changed: [default] => (item=php8.1-dev)
changed: [default] => (item=php8.1-fpm)
changed: [default] => (item=php8.1-imagick)
changed: [default] => (item=php8.1-intl)
changed: [default] => (item=php8.1-mbstring)
changed: [default] => (item=php8.1-mysql)
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: FileNotFoundError: [Errno 2] No usable temporary directory found in ['/tmp', '/var/tmp', '/usr/tmp', '/home/matthew.linux']
failed: [default] (item=php8.1-xml) => {"ansible_loop_var": "item", "changed": false, "item": {"key": "php8.1-xml", "value": "present"}, "module_stderr": "Traceback (most recent call last):\n  File \"<stdin>\", line 107, in <module>\n  File \"<stdin>\", line 92, in _ansiballz_main\n  File \"/usr/lib/python3.10/tempfile.py\", line 496, in mkdtemp\n    prefix, suffix, dir, output_type = _sanitize_params(prefix, suffix, dir)\n  File \"/usr/lib/python3.10/tempfile.py\", line 265, in _sanitize_params\n    dir = gettempdir()\n  File \"/usr/lib/python3.10/tempfile.py\", line 438, in gettempdir\n    return _os.fsdecode(_gettempdir())\n  File \"/usr/lib/python3.10/tempfile.py\", line 431, in _gettempdir\n    tempdir = _get_default_tempdir()\n  File \"/usr/lib/python3.10/tempfile.py\", line 362, in _get_default_tempdir\n    raise FileNotFoundError(_errno.ENOENT,\nFileNotFoundError: [Errno 2] No usable temporary directory found in ['/tmp', '/var/tmp', '/usr/tmp', '/home/matthew.linux']\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: FileNotFoundError: [Errno 2] No usable temporary directory found in ['/tmp', '/var/tmp', '/usr/tmp', '/home/matthew.linux']
failed: [default] (item=php8.1-xmlrpc) => {"ansible_loop_var": "item", "changed": false, "item": {"key": "php8.1-xmlrpc", "value": "present"}, "module_stderr": "Traceback (most recent call last):\n  File \"<stdin>\", line 107, in <module>\n  File \"<stdin>\", line 92, in _ansiballz_main\n  File \"/usr/lib/python3.10/tempfile.py\", line 496, in mkdtemp\n    prefix, suffix, dir, output_type = _sanitize_params(prefix, suffix, dir)\n  File \"/usr/lib/python3.10/tempfile.py\", line 265, in _sanitize_params\n    dir = gettempdir()\n  File \"/usr/lib/python3.10/tempfile.py\", line 438, in gettempdir\n    return _os.fsdecode(_gettempdir())\n  File \"/usr/lib/python3.10/tempfile.py\", line 431, in _gettempdir\n    tempdir = _get_default_tempdir()\n  File \"/usr/lib/python3.10/tempfile.py\", line 362, in _get_default_tempdir\n    raise FileNotFoundError(_errno.ENOENT,\nFileNotFoundError: [Errno 2] No usable temporary directory found in ['/tmp', '/var/tmp', '/usr/tmp', '/home/matthew.linux']\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: FileNotFoundError: [Errno 2] No usable temporary directory found in ['/tmp', '/var/tmp', '/usr/tmp', '/home/matthew.linux']
failed: [default] (item=php8.1-zip) => {"ansible_loop_var": "item", "changed": false, "item": {"key": "php8.1-zip", "value": "present"}, "module_stderr": "Traceback (most recent call last):\n  File \"<stdin>\", line 107, in <module>\n  File \"<stdin>\", line 92, in _ansiballz_main\n  File \"/usr/lib/python3.10/tempfile.py\", line 496, in mkdtemp\n    prefix, suffix, dir, output_type = _sanitize_params(prefix, suffix, dir)\n  File \"/usr/lib/python3.10/tempfile.py\", line 265, in _sanitize_params\n    dir = gettempdir()\n  File \"/usr/lib/python3.10/tempfile.py\", line 438, in gettempdir\n    return _os.fsdecode(_gettempdir())\n  File \"/usr/lib/python3.10/tempfile.py\", line 431, in _gettempdir\n    tempdir = _get_default_tempdir()\n  File \"/usr/lib/python3.10/tempfile.py\", line 362, in _get_default_tempdir\n    raise FileNotFoundError(_errno.ENOENT,\nFileNotFoundError: [Errno 2] No usable temporary directory found in ['/tmp', '/var/tmp', '/usr/tmp', '/home/matthew.linux']\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}

RUNNING HANDLER [common : restart journald] ************************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: FileNotFoundError: [Errno 2] No usable temporary directory found in ['/tmp', '/var/tmp', '/usr/tmp', '/home/matthew.linux']
fatal: [default]: FAILED! => {"changed": false, "module_stderr": "Traceback (most recent call last):\n  File \"<stdin>\", line 107, in <module>\n  File \"<stdin>\", line 92, in _ansiballz_main\n  File \"/usr/lib/python3.10/tempfile.py\", line 496, in mkdtemp\n    prefix, suffix, dir, output_type = _sanitize_params(prefix, suffix, dir)\n  File \"/usr/lib/python3.10/tempfile.py\", line 265, in _sanitize_params\n    dir = gettempdir()\n  File \"/usr/lib/python3.10/tempfile.py\", line 438, in gettempdir\n    return _os.fsdecode(_gettempdir())\n  File \"/usr/lib/python3.10/tempfile.py\", line 431, in _gettempdir\n    tempdir = _get_default_tempdir()\n  File \"/usr/lib/python3.10/tempfile.py\", line 362, in _get_default_tempdir\n    raise FileNotFoundError(_errno.ENOENT,\nFileNotFoundError: [Errno 2] No usable temporary directory found in ['/tmp', '/var/tmp', '/usr/tmp', '/home/matthew.linux']\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}

Second attempt:

TASK [ntp : Ensure NTP package is installed.] **********************************
fatal: [default]: FAILED! => {"cache_update_time": 1680740955, "cache_updated": false, "changed": false, "msg": "'/usr/bin/apt-get -y -o \"Dpkg::Options::=--force-confdef\" -o \"Dpkg::Options::=--force-confold\"       install 'ntp=1:4.2.8p15+dfsg-1ubuntu2'' failed: touch: cannot touch '/var/lib/update-notifier/dpkg-run-stamp': Read-only file system\nE: Sub-process /usr/bin/dpkg returned an error code (2)\nW: Problem unlinking the file /var/cache/apt/pkgcache.bin - pkgDPkgPM::Go (30: Read-only file system)\n", "rc": 100, "stderr": "touch: cannot touch '/var/lib/update-notifier/dpkg-run-stamp': Read-only file system\nE: Sub-process /usr/bin/dpkg returned an error code (2)\nW: Problem unlinking the file /var/cache/apt/pkgcache.bin - pkgDPkgPM::Go (30: Read-only file system)\n", "stderr_lines": ["touch: cannot touch '/var/lib/update-notifier/dpkg-run-stamp': Read-only file system", "E: Sub-process /usr/bin/dpkg returned an error code (2)", "W: Problem unlinking the file /var/cache/apt/pkgcache.bin - pkgDPkgPM::Go (30: Read-only file system)"], "stdout": "Reading package lists...\nBuilding dependency tree...\nReading state information...\nThe following additional packages will be installed:\n  libevent-pthreads-2.1-7 libopts25 sntp\nSuggested packages:\n  ntp-doc\nThe following packages will be REMOVED:\n  systemd-timesyncd\nThe following NEW packages will be installed:\n  libevent-pthreads-2.1-7 libopts25 ntp sntp\n0 upgraded, 4 newly installed, 1 to remove and 9 not upgraded.\nNeed to get 852 kB of archives.\nAfter this operation, 2281 kB of additional disk space will be used.\nGet:1 http://ports.ubuntu.com/ubuntu-ports jammy/main arm64 libevent-pthreads-2.1-7 arm64 2.1.12-stable-1build3 [7588 B]\nGet:2 http://ports.ubuntu.com/ubuntu-ports jammy/universe arm64 libopts25 arm64 1:5.18.16-4 [55.8 kB]\nGet:3 http://ports.ubuntu.com/ubuntu-ports jammy/universe arm64 ntp arm64 1:4.2.8p15+dfsg-1ubuntu2 [721 kB]\nGet:4 http://ports.ubuntu.com/ubuntu-ports jammy/universe arm64 sntp arm64 1:4.2.8p15+dfsg-1ubuntu2 [67.4 kB]\nFetched 852 kB in 1s (837 kB/s)\n(Reading database ... \r(Reading database ... 5%\r(Reading database ... 10%\r(Reading database ... 15%\r(Reading database ... 20%\r(Reading database ... 25%\r(Reading database ... 30%\r(Reading database ... 35%\r(Reading database ... 40%\r(Reading database ... 45%\r(Reading database ... 50%\r(Reading database ... 55%\r(Reading database ... 60%\r(Reading database ... 65%\r(Reading database ... 70%\r(Reading database ... 75%\r(Reading database ... 80%\r(Reading database ... 85%\r(Reading database ... 90%\r(Reading database ... 95%\r(Reading database ... 100%\r(Reading database ... 75037 files and directories currently installed.)\r\nRemoving systemd-timesyncd (249.11-0ubuntu3.7) ...\r\ndpkg: unrecoverable fatal error, aborting:\r\n unable to truncate for updated status of 'systemd-timesyncd': Read-only file system\r\n", "stdout_lines": ["Reading package lists...", "Building dependency tree...", "Reading state information...", "The following additional packages will be installed:", "  libevent-pthreads-2.1-7 libopts25 sntp", "Suggested packages:", "  ntp-doc", "The following packages will be REMOVED:", "  systemd-timesyncd", "The following NEW packages will be installed:", "  libevent-pthreads-2.1-7 libopts25 ntp sntp", "0 upgraded, 4 newly installed, 1 to remove and 9 not upgraded.", "Need to get 852 kB of archives.", "After this operation, 2281 kB of additional disk space will be used.", "Get:1 http://ports.ubuntu.com/ubuntu-ports jammy/main arm64 libevent-pthreads-2.1-7 arm64 2.1.12-stable-1build3 [7588 B]", "Get:2 http://ports.ubuntu.com/ubuntu-ports jammy/universe arm64 libopts25 arm64 1:5.18.16-4 [55.8 kB]", "Get:3 http://ports.ubuntu.com/ubuntu-ports jammy/universe arm64 ntp arm64 1:4.2.8p15+dfsg-1ubuntu2 [721 kB]", "Get:4 http://ports.ubuntu.com/ubuntu-ports jammy/universe arm64 sntp arm64 1:4.2.8p15+dfsg-1ubuntu2 [67.4 kB]", "Fetched 852 kB in 1s (837 kB/s)", "(Reading database ... ", "(Reading database ... 5%", "(Reading database ... 10%", "(Reading database ... 15%", "(Reading database ... 20%", "(Reading database ... 25%", "(Reading database ... 30%", "(Reading database ... 35%", "(Reading database ... 40%", "(Reading database ... 45%", "(Reading database ... 50%", "(Reading database ... 55%", "(Reading database ... 60%", "(Reading database ... 65%", "(Reading database ... 70%", "(Reading database ... 75%", "(Reading database ... 80%", "(Reading database ... 85%", "(Reading database ... 90%", "(Reading database ... 95%", "(Reading database ... 100%", "(Reading database ... 75037 files and directories currently installed.)", "Removing systemd-timesyncd (249.11-0ubuntu3.7) ...", "dpkg: unrecoverable fatal error, aborting:", " unable to truncate for updated status of 'systemd-timesyncd': Read-only file system"]}

RUNNING HANDLER [common : restart journald] ************************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: FileNotFoundError: [Errno 2] No usable temporary directory found in ['/tmp', '/var/tmp', '/usr/tmp', '/home/matthew.linux']
fatal: [default]: FAILED! => {"changed": false, "module_stderr": "Traceback (most recent call last):\n  File \"<stdin>\", line 107, in <module>\n  File \"<stdin>\", line 92, in _ansiballz_main\n  File \"/usr/lib/python3.10/tempfile.py\", line 496, in mkdtemp\n    prefix, suffix, dir, output_type = _sanitize_params(prefix, suffix, dir)\n  File \"/usr/lib/python3.10/tempfile.py\", line 265, in _sanitize_params\n    dir = gettempdir()\n  File \"/usr/lib/python3.10/tempfile.py\", line 438, in gettempdir\n    return _os.fsdecode(_gettempdir())\n  File \"/usr/lib/python3.10/tempfile.py\", line 431, in _gettempdir\n    tempdir = _get_default_tempdir()\n  File \"/usr/lib/python3.10/tempfile.py\", line 362, in _get_default_tempdir\n    raise FileNotFoundError(_errno.ENOENT,\nFileNotFoundError: [Errno 2] No usable temporary directory found in ['/tmp', '/var/tmp', '/usr/tmp', '/home/matthew.linux']\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}

Hopefully something in there is helpful!

Very strange. I’m assuming both issues are related.

Are your Trellis projects on your main macOS hard drive? They aren’t on an external drive or any kind of different setup?

Yeah the projects are on the main macOS drive. There’s nothing unusual about the set up, at least nothing I can think of. The only thing that could potentially be relevant is that I originally had some problems because I forgot that I changed my global python version to 2.7, but I changed it back to the latest and still get these errors. So maybe I messed something up in that process? Seems pretty simple though so I assume it’s unrelated.

From googling, Python will error with No usable temporary directory found for read-only filesystems, so that’s consistent with the other error message.

Can you run the following commands on the VM (trellis vm shell) and paste the output here please:

  • df -h
  • df -i
  • cat /etc/fstab

Sure, here’s what I got from running those commands:

df -h
Filesystem      Size  Used Avail Use% Mounted on
tmpfs           392M 1004K  391M   1% /run
/dev/vda1        97G  2.0G   95G   3% /
tmpfs           2.0G     0  2.0G   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
/dev/vda15       98M  6.3M   92M   7% /boot/efi
mount0          229G  182G   47G  80% /srv/www/test.com/current
/dev/vdb         36M   36M     0 100% /mnt/lima-cidata
tmpfs           392M  4.0K  392M   1% /run/user/501

df -i
Filesystem        Inodes   IUsed     IFree IUse% Mounted on
tmpfs             501198     664    500534    1% /run
/dev/vda1       12966400   84467  12881933    1% /
tmpfs             501198       1    501197    1% /dev/shm
tmpfs             501198       3    501195    1% /run/lock
/dev/vda15             0       0         0     - /boot/efi
mount0         493479715 2356915 491122800    1% /srv/www/test.com/current
/dev/vdb               0       0         0     - /mnt/lima-cidata
tmpfs             100239      25    100214    1% /run/user/501

cat /etc/fstab
LABEL=cloudimg-rootfs	/	 ext4	discard,errors=remount-ro	0 1
LABEL=UEFI	/boot/efi	vfat	umask=0077	0 1
mount0	/srv/www/test.com/current	virtiofs	rw,nofail,comment=cloudconfig	0	0

Thanks again for your help on this! I’m assuming this line is potentially an issue?

/dev/vdb         36M   36M     0 100% /mnt/lima-cidata
1 Like

No, I don’t think that’s an issue. That’s just for metadata Lima uses internally but nothing should be writing to it after boot.

I was more interested in the mount for /srv/www/test.com/current, but those all look fine:

  • there’s free space
  • there’s free inodes
  • it’s mounted as rw (read-write, as it should be)

But something is causing Python to detect it’s read-only, or out of space, or something like that :thinking:

I’m finding other people who have had similar problems with Lima online, but it’s all older versions and issues which don’t seem to apply exactly to the Trellis set up. Frustrating.

Lots of suggesting to change the mountType to virtiofs (which Trellis already uses), and also explicitly declaring the mount writable, (which Trellis also does, obviously). It seems, at least on older versions of Lima, that you can’t change mounts or mount types after the VM is created, but as far as I can tell that’s also not happening here.

I’m about out of ideas. At least it works after a restart, but that’s for sure kind of a drag to have to do every time.

Getting the same error when trying to reprovision PHP. Adding my info for an additional data point.

TASK [php : Add PHP PPA] *******************************************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: FileNotFoundError: [Errno 2] No usable temporary directory found in ['/tmp', '/var/tmp', '/usr/tmp', '/home/user.linux']
fatal: [default]: FAILED! => {"changed": false, "module_stderr": "Traceback (most recent call last):\n  File \"<stdin>\", line 107, in <module>\n  File \"<stdin>\", line 92, in _ansiballz_main\n  File \"/usr/lib/python3.10/tempfile.py\", line 496, in mkdtemp\n    prefix, suffix, dir, output_type = _sanitize_params(prefix, suffix, dir)\n  File \"/usr/lib/python3.10/tempfile.py\", line 265, in _sanitize_params\n    dir = gettempdir()\n  File \"/usr/lib/python3.10/tempfile.py\", line 438, in gettempdir\n    return _os.fsdecode(_gettempdir())\n  File \"/usr/lib/python3.10/tempfile.py\", line 431, in _gettempdir\n    tempdir = _get_default_tempdir()\n  File \"/usr/lib/python3.10/tempfile.py\", line 362, in _get_default_tempdir\n    raise FileNotFoundError(_errno.ENOENT,\nFileNotFoundError: [Errno 2] No usable temporary directory found in ['/tmp', '/var/tmp', '/usr/tmp', '/home/user.linux']\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}
df -h
Filesystem      Size  Used Avail Use% Mounted on
tmpfs           392M  1.1M  391M   1% /run
/dev/vda1        97G  2.8G   94G   3% /
tmpfs           2.0G     0  2.0G   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
mount0          927G  673G  254G  73% /srv/www/sub.domain.tld/current
/dev/vda15       98M  6.3M   92M   7% /boot/efi
/dev/vdb         36M   36M     0 100% /mnt/lima-cidata
tmpfs           392M  4.0K  392M   1% /run/user/501
df -i
Filesystem         Inodes   IUsed      IFree IUse% Mounted on
tmpfs              501206     678     500528    1% /run
/dev/vda1        12966400   89039   12877361    1% /
tmpfs              501206       1     501205    1% /dev/shm
tmpfs              501206       3     501203    1% /run/lock
mount0         2662963796 5992916 2656970880    1% /srv/www/sub.domain.tld/current
/dev/vda15              0       0          0     - /boot/efi
/dev/vdb                0       0          0     - /mnt/lima-cidata
tmpfs              100241      25     100216    1% /run/user/501
LABEL=cloudimg-rootfs	/	 ext4	discard,errors=remount-ro	0 1
LABEL=UEFI	/boot/efi	vfat	umask=0077	0 1
mount0	/srv/www/domain.tld/current	virtiofs	rw,nofail,comment=cloudconfig	0	0

If you run into this again (or now), please do the following:

  1. limactl shell <instance name> (or trellis vm shell)
  2. Start a python console: python3
  3. Type this in
import tempfile
tempfile.TemporaryDirectory()
  1. Provide the output please

I’m not sure if the directory matters, but please run that twice in from two dirs:

  1. /srv/www/<site>/current
  2. /etc/

I just want to make sure this is happening in pure Python outside of Ansible and Trellis.

In my case I get <TemporaryDirectory '/tmp/tmp7s1cgg4a'>, with varying ID strings in both folders.

Just to confirm, provisioning fails right now? Or is it working?

Yeah it’s failing. Here’s the error message I get when I just tried again:

fatal: [default]: FAILED! => {"ansible_facts": {}, "changed": false, "failed_modules": {"ansible.legacy.setup": {"ansible_facts": {"discovered_interpreter_python": "/usr/bin/python3"}, "exception": "Traceback (most recent call last):\n  File \"<stdin>\", line 107, in <module>\n  File \"<stdin>\", line 99, in _ansiballz_main\n  File \"<stdin>\", line 47, in invoke_module\n  File \"/usr/lib/python3.10/runpy.py\", line 224, in run_module\n    return _run_module_code(code, init_globals, run_name, mod_spec)\n  File \"/usr/lib/python3.10/runpy.py\", line 96, in _run_module_code\n    _run_code(code, mod_globals, init_globals,\n  File \"/usr/lib/python3.10/runpy.py\", line 86, in _run_code\n    exec(code, run_globals)\n  File \"/tmp/ansible_ansible.legacy.setup_payload_agu18zd2/ansible_ansible.legacy.setup_payload.zip/ansible/modules/setup.py\", line 178, in <module>\n  File \"/tmp/ansible_ansible.legacy.setup_payload_agu18zd2/ansible_ansible.legacy.setup_payload.zip/ansible/module_utils/facts/__init__.py\", line 34, in <module>\n  File \"/tmp/ansible_ansible.legacy.setup_payload_agu18zd2/ansible_ansible.legacy.setup_payload.zip/ansible/module_utils/facts/compat.py\", line 33, in <module>\n  File \"/tmp/ansible_ansible.legacy.setup_payload_agu18zd2/ansible_ansible.legacy.setup_payload.zip/ansible/module_utils/facts/default_collectors.py\", line 33, in <module>\n  File \"/tmp/ansible_ansible.legacy.setup_payload_agu18zd2/ansible_ansible.legacy.setup_payload.zip/ansible/module_utils/facts/collector.py\", line 38, in <module>\n  File \"/tmp/ansible_ansible.legacy.setup_payload_agu18zd2/ansible_ansible.legacy.setup_payload.zip/ansible/module_utils/facts/timeout.py\", line 20, in <module>\n  File \"/usr/lib/python3.10/multiprocessing/pool.py\", line 30, in <module>\n    from .connection import wait\n  File \"/usr/lib/python3.10/multiprocessing/connection.py\", line 21, in <module>\n    import _multiprocessing\nImportError: /usr/lib/python3.10/lib-dynload/_multiprocessing.cpython-310-aarch64-linux-gnu.so: undefined symbol: _PyArg_CheckPositional\n", "failed": true, "module_stderr": "Traceback (most recent call last):\n  File \"<stdin>\", line 107, in <module>\n  File \"<stdin>\", line 99, in _ansiballz_main\n  File \"<stdin>\", line 47, in invoke_module\n  File \"/usr/lib/python3.10/runpy.py\", line 224, in run_module\n    return _run_module_code(code, init_globals, run_name, mod_spec)\n  File \"/usr/lib/python3.10/runpy.py\", line 96, in _run_module_code\n    _run_code(code, mod_globals, init_globals,\n  File \"/usr/lib/python3.10/runpy.py\", line 86, in _run_code\n    exec(code, run_globals)\n  File \"/tmp/ansible_ansible.legacy.setup_payload_agu18zd2/ansible_ansible.legacy.setup_payload.zip/ansible/modules/setup.py\", line 178, in <module>\n  File \"/tmp/ansible_ansible.legacy.setup_payload_agu18zd2/ansible_ansible.legacy.setup_payload.zip/ansible/module_utils/facts/__init__.py\", line 34, in <module>\n  File \"/tmp/ansible_ansible.legacy.setup_payload_agu18zd2/ansible_ansible.legacy.setup_payload.zip/ansible/module_utils/facts/compat.py\", line 33, in <module>\n  File \"/tmp/ansible_ansible.legacy.setup_payload_agu18zd2/ansible_ansible.legacy.setup_payload.zip/ansible/module_utils/facts/default_collectors.py\", line 33, in <module>\n  File \"/tmp/ansible_ansible.legacy.setup_payload_agu18zd2/ansible_ansible.legacy.setup_payload.zip/ansible/module_utils/facts/collector.py\", line 38, in <module>\n  File \"/tmp/ansible_ansible.legacy.setup_payload_agu18zd2/ansible_ansible.legacy.setup_payload.zip/ansible/module_utils/facts/timeout.py\", line 20, in <module>\n  File \"/usr/lib/python3.10/multiprocessing/pool.py\", line 30, in <module>\n    from .connection import wait\n  File \"/usr/lib/python3.10/multiprocessing/connection.py\", line 21, in <module>\n    import _multiprocessing\nImportError: /usr/lib/python3.10/lib-dynload/_multiprocessing.cpython-310-aarch64-linux-gnu.so: undefined symbol: _PyArg_CheckPositional\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}}, "msg": "The following modules failed to execute: ansible.legacy.setup\n"}

Sorry lost track of this… and that’s a surprising result I didn’t expect :thinking:

Actually, it might not be enough to just run tempfile.TemporaryDirectory(). Using the same steps as above, can someone try this instead please:

import tempfile
tempfile.mkdtemp()

If it works it will return the path of a tmp folder.

I had the “no usable temp directory” issue today, and on a whim I tried upgrading Lima with brew upgrade lima and it seems to have resolved the issue, at least temporarily.

If I can find any consistency in when it does and doesn’t work I’ll write back.

1 Like

Leaving this here in the hope that it’s still useful. When I ran into this issue, tempfile.mkdtemp() returned a path in /srv/www/<site>/current, but it failed in /etc:

>>> tempfile.mkdtemp()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.10/tempfile.py", line 496, in mkdtemp
    prefix, suffix, dir, output_type = _sanitize_params(prefix, suffix, dir)
  File "/usr/lib/python3.10/tempfile.py", line 265, in _sanitize_params
    dir = gettempdir()
  File "/usr/lib/python3.10/tempfile.py", line 438, in gettempdir
    return _os.fsdecode(_gettempdir())
  File "/usr/lib/python3.10/tempfile.py", line 431, in _gettempdir
    tempdir = _get_default_tempdir()
  File "/usr/lib/python3.10/tempfile.py", line 362, in _get_default_tempdir
    raise FileNotFoundError(_errno.ENOENT,
FileNotFoundError: [Errno 2] No usable temporary directory found in ['/tmp', '/var/tmp', '/usr/tmp', '/etc']

For context, I was trying to re-provision after doing lima factory-reset. Upgrading lima didn’t help, since I already had the latest version. In my case the issue went away after a reboot.

2 Likes

@swalkinshaw Here is what I see once I start getting read only file system errors. The issue seems to be the tmp dir is relative to my site install instead of /tmp or the like

python3
Python 3.10.6 (main, Mar 10 2023, 10:55:28) [GCC 11.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tempfile
>>> tempfile.TemporaryDirectory()
<TemporaryDirectory '/srv/www/example.com/current/tmp8lskhwcv'>
>>> tempfile.mkdtemp()
'/srv/www/example.com/current/tmpfg4w_i_a'
>>>

Note that when the file system isn’t in a readonly state I see a differnt path, one that isn’t relative to my install

python3
Python 3.10.6 (main, Mar 10 2023, 10:55:28) [GCC 11.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tempfile
>>> tempfile.TemporaryDirectory()
<TemporaryDirectory '/tmp/tmps_fu1e0q'>
>>> tempfile.mkdtemp()
'/tmp/tmpllb5g32f'

1 Like