Filesystem error: cannot remove all [YjLu0asVxy]


I am using dynare_version ‘4.6.3’ under Windows 10.

I am trying to run dynare from Matlab using the statement

eval([‘dynare ‘,ModFileName,’ noclearall nostrict’]);

The program runs correctly for the first time. However, when I try to run again I obtain the error

terminate called after throwing an instance of ‘std::filesystem::__cxx11::filesystem_error’
what(): filesystem error: cannot remove all [YjLu0asVxy]

I saw that I can fix the problem deleting the folder creater after the first execution, using


where fname is the name of matlab file after preprocessing.

Is there a better way to fix the problem?

Thank you

Unfortunately, no. Dynare will try to delete that folder itself, but sometimes this operation is blocked. On my machine that happens particularly if the folder is synchronized by a cloud drive.

1 Like

Thank you for your response. Let me add. After the rmdir, add the line
clear M_;
To avoid the warning “The value of local variables may have been changed to match the globals.”

Given your use of

there seems to be a more fundamental issue here in your use of global variables.

It doesn’t look like. Before the eval, I create the local variable M_.fname = 'modfile'. Dynare then creates a file driver.m in which M_ is created again as global. At this point, it generated the warning. When I added the clear M_ before running dynare, the warning disappeared.

It’s fine as long as you know what you are doing. Global variables have a lot of potential for mistakes.