Opened 5 years ago

Last modified 5 years ago

#5898 assigned defect

loadCompletePackageFromMp fails when directory-structured library has models that differs only in letter case

Reported by: dariomangoni@… Owned by: Adrian Pop
Priority: high Milestone: Future
Component: Interactive Environment Version:
Keywords: Cc:

Description

Strange situation, not sure if it is specifications-compliant:

OpenModelica cannot load a library in Directory Hierarchy structure whose models have names that differ only for letter case.

I passed from OneFile to Directory structure with a well-known Modelica editor...

My package was like this:

  • MyPackage
model1 Model1

at the beginning, model1 and Model1 were both in a single MyPackage.mo file. Good.

Once I split in single files (i.e. Directory structure), this famous Modelica editor gave me a subfolder named MyPackage whose package.order file have TWO lines, namely model1 and Model1, however in the folder I have just ONE file, named model1.mo.
Of couse, I couldn't have a Model1.mo in the same folder, so in the same model1.mo file both model1 and Model1 models have to be fit!

However, this throws the error:

[1] 12:19:22 Translation Error
[C:/dev/OM64bit/OMCompiler/Compiler/FrontEnd/ClassLoader.mo: 299:9-299:128]: Internal error loadCompletePackageFromMp failed for unknown reason: mp=C:/workspace/_modelica_temp/ pack=DirectoryFailure

[2] 12:19:22 Scripting Error
Failed to load package DirectoryFailure () using MODELICAPATH C:/workspace/_modelica_temp/.}}}

HOWEVER, strange as it seems, if you put the original one-file library '''MyPackage.mo''' in the same containing folder in which there is also the folder '''MyPackage''' everything works back, even if you ask to load the '''MyPackage/package.mo'''!!!!
Plase read carefully this few lines above because it's tryuly incredible.

Attachments (1)

DirectoryFailures.zip (1.8 KB ) - added by dariomangoni@… 5 years ago.
MinimalExample

Download all attachments as: .zip

Change History (10)

comment:1 by dariomangoni@…, 5 years ago

Sorry, bad formatting.
The package was

MyPackage
|- model1
|- Model1

I add the minimal example to replicate

by dariomangoni@…, 5 years ago

Attachment: DirectoryFailures.zip added

MinimalExample

comment:2 by Francesco Casella, 5 years ago

I guess this is a problem with the Windows file system...

comment:3 by Martin Sjölund, 5 years ago

You are indeed only allowed to put one class in a file. On Linux, you would get two files model1.mo and Model1.mo and it would work.
You would need to put one of them in the package.mo or reorganize the package.

How old is that OpenModelica version though? Mine says:

[DirectoryFailure/package.mo:2:1-23:21:writable] Warning: The package.order file contains a class Model1, which is expected to be stored in file Model1.mo, but seems to be named model1.mo. Proceeding since only the case of the names are different.
[DirectoryFailure/model1.mo:0:0-0:0:readonly] Error: Modelica library files should contain exactly one package, but found the following classes: model1, Model1.
Error: Failed to load package DirectoryFailure () using MODELICAPATH /mnt/data/@Mech/martin/tmp.

comment:4 by dariomangoni@…, 5 years ago

Yes, the problem is on Win only, since it ignores letter cases in filesystem.

The solution is not complex: I already reorganized things accordingly.
What was complex was was actually finding the problem, because the error message was not clear on what went wrong.

I'm on v1.16.0-dev-197-g05f528fd5.

I'm trying to download the latest dev, but it is taking hours... I'll let you know

comment:5 by Martin Sjölund, 5 years ago

I guess it's some Windows-specific problem then. These error messages that we get on Linux are years old, I think...

comment:6 by Martin Sjölund, 5 years ago

Component: *unknown*Interactive Environment
Owner: changed from somebody to Adrian Pop
Status: newassigned

comment:7 by Adrian Pop, 5 years ago

I guess we could check the file case vs model case and if different report a problem (this on all systems, not just Windows).

comment:8 by Martin Sjölund, 5 years ago

We already do that. The problem is on Windows it just fails somewhere in the middle ;)

comment:9 by dariomangoni@…, 5 years ago

I can confirm that also on OpenModelica v1.16.0-dev-259-g8a5138f38 (downloaded yesterday) I always get the same message

[C:/dev/OM64bit/OMCompiler/Compiler/FrontEnd/ClassLoader.mo: 299:9-299:128]: Internal error loadCompletePackageFromMp failed for unknown reason: mp=D:/Users/Desktop/ pack=DirectoryFailure

But I wouldn't want to support this not-so-compliant structuring scheme with multiple models in one file, but just to output an error message that can hint to the underlying problem.

Note: See TracTickets for help on using tickets.