JacquesLucke / blender_vscode

Visual Studio Code extension for Blender development.
MIT License
565 stars 75 forks source link

Blender crashes immediately after launching my addon through blender_vscode #206

Open enenra opened 4 hours ago

enenra commented 4 hours ago
ADDONS_TO_LOAD [{'load_dir': 'd:\\Modding\\Space Engineers\\tools\\Blender\\Add-ons\\space-engineers-utilities\\space-engineers-utilities', 'module_name': 'space-engineers-utilities'}, {'load_dir': 'c:\\Program Files\\Blender Foundation\\Blender 4.2\\4.2\\scripts\\templates_toml', 'module_name': 'templates_toml'}]
DEBUG: new extensions repository "vscode_development" created
Traceback (most recent call last):
  File "c:\Users\enenra\.vscode\extensions\jacqueslucke.blender-development-0.0.24\pythonFiles\launch.py", line 26, in <module>
    blender_vscode.startup(
  File "c:\Users\enenra\.vscode\extensions\jacqueslucke.blender-development-0.0.24\pythonFiles\include\blender_vscode\__init__.py", line 26, in startup
    path_mappings = load_addons.setup_addon_links(addons_to_load)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "c:\Users\enenra\.vscode\extensions\jacqueslucke.blender-development-0.0.24\pythonFiles\include\blender_vscode\load_addons.py", line 38, in setup_addon_links
    load_path = _link_addon_or_extension(addon_info)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "c:\Users\enenra\.vscode\extensions\jacqueslucke.blender-development-0.0.24\pythonFiles\include\blender_vscode\load_addons.py", line 64, in _link_addon_or_extension
    if addon_has_bl_info(addon_info.load_dir) and is_in_any_addon_directory(addon_info.load_dir):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "c:\Users\enenra\.vscode\extensions\jacqueslucke.blender-development-0.0.24\pythonFiles\include\blender_vscode\utils.py", line 19, in addon_has_bl_info
    with open(addon_dir / "__init__.py") as init_addon_file:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: 'c:\\Program Files\\Blender Foundation\\Blender 4.2\\4.2\\scripts\\templates_toml\\__init__.py'
 *  Terminal will be reused by tasks, press any key to close it. 

Win10, VSC in normal mode (but admin has the same issue)

My addon: https://github.com/enenra/space-engineers-utilities

Note that this issue appears only on my desktop PC, it's fine on my laptop. It only appears with Blender 4.2 - older versions of Blender are fine, though Add-on not loaded: "templates_toml", cause: appears - nothing after the colon.

My addon is not in a templates_toml-folder. It's where it's supposed to be - in its own folder. image

Mateusz-Grzelinski commented 3 hours ago

uhh, in this logic I forgot to respect setting called blender.addon.moduleName and I thought the error (file that not exesits) will be catch by uper function in call stack. addon_has_bl_info needs to be improved.

Are you using the setting blender.addon.moduleName in you current config? i am asking just to be sure

Mateusz-Grzelinski commented 3 hours ago

when you open the VS code directly inside folder space-engineers-utilities it should work.

enenra commented 2 hours ago

uhh, in this logic I forgot to respect setting called blender.addon.moduleName and I thought the error (file that not exesits) will be catch by uper function in call stack. addon_has_bl_info needs to be improved.

Are you using the setting blender.addon.moduleName in you current config? i am asking just to be sure

I'm not using blender.addon.moduleName, no. Unsure where / how I would use that?

And how would I do this with the directory inside the addon folder? My workspace file is in there so it should always be that directory I think.

Mateusz-Grzelinski commented 2 hours ago

I am basically asking you to paste all blender related VS code settings that you use.

enenra commented 2 hours ago
{
    "python.languageServer": "Pylance",
    "blender.executables": [
        {
            "path": "c:\\Program Files\\Blender Foundation\\Blender 4.1\\blender.exe",
            "name": "",
            "isDebug": false
        },
        {
            "path": "c:\\Program Files\\Blender Foundation\\Blender 4.2\\blender.exe",
            "name": "",
            "isDebug": false
        }
    ],
}

This is my entire settings.json - admin edited to relevant parts. I don't think I have any specific blender settings aside from the path itself.

Mateusz-Grzelinski commented 1 hour ago

this is the part when I say:

  1. how on did you got that log...
  2. it works for me... obraz
enenra commented 1 hour ago

Yes, as I stated in the initial post it only happens on my desktop PC. It works fine on my laptop.

I get the error when hitting Ctrl+Shift+P > Start Blender > 4.2 . Then Blender briefly comes up and then closes again and I get the output from above.

I have tried reinstalling the plugin, as well as Blender itself.

Mateusz-Grzelinski commented 1 hour ago

I hope you sent me the config from the problematic PC? xD

sry, missed that, I am tired today.

enenra commented 1 hour ago

Of course.

enenra commented 1 hour ago

One other thing I should note, I forgot to mention it, is that initially I got a different error. Initially I got a straight up Blender crash with a Blender crash log. An access violation:

blender.crash.txt

I was trying to get it to work for a couple hours and what finally made a difference was to edit the Blender code and comment out the bit where it calls the function that causes the crash:

  File "c:\Program Files\Blender Foundation\Blender 4.2\4.2\scripts\addons_core\bl_pkg\bl_extension_ui.py", line 453 in addons_panel_draw_items

Blender still then crashed on startup but differently, and that is where the above stuff started. Sorry, should've started with that.

Mateusz-Grzelinski commented 1 hour ago
  1. try deleting the links in blender config - let vs code recreate them.
  2. try running the vs code with
    "blender.environmentVariables": {
    "BLENDER_USER_RESOURCES": "./blender_vscode_development" // changes folder for addons, extensions, modules, config
    },

    see readme

I want to make sure that blender config is ok - those are various ways of cleanup

Mateusz-Grzelinski commented 1 hour ago

One other thing I should note, I forgot to mention it, is that initially I got a different error. Initially I got a straight up Blender crash with a Blender crash log. An access violation:

blender.crash.txt

I was trying to get it to work for a couple hours and what finally made a difference was to edit the Blender code and comment out the bit where it calls the function that causes the crash:

  File "c:\Program Files\Blender Foundation\Blender 4.2\4.2\scripts\addons_core\bl_pkg\bl_extension_ui.py", line 453 in addons_panel_draw_items

Blender still then crashed on startup but differently, and that is where the above stuff started. Sorry, should've started with that.

this might be #192 - I am noticing that downgrading wergzeug to 3.0.3 still causes the issues to appear, or my current fix is ineffective... the proper fix is coming in #201

Sorry about your hours of debugging, I know how annoying this is, but it is not obvious to fix without creating new problems. A review is needed, the implementattion is there.

enenra commented 1 hour ago

Yes it definitely sounds like #191 though I get it on startup, not just when opening preferences.

Mateusz-Grzelinski commented 1 hour ago

if you dig ver very deep into developers formu you will find that the issue is import multiprocessing - so if you import it in any dependencies you blender will hard crash.

Mateusz-Grzelinski commented 1 hour ago

btw if you use - in your path names your addon will not work nice with extensions

enenra commented 1 hour ago

if you dig ver very deep into developers formu you will find that the issue is import multiprocessing - so if you import it in any dependencies you blender will hard crash.

I've removed that since I wasn't using it anyway. But the crash with addon_utils is still there. I guess I somehow now have to get back to the access violation crash?

And regarding the - yeah, idk if that's easy to change at this point though. Unsure if I will change it to an extension anyway atm.

Mateusz-Grzelinski commented 1 hour ago

My head is not working today, need to sleep. Jus make sure that wrrgzeug dependency does not contain string multiprocessing (v3.0.4)

enenra commented 1 hour ago

Okay, I think I've done that since I only import it in a single file and it was unused there.

What I'm unsure about is what I should be doing now? Is this something you can fix on your end in a VSC plugin update? Or should I try to get back to the access violation error?

And please don't stay up on my behalf. An answer can wait till tomorrow. 👍