Permission error for PREFDIR when running a stand-alone application on a different system

Hi!
I am trying to run a stand-alone application compiled on Linux on another Linux system. However, I am running into issues because it seems like at some point the Matlab preference folder is being accessed. However, since this folder does not exist on this system, it returns an error. I am now wondering why prefdir is included in the compiled version and how I can circumvent the stand-alone application to rely on it.
Error:
Unable to access preferences folder /home/[USERNAME]/.matlab/R2022a. Preferences folder must be writable.
Thank you!

4 Comments

Does your code call setpref() or savepath() or the image processing toolbox options function? (sympref would also be a concern except it cannot be compiled)
'savepath()' occurs once in one of the scripts I compile (however, that function should not be called in my trial run..)
@Walter Roberson, which options file are you referring to in the image processing toolbox? I just realized that /matlab/R2022a/toolbox/images is also specified during compilation..

Sign in to comment.

Answers (2)

If the preferences folder is hardcoded, such problems occur. Search in the code for the name of the folder an replace it by the command prefdir.

7 Comments

Hi Jan, thanks for your reply! Do you think the path could be mentioned in either one of the directories listed in LD_LIBRARY_PATH or LD_PRELOAD?
I cannot find /.matlab/R2022a/ being mentioned anywhere in my code which I compiled...
Another idea is to insert some code tocreate the preferences folder on demand:
pref = prefdir();
if ~isfolder(pref)
mkdir(pref);
end
and this should be the first thing to be run, so I put it in the beginning of the first function that I call? I'll give it a try, thanks!
savepath should not occur in a compiled application.
what about addpath()? Could that also cause this issue?
I don't think so. addpath should only affect memory.
Hmm, okay, then I'll need to play around with it a bit more.
Let me know in case you have other ideas what might cause this issue!
Just to make sure, I tried a helloworld compiled script and that worked fine.. The error seems to occur when trying to open the actual compiled standalone application but it does not even run the first line of the main function since it would otherwise execute a print command.

Sign in to comment.

I think I was abble to fix it by adding
"-R -nodisplay or -R -nojvm" during the compilation!
However, I was just trying out things so it is not really clear to me why this helped. Do you have an idea why? (also I haven't tested yet whether only on of the two or both were necessary, I assume I'd only need the -nodisplay option). I'll update that once I tried it.

Categories

Products

Release

R2022a

Asked:

on 9 Mar 2023

Edited:

on 11 Mar 2023

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!