Error when saving MLX file
196 views (last 30 days)
Agustín on 10 Oct 2022
I am using MATLAB R2022a in Ubuntu 20.04.5 LTS (Kernel 5.15), and whenever I try so save a .m script file I have no issues, however when I try to save a Live Editor file (.mlx), I get the next error:
Unable to save file myFile.mlx
java.lang.RuntimeException: Internal Exception in writing MLX file : Could not commit changes: copy failed: fl:filesystem:SystemError: /tmp/.bdae-ce03-39f3-5965.tmp invalid cross-device link
I have tried with R2022b, but the problem persists. I have another Ubuntu station (Kernel 5.4) and it does write the file. I have read about similar errors depending on the Kernel version. Is there any solution that does not include downgrading the Kernel?
Sailesh Kalyanapu on 14 Oct 2022
I understand that you are getting an error when saving 'MLX' files in MATLAB R2022a and R2022b.
This is a known issue with MATLAB R2022 releases. Currently, these are the following workarounds other than downgrading the Linux kernel:
1) Change the temp directory of MATLAB to a new folder
The default temp directory of MATLAB on Linux is '/tmp/', to resolve the issue, you can create a new folder in a different file directory and set it as the new temp directory.
Please refer to the following example to change the temp directory of MATLAB in the MATLAB Command Window:
>> clear all
>> tempdir % ans = '/tmp/'
>> setenv('TMPDIR', 'FILE DIRECTORY FOR THE NEW FOLDER')
>> clear all
>> tempdir % ans = 'FILE DIRECTORY FOR THE NEW FOLDER'
You should be able to save all MLAPP files/ Simulink models/ Live Scripts as usual after changing to the new temp directory.
If the above workaround does not resolve the issue, try to
2) Use MATLAB Online:
MATLAB Online provides access to the latest version of MATLAB from a standard web browser using MathWorks-hosted computing resources and storage, which allows you to continue working with your previous files and related datasets.
Please refer to the following link to upload the files to MATLAB Online and download files from it: https://www.mathworks.com/help/releases/R2022b/matlab/matlab_env/access-files-in-matlab-online.html
If you would like to know more about what is MATLAB Online, please refer to the link below: https://www.mathworks.com/help/releases/R2022b/matlab/matlab_env/what-is-matlab-online.html
More Answers (2)
Cailean MacLabhruinn on 13 Dec 2022
Based on the answers above I created a suitable folder in my home folder, then I started MATLAB using something like the following command:
(Matlab_Install_Folder)/bin/matlab -desktop -r "setenv('TMPDIR', 'path to created directory')"
This way I need not modify anything in the operating system but Matlab always starts using the specified temp dir.
(Note that your solution is a solution to Simulink and AppDesigner saving problems!)
Charles on 24 Oct 2022
I am having this problem, too, but the above work-around does not work.
Without the work-around, I get this error dialog:
This mentions the "cross-device link".
Then I change the temp directory to one under my home dir: '/home/cwright/.matlab_tmp/'. I open a new model in Simulink, add one block and try to save. I get this error dialog:
Clearly, the new temp dir isn't good enough. So I close the file without saving, then attempt to exit Matlab. The GUI disappears, but the process never quits, in fact it starts taking 100% of the CPU (single core) and requires manually killing. This happens with or without the temp dir change.
This is pretty frustrating, as I'm on a trial Simulink license. Simulink works perfectly on my machine at work, but not my home machine. Both are running Linux Mint 20.3 with identical kernels:
Linux 5.15.0-48-generic #54~20.04.1-Ubuntu SMP Thu Sep 1 16:17:26 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
They are two different processors and mainboard. I guess the next step is to downgrade the kernel, but I'd appreciate other suggestions.