JuliaInterop / JuliaInterop/MATLAB.jl
"Failed to get variable ans" error, when not trying to get ans.
Nobody has claimed this yet.
- Dominant language
- Julia
- Stars
- 286
- Forks
- 64
- PR merge metrics
- No merged PRs in 30d
Description
Using the string macro mat"" I frequently get "failed to get variable ans from MATLAB session" error. This happens even though I am suppressing Matlab output with ;. It happens in various situations, but this is the first reliably reproducible example I have been able to make:
Put this in a file Foo.m somewhere in your path:
classdef Foo < dynamicprops
end
Then run:
julia> using MATLAB
julia> mat"f = Foo();"
inary
julia> mat"addprop(f, 'bar');"
Error using save
Unable to save variable 'ans' of class 'meta.DynamicProperty' to STDIO.
ERROR: MATLAB.MEngineError("failed to get variable ans from MATLAB session")
Stacktrace:
[1] get_mvariable(::MSession, ::Symbol) at /home/DNF/.julia/packages/MATLAB/cVrxc/src/engine.jl:164
[2] get_mvariable at /home/DNF/.julia/packages/MATLAB/cVrxc/src/engine.jl:168 [inlined]
[3] get_variable(::Symbol) at /home/DNF/.julia/packages/MATLAB/cVrxc/src/engine.jl:170
[4] top-level scope at /home/DNF/.julia/packages/MATLAB/cVrxc/src/matstr.jl:169
[5] include_string(::Function, ::Module, ::String, ::String) at ./loading.jl:1088
- The dynamic property
'bar'is successfully created. - Why is the word 'inary' printed to output after creation of the object? This happens a lot.
MATLAB.jl v0.7.3
MATLAB Version: 9.8.0.1417392 (R2020a) Update 4
julia> versioninfo()
Julia Version 1.5.0
Commit 96786e22cc (2020-08-01 23:44 UTC)
Platform Info:
OS: Linux (x86_64-pc-linux-gnu)
CPU: Intel(R) Core(TM) i7-10875H CPU @ 2.30GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-9.0.1 (ORCJIT, skylake)
Environment:
JULIA_EDITOR = code
JULIA_NUM_THREADS = 10
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the Foo.m example with the two mat"" commands, then inspect src/matstr.jl:169 and src/engine.jl:164-170, where the stack trace shows ans being fetched. Trace how suppressed expressions are handled and check the output path that prints "inary". Done means the commands complete without an ans error or stray output while still creating the dynamic property.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- api
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100