XF 2.2 Additional files not being deployed on add-on installation

FoxSecrets

Active member
I've added some directories to my add-on, however is not being deployed on installation.

Am I missing something?

build.json

Code:
{
  "additional_files": [
    "js/My/Addon",
    "styles/My/Addon",
    "data/My/Addon/Images"
  ]
}
 
You've created directories _files/js/My/Addon and _files/styles/My/Addon within your Add-on directory?

Don't ever write any files directly to data, only access this via Flysystem.
 
@Jeremy P can you help me with this issue?

I've got the zip with all js/css files, but do not deploy them on installation.

I did exactly what you mentioned here, but the problem is not with the zip, but with the installation.
 
You've confirmed the zip file has the appropriate layout? Was the add-on built with php cmd.php xf-addon:build-release and does it include all of the files in the hashes.json manifest?

If so, what issue are you experiencing when installing it? Is it refusing to install or does it complete but the files aren't extracted to their expected locations? Can you provide an example I can test myself (either here or via direct message)?
 
Yes, layout, command and hashes, everything ok. And exactly as you said, the installation completes, but the files (js/css) are not placed anywhere, no log errors, no messages.

I have no idea how to give an example, that's a simple installation task. Should this behavior maybe related to development mode or something like that? Just a guess because I see no reason.

zip file:

1715135454623.webp
 
Hundreds if not thousands of add-ons have been packaged and released this way, and I don't remember any similar issues coming up so I'm really not sure what the issue could be. Have you tried installing the add-on on a different XF installation to see if it's an issue with that particular XF instance?

You can provide an example by uploading an add-on archive (a skeleton add-on that exhibits the same issue is fine).
 
I did other tests here and I understood what happened, I'll try to explain.

In development mode, when uninstalling the add-on, I noticed that the files were not deleted. So I configured it to delete the directories when uninstalling the add-on (in setup.php), and when trying to reinstall it, the files no longer existed. But this procedure doesn't show any error messages, it reinstalls normally without errors, so I didn't understand what was happening and this is why I posted here.

In production mode it showed error messages, the files were deleted, but not the directories (the full path remained), but it was not possible to reinstall or delete, as the files did not exist. It got stuck.

Then I realized that I can't delete these directories via the setup file, right? I removed the file deletion process in setup and it is working now, but in production the add-on directory path still remains, even without the files. Is there another way to erase this path or do I have to keep it?
 
You shouldn't need to do manual file or directory removal in your uninstall routines unless the add-on creates files at runtime (user uploads, etc.). XF presents the option to remove all files from hashes.json automatically after uninstallation. I think it will leave any directories even if they are empty, which I guess we could consider adding, but that shouldn't cause any issues in practice.
 
Ok, thanks @Jeremy P. It would be interesting if you could address this behavior, in dev mode display some error message and in prod mode avoid getting stuck.
 
I believe we already show errors and warnings before installation if hashes.json is missing or if the files don't match up, but in development mode you can choose to force the installation anyway. In production, blocking the add-on from being installed is deliberate. In development mode, you should be warned about the situation before being prompted to force installation.

It looks like there's a foot-gun we don't handle well though if that's what you mean: https://xenforo.com/community/threa...-in-add-ons-being-unexpectedly-broken.216966/
 
Back
Top Bottom