Macros stored in my profile cannot suddenly be seen in LO (creating new library doesn´t help)

I cannot use any of my macros in Tools – Macro organizer (they were surelly stored here, NOT in the file) as they can not be seen suddenly. Tens of macros. Without apparent reason.

They are all stored in Users – AppData – Roaming – LibreOffice 4 – User – Basic – Standard. Windows shows them.

I tried: Organizer – Libraries – create new library, Standard2. I was able to find new folder Standard2 in 4 – User – Basic. I copied all macros from Standard to it. If I tried toopen them from macro oganizer in LO – nothing. They couldn´t be run as they couldn´t be even seen.

If I manually create a macro and save it to Standard or Standard2, it is saved properly and I am able to run it. If I check the folder Standard or Standard2, I can find this macro – with plenty of older macos. The clue difference is how LO behaves. The new macros that were manually created can be run. The old can not – despite the fact they are in the same folder. I backuped some macros as text codes separately but I surelly won´t insert tens of them manually. If it was the only way, I would see than I couln´t rely on macros any more (and that would be quite frustrating).

Please, could you give me an advice? I would consider to reinstall LO. But with this behavior of LO, I fear only to do things worse. Even if I create a backup not in LO folders. And I would like to understand why it all appeared to prevent it in the future. There were more updates of LO since I use macros. and I have never expected situation like that.

Thank you.

basic
├── dialog.xlc
├── script.xlc
└── Standard
    ├── dialog.xlb
    ├── Module1.xba
    ├── Module2.xba
    └── script.xlb

This is for Example the correct folder-tree for an basic-folder with the Standard-library with 2 basic-modules (Module1 and Module2)
In your case … do you spot the script.xlc ? if not, create such a file with content:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE library:library PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "library.dtd">
<library:library xmlns:library="http://openoffice.org/2000/library" library:name="Standard" library:readonly="false" library:passwordprotected="false"/>

also …does script.xlb exist ? if not, create it with content:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE library:library PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "library.dtd">
<library:library xmlns:library="http://openoffice.org/2000/library" library:name="Standard" library:readonly="false" library:passwordprotected="false">
 <library:element library:name="Module1"/>
 <library:element library:name="Module2"/>
</library:library>

Thank you. The files script.xlb and script.xlc are where they are supposed to be and look like they are supposed to look. But their content corresponds not to the names of .xba files. In Basic - Standard, I have plenty of macros named not Module1, Module2 - I gave my own names.

So, I tried to change the contents of script.xlb so that some names match - and the macros with these names can be seen and run.

But as I have tens and possible hundreds of macros, I would spend a lot of time to rewrite script.xlb properly. And if I do it, then edit my macros and then this all happens… then it has no sense.

I can´t understand what is going on. I didn´t ranamed the macros and they could be seen earlier. Does it mean there was a file script.xba with the right content and it was gone or replaced? I found a backup of my profile in LibreOffice - 4 (it was created automatically). There is only Module1 in script.xba. And the the date of last change is supposed to be 20. august, also - in the future! Backupped file was changed in the future…

OK… lets try to repair that corrupt basic-tree, store:

from pathlib import Path 
from uno import fileUrlToSystemPath

def fix_basic_tree():
    bas_folder = Path(fileUrlToSystemPath(__file__)).parents[2] / 'basic'
    libraries = list(bas_folder.glob('*/'))
    for lib in libraries:
        with (lib / "script.xlb").open("w") as xlb:
            xlb.write('<?xml version="1.0" encoding="UTF-8"?>\n'
                      '<!DOCTYPE library:library PUBLIC'
                      ' "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "library.dtd">'
                      '<library:library xmlns:library="http://openoffice.org/2000/library"'
                      f'library:name="{lib.name}" '
                      'library:readonly="false" '
                      'library:passwordprotected="false">\n')
            for module in lib.glob('*.xba'):
                xlb.write(f' <library:element library:name="{module.stem}"/>\n')
            xlb.write("</library:library>\n")
    
    with (bas_folder / "script.xlc").open("w") as xlc:
        xlc.write('<?xml version="1.0" encoding="UTF-8"?>\n'
                  '<!DOCTYPE library:libraries PUBLIC'
                  ' "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "libraries.dtd">'
                  '<library:libraries xmlns:library="http://openoffice.org/2000/library" '
                  'xmlns:xlink="http://www.w3.org/1999/xlink">\n')
        for lib in libraries:
            xlc.write(f' <library:library library:name="{lib.name}" '
                      f'xlink:href="$(USER)/basic/{lib.name}/script.xlb/" '
                       'xlink:type="simple" library:link="false"/>\n')
        xlc.write('</library:libraries>')

… to …/Scripts/python/basic_tree_fixer.py
and run fix_basic_tree()