How to use "savepath" for adding path to pathdef.m in Linux?

18 views (last 30 days)
Hello All,
I am using MATLAB R2020a on Ubuntu 20.04.3 LTS. I have installed YALMIP and GUROBI, and I am using them on MATLAB.
The problem, however, is that I need to reintall these two whenever I open MATLAB.
When I use savepath command, I get the following error.
Warning: Unable to save path to file '/usr/local/MATLAB/R2020a/toolbox/local/pathdef.m'. You can save your path
to a different location by calling SAVEPATH with an input argument that specifies the full path. For MATLAB to
use that path in future sessions, save the path to 'pathdef.m' in your MATLAB startup folder.
> In savepath (line 176)
According to what I found online, I have copied and pasted the pathdef.m from the directory mentioned in the error message to another directory. Then, I used the savepath command with an arguement specifying the location of the pasted pathdef.m file to save the current path. This did not work.
Is there a permanent solution to this issue?
Any help is greatly appreciated!
Nasim on 19 Feb 2022
Edited: Nasim on 19 Feb 2022
When I started MATLAB again, I checked and saw that the path is added to pathdef.m in ~/Document/MATLAB. Then, I checked if Yalmip is intalled or not. It was not installed.
The same thing happended when I copy pasted pathdef in another directory. The added directory for Yalmip was saved on pathdef.m, but Yalmip was not installed.

Sign in to comment.

Answers (1)

Anshika Chourasia
Anshika Chourasia on 22 Feb 2022
Hi Nasim,
I understand that you are unable to save the path and encounter a warning.
The MATLAB path is saved in the 'pathdef.m' file as suggested in the warning message you receive. Users who do not have administrative privileges are not able to write in this directory. This may be one of the reasons why you are unable to save the paths.
To work around this issue, you can save the ADDPATH command in "startup.m" in the current startup directory, if you have write permission to that directory. The startup directory can be modified by right-clicking on the MATLAB shortcut and clicking on "properties".
Or, you also can save your ADDPATH command in a .m file in their respective work directories and run it using startup options each time they start MATLAB. This can be done as follows:
1. You must save your ADDPATH command in a file, say (username)_path.m.
2. While starting MATLAB, you can start it up at the system prompt as follows:
matlab /r (username)_path
I hope this helps!




Community Treasure Hunt

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

Start Hunting!