JacquesLucke / blender_vscode

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

Unable to execute Blender: Start on OSX #5

Closed simsod closed 5 years ago

simsod commented 5 years ago

Unable to open on OSX

added this to resolve the issue in blender_executable.ts

on OSX blender is packaged in a .app folder-structure which the file-selector on osx recognises as an application. but when starting from commandline, the actual binary should be executed from the folder Contents/MacOS/ inside the blender.app (folder).

Another solution would be to use the 'open' command on osx.

L#4 import * as os from 'os';`
...
L#147     (askUser_BlenderPath)
if (os.platform() === 'darwin') {
     filepath = filepath + '/Contents/MacOS/blender';
}

heh, I started a forked a while back with some tweaks to the overall layout of the vscode plugin, but now I see you´ve implemented a similar solution in the new update :)

JacquesLucke commented 5 years ago

Yeah, the code back then was much uglier than now because I just started learning typescript. Should be better now. :)

Thanks for the provided fix. Is it not possible to select the actual binary when you are asked to select the executable?

Will blender always be packaged like that or is this path different for different people?

Can command line arguments be passed to "open" that are forwarded to the application? I'm not sure how well that works in the task system of vs code. Would be nice if you could try that. I guess if it works, using "open" is the preferable solution because it makes less assumptions about the system.

JacquesLucke commented 5 years ago

Or we could check if the selected file ends with .app, and if yes, /Contents/MacOS/blender can be added to the path.

Looks like this path is always the same: https://developer.apple.com/library/archive/documentation/CoreFoundation/Conceptual/CFBundles/BundleTypes/BundleTypes.html#//apple_ref/doc/uid/10000123i-CH101-SW1

simsod commented 5 years ago

in Finder you can right click and do "Show package contents", but that is not available in the open-dialog from vscode atleast.

AFAIK blender is always packaged in a .app when released to OSX, and the path is always blender.app/Contents/MacOS/blender

not sure how it is launched when compiling/debugging the blender sourcecode itself though, I havent dived that far into blender :)

since osx 10.6 you can pass arguments to the 'open' command using --args but I don´t think that is used very widely.

I recently helped solve a bug with machin3tools (for 2.8) regarding osx compatibility (he got the path wrong when reading keymaps inside his plugin) he used this code to solve the issue:

keymappath = os.path.join(bpy.utils.preset_paths(subdir='keyconfig')[0],'blender_27x.py') inside blender that code returns the blender.app/Content/Resources/.... folder.

yeah your comment from 44secs ago seems like a good solution

JacquesLucke commented 5 years ago

https://wiki.blender.org/wiki/Building_Blender/Mac

The last screenshot there indicates that Blender is packaged in the same way when Blender is build from source code.

JacquesLucke commented 5 years ago

Can you check if the provided fix works, please?

simsod commented 5 years ago

Works like a charm!

btw, do you really need the ms-vscode.cpptools as an extension dependency? Its only used for some use-cases which you barely "support" right now right?

JacquesLucke commented 5 years ago

Thanks.

No, I don't really need it right now... Added it before I was sure which features I will support for now. Does it cause trouble for you?

simsod commented 5 years ago

nah, well, since its a dependency you have to install it in order to activate the blender-vscode plugin Which seems unnecessary if you aren´t doing any cpp development but I guess it´s fine :)

JacquesLucke commented 5 years ago

True, I'll probably add this dependency back soon anyway, so not sure if I should remove it now. Will decide before I publish the next version.