Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FMUArchive is not a directory error #473

Open
benplay2 opened this issue Apr 9, 2024 · 0 comments
Open

FMUArchive is not a directory error #473

benplay2 opened this issue Apr 9, 2024 · 0 comments

Comments

@benplay2
Copy link

benplay2 commented Apr 9, 2024

Problem

When attempting to create an FMU from a simulink model, I received the following error:

C:\Users\USERID1\AppData\Local\Temp\tpdeb91cc8_6d09_4157_9226_606a8095eb0d\zzzzz_to_be_fmu_zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz_fmu_sfcn_rtw_fmi\FMUArchive is not a directory.

This did not happen every time, but I believe occurred after a prior failure.

Solution

I was able to detect where the error occurs and fix it. The issue is that rtwsfcnfmi_make_rtw_hook() uses exist() to check existence of the FMUArchive directory, but does not specify a full path to it. Therefore, it will return that the directory does exist if some folder with that name lives somewhere in your MATLAB path.

This is the reason for MATLAB suggests using isfolder() instead.

Problem:

% remove FMU build directory from previous build
if exist('FMUArchive', 'dir')
   rmdir('FMUArchive', 's'); %This line could be executed even if FMUArchive does not live in the current directory! (which causes an error)
end

Fix:

% remove FMU build directory from previous build
if isfolder('FMUArchive')
    rmdir('FMUArchive', 's');
end

The following logic should be changed where applicable:

  • exist(<something>, 'dir') ➡️ isfolder(<something>)
  • exist(<something>, 'file') ➡️ isfile(<something>)

From a quick search, I found 8 spots that may need this update.
image

System details:

  • Windows 10
  • MATLAB 2022b
  • Compiler: Visual Studio 2017
  • FMIKit version 3.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant