# File not located on MATLAB 'path' but correct path is known by MATLAB

7 messages
Open this post in threaded view
|

## File not located on MATLAB 'path' but correct path is known by MATLAB

 In migrating MATLAB to a Windows 10 platform from Windows 7, I have encountered a curious difference in executable file path resolution.  It is only an "issue" for me because I have grown accustom to it in W7 :-) In Windows 7, from the MATLAB console (shown below just after startup), if a command/script is entered for exection that is not to be found on the "path", many (most? all?) times, MATLAB tells you where it is and suggests a "cd" to that location or add that location to the path AND it even formulates the "cd" or "addpath" commands available by clicking on the appropriate "suggestion" text which is underlined. So far I cannot duplicate this behavior on the W10 installation. Here is what happens on W7 ===============  Home License -- for personal use only. Not for government, academic, research, commercial, or other organizational use. >> pwd ans = 'D:\FEATool\tempwork\calling c' >> print_geom_objects 'print_geom_objects' is not found in the current folder or on the MATLAB path, but exists in: D:\FEATool\tempwork\scripts Change the MATLAB current folder or add its folder to the MATLAB path. ============== The phrase "Change the MATLAB current folder" is underlined and if clicked on executes: >> addpath 'D:\FEATool\tempwork\scripts' The phrase "add its folder to the MATLAB path" is also underlined and if clicked on executes: >> cd 'D:\FEATool\tempwork\scripts' I realize that this is a MATLAB question (and I intend to pursue MATLAB for an answer), but all I can seem to find on the MATLAB site associated with this message is a discussion/question as to WHY the file is not found on the path ...  not the reason that the message is generated. Kind regards, Randal
Open this post in threaded view
|

## Re: File not located on MATLAB 'path' but correct path is known by MATLAB

 Administrator I can't really say why your new Matlab installation is behaving differently, but it seems like the Mathworks have switched up the links, "cd" will change to a directory, and "addpath" will temporarily add a folder to the list of known paths from which to find scripts (Matlab can only run scripts from either the current directory or the ones on the Matlab search paths which can be seen by using the "pathtool" command). If you want to permanently add a folder to this list you can use the "savepath command or manually add the corresponding addpath command to your "startup.m file. Further discussion on this and purely Matlab related topic are better suited to the Mathworks specific help forums: https://www.mathworks.com/matlabcentral/answers/index
Open this post in threaded view
|

## Re: File not located on MATLAB 'path' but correct path is known by MATLAB

 Precise Simulation wrote I can't really say why your new Matlab installation is behaving differently, but it seems like the Mathworks have switched up the links, "cd" will change to a directory, and "addpath" will temporarily add a folder to the list of known paths from which to find scripts Opps! It was I that "switched up the links" in my description of what happens :-( ... they get it right. Precise Simulation wrote (Matlab can only run scripts from either the current directory or the ones on the Matlab search paths which can be seen by using the "pathtool" command). ... which I understand ... I just wondered how MATLAB knew the correct path even though it was not listed in the path list. Oh well... we'll see what MATLAB says... Kind regards, Randal
Open this post in threaded view
|

## Re: File not located on MATLAB 'path' but correct path is known by MATLAB

 Administrator If you're Matlab version hasn't changed, I'm guessing it is probably more related to changing OS/Windows,  possibly due to your OS paths (used by the "where" CLI tool to find things), but I'm only speculating.
Open this post in threaded view
|

## Re: File not located on MATLAB 'path' but correct path is known by MATLAB

 This post was updated on . I sent the following to MATLAB: Please find attached “W10cleanInstall.png”. It is a screen shot of commands immediately after the initial invocation of MATLAB 2020a. There is a MATLAB script “print_geom_objects.m” located at : D:\FEATool\tempwork\scripts Note that when the commands: >>cd D:\FEATool\tempwork >>print_geom_objects are executed, the response is (as expected – since “print_geom_objects.m” is not located in the current directory or on the execution path) it is not located and MATLAB responds: Unrecognized function or variable ... Then when the commands: >>cd scripts >>print_geom_objects are executed, “print_geom_objects” is located and executed, but (as expected) it fails to execute properly because of invalid arguments. Following that, note the return of the current working directory to “D:\FEATool\tempwork” by the command: >>cd .. Now comes the surprise of what seems to me to be undocumented/unexplained behavior. The command: >>print_geom_objects is (as expected) not located since it is still not on the path or in the current working directory, BUT WHAT HAPPENS IS VERY UNEXPECTED. As reported initially, the command/script “print_geom_objects.m” is correctly located by MATLAB which also formulates ‘cd’ and ‘addpath’ commands to make the appropriate changes either of which would make the command executable. Further note that changing to an empty directory produces the same result. Also (not shown) after executing MATLAB and re-launching it, the behavior does not change. From the first attempt, It refuses to execute the command but does locate it including offering the commands to correct the off-path state. To clarify: my question is NOT why the command is NOT located but why (after initially locating it and executing it) MATLAB continues to offer its location even though that location does not qualify as an executable one. Thanks, Randal Awaiting their reply, -Randal
 [I realize that this really belongs on some MATLAB forum, but I thought I would go ahead and finish this since I started it.] Below is some further information I sent to MATLAB << Further notes sent to MATLAB:   I have done some further testing and it seems that MATLAB is maintaining a path list separate from the execution “path” (the one manipulated by addpath | pathtool | rehash | restoredefaultpath | rmpath). This path, I will call “auxpath”, is a set of directory locations through which MATLAB searches for executable commands or scripts when that command is not found in the current working directory or on the “path”. If located, MATLAB does not execute the command but instead responds with the suggestion that it was located and in order to execute the command the user could ‘cd’ or ‘setpath’ using the hyperlinked commands.   Evidently, this list starts out empty with a fresh installation of MATLAB.  When a command or script is successfully executed, having been found in the current working directory or on the “path”, the directory in which the command was found is added to this “auxpath”.  The cumulative “auxpath” is maintained intact when MATLAB is exited and restarted.   If this is true – such a list as I have described as “auxpath” – how can this list be displayed, cleared, or modified? Is it described in the documentation? ---- end further notes to MATLAB>> Here is what I received back from MATLAB: << Begin message from MATLAB ==== I have some updates to share regarding your Technical Support Case #04799372 regarding 'Gratuitous Path Location'. The history used by the feature in question is the Current Folder History. It is the list that you see if you click the down arrow all the way on the right of the bar showing the current folder. This list is also available in settings. To access the settings object, you can execute the following command: s = settings().matlab.desktop.currentfolder.History To view the current value, you can access the "ActiveValue" property of the setting: s.ActiveValue You can also modify the value for either just the current MATLAB session, or across MATLAB sessions, by setting the "TemporaryValue" or "PersonalValue" property of the setting, respectively. For additional information about "Setting" objects, please refer to the following documentation: https://www.mathworks.com/help/matlab/ref/matlab.settings.setting.htmlI agree that this particular setting is not documented, so I have communicated this to the corresponding development and documentation team. ======= End message from MATLAB>> This current working directory history is located just as the above message says (It seems to be limited to 20 entries.): >> s= settings().matlab.desktop.currentfolder.History; >> fprintf ("%s\n",s.ActiveValue{1:length(s.ActiveValue)}) D:\FEATool\tempwork D: D:\FEATool D:\FEATool\tempwork\calling c D:\FEATool\tempwork\Morse\Current Density at 1 meter\TableII Series\Zone of Danger D:\FEATool\tempwork\Morse\Current Density at 1 meter\TableII Series\Zone of Danger\Total Current D:\FEATool\tempwork\Morse\Current Density at 1 meter\TableII Series D:\FEATool\tempwork\Morse\Current Density at 1 meter\TableII Series\CurrentDensity D:\FEATool\tempwork\Morse\Current Density at 1 meter D:\FEATool\tempwork\Morse C:\Users\Randal\Documents\MATLAB\Examples\R2020a\matlab\LiveEditorInteractiveNarrative C:\Users\Randal\AppData\Roaming\MathWorks\MATLAB\R2020a D:\FEATool\tempwork\scripts D:\FEATool\tempwork\Morse\Current Density at 1 meter\report C:\Users\Randal\Documents\MATLAB\Examples\R2020a\matlab\ReturnControlToInvokingFunctionExample C:\Users\Randal\AppData\Roaming\MathWorks\MATLAB Add-Ons\Apps\FEAToolMultiphysics C:\Users\Randal\Desktop\FEATool betas\featool-v1p13-beta4c C:\Users\Randal\Desktop\FEATool betas\featool-v1p13-beta4 C:\Users\Randal\Desktop\FEATool betas C:\Users\Randal\Desktop\reports-1.13beta3 However I was not able to see what I expected when I "click the down arrow all the way on the right of the bar showing the current folder" as MATLAB suggested. I have inquired about this. I may have simply misunderstood what I was supposed to see. Kind regards, Randal
 randress wrote This current working directory history is located just as the above message says (It seems to be limited to 20 entries.): >> s= settings().matlab.desktop.currentfolder.History; >> fprintf ("%s\n",s.ActiveValue{1:length(s.ActiveValue)}) D:\FEATool\tempwork D: D:\FEATool D:\FEATool\tempwork\calling c D:\FEATool\tempwork\Morse\Current Density at 1 meter\TableII Series\Zone of Danger D:\FEATool\tempwork\Morse\Current Density at 1 meter\TableII Series\Zone of Danger\Total Current D:\FEATool\tempwork\Morse\Current Density at 1 meter\TableII Series D:\FEATool\tempwork\Morse\Current Density at 1 meter\TableII Series\CurrentDensity D:\FEATool\tempwork\Morse\Current Density at 1 meter D:\FEATool\tempwork\Morse C:\Users\Randal\Documents\MATLAB\Examples\R2020a\matlab\LiveEditorInteractiveNarrative C:\Users\Randal\AppData\Roaming\MathWorks\MATLAB\R2020a D:\FEATool\tempwork\scripts D:\FEATool\tempwork\Morse\Current Density at 1 meter\report C:\Users\Randal\Documents\MATLAB\Examples\R2020a\matlab\ReturnControlToInvokingFunctionExample C:\Users\Randal\AppData\Roaming\MathWorks\MATLAB Add-Ons\Apps\FEAToolMultiphysics C:\Users\Randal\Desktop\FEATool betas\featool-v1p13-beta4c C:\Users\Randal\Desktop\FEATool betas\featool-v1p13-beta4 C:\Users\Randal\Desktop\FEATool betas C:\Users\Randal\Desktop\reports-1.13beta3 However I was not able to see what I expected when I "click the down arrow all the way on the right of the bar showing the current folder" as MATLAB suggested. I have inquired about this. I may have simply misunderstood what I was supposed to see. MATLAB replied to correct my misinterpretation of their directions.    The following illustrates the scrollable list as displayed by clicking the arrow to the right of the windows that displays the current folderSo, the long and short of this whole post is that if a path shows up in the current working directory history (possibly limited to 20), as viewed by 1 of 2 ways outlined above, MATLAB will search that list for executable files which are not found in the current working directory nor on the MATLAB search path (as viewed by "path" command). If the file is located in the cdw path history, then, rather than executing it, MATLAB notifies the user with hypertext alternatives to 'cd' to that directory or 'addpath' that directory. -Kind regards, Randal