triforcely / Octave.NET

📈 More than cross-platform Octave process wrapper 🔬
MIT License
32 stars 7 forks source link

Unable to run 'octave-cli' executable. Adding octave-cli path to the code. #12

Closed Eslam93 closed 5 years ago

Eslam93 commented 5 years ago

Adding the bin folder to system path was working fine with me, but I need to use it through code for deployment purposes, but it won't work correctly with me, it always through an exception that I've added details below.

My usage goes like that

OctaveContext.OctaveSettings.OctaveCliPath = @"D:\InstalledPrograms\Octave\Octave-5.1.0.0\mingw64\bin\"; // add octave logic using (var octave = new OctaveContext()) { octave.Execute("pkg load image;");

I've tried to change the path several changes by adding the octave-cli file name with and without the .exe extension. i've copied the file into my project path, but failed in all nonetheless.

How to specify path to octave-cli binary in my code? I'm using .Net framework 4.7 and 4.6.1 in my project.

Thank you so much.

Exception: { "Message": "An error has occurred.", "ExceptionMessage": "Unable to run 'octave-cli' executable. Make sure that it exists and/or is added to environment PATH variable.", "ExceptionType": "System.Exception", "StackTrace": " at Octave.NET.OctaveProcess..ctor(String octaveCliPath)\r\n .... "InnerException": { "Message": "An error has occurred.", "ExceptionMessage": "The system cannot find the file specified", "ExceptionType": "System.ComponentModel.Win32Exception", "StackTrace": " at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)\r\n at Octave.NET.OctaveProcess..ctor(String octaveCliPath)" }

triforcely commented 5 years ago

It expects the full path of octave-cli.exe.

Eslam93 commented 5 years ago

Thank you @triforcely . but I've tried both OctaveContext.OctaveSettings.OctaveCliPath = @"D:\InstalledPrograms\Octave\Octave-5.1.0.0\mingw64\bin\octave-cli.exe" and OctaveContext.OctaveSettings.OctaveCliPath = @"D:\InstalledPrograms\Octave\Octave-5.1.0.0\mingw64\bin\octave-cli"

and it didn't work with me either ways. did I miss something?

triforcely commented 5 years ago

You should have similar exception message when the binary is missing. Your message only contains "octave-cli", are you sure you sent the correct error message? image

Eslam93 commented 5 years ago

Yes I'm sure, it always only gives me 'octave-cli', even if in octave object I find the path in the setting I've typed

triforcely commented 5 years ago

I'm going to need repo with a reproducible example to look into this issue.

Eslam93 commented 5 years ago

Ok thank you so much, I'll be doing that now, but I've noticed that our octave versions are different and having a different bin path inside octave, would that be the issue may be?

triforcely commented 5 years ago

Just tested with newest version and it works fine. image But the inner exception explicitly says, that the system cannot find the file specified so it doesn't even come to the point where it runs Octave.

Eslam93 commented 5 years ago

Finally, Thank you again @triforcely , the issue was on my side, but was a bit more about my architecture of the project not how the string is written, I figured it out while recreating the project for the online rep. my solution that I had to create a constructor that set the OctaveCliPath there, as setting it inside the function didn't apply the change for some reason.

Thank you again man.

triforcely commented 5 years ago

I'm happy to hear that it works :)