JacquesLucke / blender_vscode

Visual Studio Code extension for Blender development.
MIT License
557 stars 76 forks source link

Using symlinks to hook up the project to Blender is a VERY bad idea. #49

Open Zyl9393 opened 5 years ago

Zyl9393 commented 5 years ago

So I have been happily using the extension for a while, when I just encountered a big issue. After some development, I decided to write a script which bundles my addon as a .zip file which can be loaded in Blender. As I go to Preferences -> Addons in Blender, I notice by addon is still in there, probably from all my invocations of Ctrl+Shift+P -> Blender: Start. So I click Remove, so that I can then add it again using the .zip file. Then, due to what I can, in retrospective, only phrase as a stroke of SHEER LUCK, Blender gets a permission error trying to delete a file. I think "Huh? What's this?".

PermissionError: [WinError 5] Access is denied: 'C:\\Users\\Zyl\\AppData\\Roaming\\Blender Foundation\\Blender\\2.80\\scripts\\addons\\mouse_strafing\\.git\\objects\\1c\\36adfaa8701d66ad8189eb9868acda6ba8d801'

Wait... is that my git repository? I check the addon installation in the user addon folder, to find that all this time my addon has been hooked into Blender using a symbolic link, and I almost unknowingly deleted 2 weeks of work by the click of a button. WHAT. Luckily, only the project history (.git-folder) has been destroyed. Symlinking the entire development directory into production is probably the most mental thing I have come across this year. Please reconsider this design decision.

JacquesLucke commented 5 years ago

I think I fixed this in Blender at some point, maybe the fix is not working in your specific case.

https://developer.blender.org/rBe6ba760ce8fda5cf2e18bf26dddeeabdb4021066

Zyl9393 commented 5 years ago

It's good to fix it on that end, but I also believe it should not have been symlinked in the first place.

ecke101 commented 4 years ago

There is another problem with symlinks. I can't seem to have my project files on a network folder. I have all my files at a network folder at work and use VPN to access them at home as well. Is there something I can do to fix this? (using win10)

gerroon commented 4 years ago

@ecke101 that is a Samba related setting if you are on Linux. Symlinks are not served by default.

@Zyl9393

Symlinking the entire development directory into production is probably the most mental thing I have come across this year. Please reconsider this design decision.

That is your personal opinion. Please do not call people mental because they do not follow your mental model. Symlinks on Windows require heightened permissions, that is why Blender throws an error. Junctions are the recommended way for Windows.

There is no problem using symlinks/junctions (depending on your OS) to use for addon development. That is your personal opinion, since you did not even bother to explain why it was a bad idea properly. You used this development tool without paying attention to how it functioned then came here to call people who developed it mental and ask for immediate action.

Kein commented 3 years ago

I'm having the same issue, any solution?

 File "d:\Unlinked\Users\Kein\.vscode\extensions\jacqueslucke.blender-development-0.0.12\pythonFiles\include\blender_vscode\load_addons.py", line 39, in create_link_in_user_addon_directory
    os.remove(link_path)
PermissionError: [WinError 5] Access is denied: 'C:\\Users\\Kein\\AppData\\Roaming\\Blender Foundation\\Blender\\2.80\\scripts\\addons\\MyAddon'
Saved session recovery to 'D:\TempC\quit.blend'

My VScode extensions folder symlinked to another drive but that is not the issue here, it tries to symlink in 'C:\Users\Kein\AppData\Roaming\Blender Foundation\Blender\2.80\scripts\addons\MyAddon'

gerroon commented 3 years ago

Use junctions instead of symlinks for folder

Kein commented 3 years ago

For what folder? I'm not using any symlinks for blender addons, I've already mentioned it. And this is where it tries to symlink: C:\\Users\\Kein\\AppData\\Roaming\\Blender Foundation\\Blender\\2.80\\scripts\\addons\\MyAddon Nothing here is symlinked. Nothing inside as well.

Kein commented 3 years ago

Okay, I figured it out. Junction had nothing to do with it. Apaprently you cant have addon installed in Blender and debug it, you can only debug working project. This is fine and makes sense, but it could have been stressed out more clearly in README.

Zyl9393 commented 2 years ago

We really need a fix for this. Today the addon recursively nuked my project directory when trying to launch into a new download of Blender 3.2.1 portable, bringing all files down to 0 bytes in size and deleting .git, destroying 3 days of work. This is not okay.

I get that my anecdotal telling can be seen as an eyesore, but I would hope for it to be taken as representative of the priority of the issue rather than as a personal attack.

justus-hildebrand commented 1 year ago

@Zyl9393 I have run into the same problem as you, and did some digging:

For me, the issue occurs when I install my addon into a fully fresh installation of Blender (i.e. I had no previous setup of preferences) by hitting "Build and Start" through the VSCode extension, and then pressing the "Load Settings" button on the Quick Setup splash screen, AND having the add-on installed in the old version of Blender already. Blender then copies the Junctions created by VSCode from the old Preferences folder to the new one, and overwrites the files that the newly installed (by VSCode) junctions point at - which would be your Git clone, which is why your data is gone, but the file structure isnt. Yay!

Would be nice if you can confirm if this is also what might have happened for you, or if you can even reproduce it and let us know how it went.

With this in mind: For now its probably best to stay away from the combination of "Build and Start", a new Blender version and the "Load old version Settings" button for now, until I or someone else has written a fix and it has been pushed and released into Blender's downstream.

This way we can have the debate on whether Symlinks/Junctions are a good or bad idea without having to worry of losing all our work, which should be nice. Personally I think it's neither a good or a bad choice. If you have a big plugin that you want to have working on different versions, it's certainly nice to be able to push your updates to all your installations at once, and not having to deal with multiple copies of large assets that your add-on might use is also a nice bonus. But you also have to deal with problems like this issue if you don't use the tech right. I guess, as with any project, it comes down to: Use git, use a remote repo, and push often. Backups are good. They make these bugs much less catastrophic, whenever they do occur, which I have found to be more often than one would think.