How to use "savepath" for adding path to pathdef.m in Linux?
21 views (last 30 days)
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!
Anshika Chourasia on 22 Feb 2022
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!