Skip to content

Conversation

@musm
Copy link
Collaborator

@musm musm commented Aug 24, 2017

On linux starting the MATLAB engine will automatically open in the
current working directory. However, Windows has different behavior and
this patch manually changes the engine to the current working directory
to more closely match the behavior on linux. This has the side effect that if a new MATLAB engine is open into a different directory than the directory the previous engines was open in, all the directories change into the new directory (this would be the behavior if you did cd in the new engine, anyways)

Right now it is very annoying that the default engopen, open's up matlab in the C:\Program Files\MATLAB\R2016b directory, which almost always means you have to cd into the directory where your matlab files are located in

linux

julia> using MATLAB

julia> pwd()
"/home/mus"
julia> m1 = MSession();
julia> cd("..")
julia> pwd()
"/home"
julia> m2 = MSession();
julia> pwd()
"/home"
julia> m3 = MSession();
julia> cd("..")
julia> pwd()
"/"
julia> m4 = MSession();

julia> eval_string(m1, "pwd")
>>
ans =
/home/mus

julia> eval_string(m2, "pwd")
>>
ans =
/home

julia> eval_string(m3, "pwd")
>>
ans =
/home

julia> eval_string(m4, "pwd")
>>
ans =
/

this pr, windows

julia> using MATLAB
julia> pwd()
"C:\\Users\\Mus\\.julia\\v0.7\\MATLAB\\src"
julia> m1 = MSession();
julia> cd("..")
julia> pwd()
"C:\\Users\\Mus\\.julia\\v0.7\\MATLAB"
julia> m2 = MSession();
julia> pwd()
"C:\\Users\\Mus\\.julia\\v0.7\\MATLAB"
julia> m3 = MSession();
julia> cd("..")
julia> pwd()
"C:\\Users\\Mus\\.julia\\v0.7"
julia> m4 = MSession();

julia>  eval_string(m1, "pwd")
ans =
C:\Users\Mus\.julia\v0.7

julia>  eval_string(m2, "pwd")
ans =
C:\Users\Mus\.julia\v0.7

julia>  eval_string(m3, "pwd")
ans =
C:\Users\Mus\.julia\v0.7

julia>  eval_string(m4, "pwd")
ans =
C:\Users\Mus\.julia\v0.7

master, windows

julia> using MATLAB
julia> pwd()
"C:\\Users\\Mus\\.julia\\v0.7\\MATLAB\\src"
julia> m1 = MSession();
julia> cd("..")
julia> pwd()
"C:\\Users\\Mus\\.julia\\v0.7\\MATLAB"
julia> m2 = MSession();
julia> pwd()
"C:\\Users\\Mus\\.julia\\v0.7\\MATLAB"
julia> m3 = MSession();
julia> cd("..")
julia> pwd()
"C:\\Users\\Mus\\.julia\\v0.7"
julia> m4 = MSession();

julia>  eval_string(m1, "pwd")
ans =
C:\Program Files\MATLAB\R2016b

julia>  eval_string(m2, "pwd")
ans =
C:\Program Files\MATLAB\R2016b

julia>  eval_string(m3, "pwd")
ans =
C:\Program Files\MATLAB\R2016b

julia>  eval_string(m4, "pwd")
ans =
C:\Program Files\MATLAB\R2016b

On linux starting the MATLAB engine will automatically open in the
current working directory. However, Windows has different behavior and
this patch manually changes the engine to the current working directory
to match the behavior on linux.
@musm musm merged commit a1945a6 into JuliaInterop:master Sep 4, 2017
@musm musm deleted the dir branch September 4, 2017 16:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants