I've run into this before and I don't remember what I did to make it stop. Something changes in some file - though not any normally tracked in version control - and direct downloads stop working. On /admin/config/system/updates, I get a line about "Updating modules, themes, and layouts requires FTP access to your server." Literally just a few hours ago this was working in the more normal way. Everything is running on my local machine, the site runs in a Docker container. I don't need to use FTP to make changes to the code.

Why is this happening and what can I do to fix it?

I couldn't find the posts about this problem that I thought would be here, searching on FTP or download. Sorry for the no-doubt duplication, but maybe this will be easier for other people to find.

Comments

I put some debugging lines in installer_manager_local_transfers_allowed() and the problem went away. I assume maybe it was about file ownership of the temporary directory? But I can't recreate the issue on purpose now.

Ah, I saw that first one was about SFTP vs FTP and didn't keep reading. That's the previous issue I was looking for, thanks.

I work on the code files directly from the host machine, not in an ssh session into the container, so I think I was looking at the directory ownership in the wrong place. Assuming that since this code is being run by the web server, it's what's true inside the container where the server is running that matters. Permissions are trickier. I'm not 100% on the inner workings, but I think that there is some syncing going on, so that what I see on the outside may not match what's there inside.

I'll know to look inside the installer code if it happens again. The symlink stuff is not involved.

OK, it happened again, and the problem is that the owner of conf_path() - which has a value of "." - is root (uid 0), while the owner of the temporary file created by installer_manager_local_transfers_allowed() is www-data, the Apache process. This is probably related to Docker particularly, since all of this installation is inside a mounted volume. If I recursively change the owner of the installation files to www-data, it works normally. The owner is probably changing either when file changes are sync'd from the host machine to the volume and/or when the container gets rebuilt.