INTO-CPS-Association / unifmu

A universal mechanism for implementing Functional Mock-up Units (FMUs) in various languages
41 stars 4 forks source link

Unable to compile an FMU on MacOS #62

Closed michellebieger closed 4 months ago

michellebieger commented 5 months ago

Hiya, I'm looking to use this package as a way to compile FMUs on MacOS and then build on Docker. I'm currently on Apple M2 but I have Rosetta installed.

When following the local build instructions on the unifmu README, I get the following error:

➜  unifmu git:(master) ✗ cargo build --target aarch64-apple-darwin --release
warning: virtual workspace defaulting to `resolver = "1"` despite one or more workspace members being on edition 2021 which implies `resolver = "2"`
note: to keep the current resolver, specify `workspace.resolver = "1"` in the workspace root's manifest
note: to use the edition 2021 resolver, specify `workspace.resolver = "2"` in the workspace root's manifest
note: for more details see https://doc.rust-lang.org/cargo/reference/resolver.html#resolver-versions
   Compiling unifmu v0.0.8 (/Users/michellebieger/Documents/digi/unifmu/cli)
   Compiling fmiapi v0.1.0 (/Users/michellebieger/Documents/digi/unifmu/fmiapi)
warning: unused import: `zip::result::ZipError`
 --> cli/src/utils.rs:8:5
  |
8 | use zip::result::ZipError;
  |     ^^^^^^^^^^^^^^^^^^^^^
  |
  = note: `#[warn(unused_imports)]` on by default

warning: unused import: `CStr`
 --> cli/src/validation.rs:2:16
  |
2 | use std::ffi::{CStr, CString};
  |                ^^^^

error[E0283]: type annotations needed for `FileOptions<'_, _>`
   --> cli/src/utils.rs:21:9
    |
21  |     let options = FileOptions::default()
    |         ^^^^^^^   ----------- type must be known at this point
    |
    = note: cannot satisfy `_: FileOptionExtension`
    = help: the following types implement trait `FileOptionExtension`:
              ()
              ExtendedFileOptions
note: required by a bound in `FileOptions`
   --> /Users/michellebieger/.cargo/registry/src/index.crates.io-6f17d22bba15001f/zip-2.1.3/src/write.rs:246:31
    |
246 | pub struct FileOptions<'k, T: FileOptionExtension> {
    |                               ^^^^^^^^^^^^^^^^^^^ required by this bound in `FileOptions`
help: consider giving `options` an explicit type, where the type for type parameter `T` is specified
    |
21  |     let options: FileOptions<'_, T> = FileOptions::default()
    |                ++++++++++++++++++++

warning: unused variable: `rootdir`
  --> cli/src/benchmark.rs:11:18
   |
11 | pub fn benchmark(rootdir: &Path, config: &BenchmarkConfig) {
   |                  ^^^^^^^ help: if this is intentional, prefix it with an underscore: `_rootdir`
   |
   = note: `#[warn(unused_variables)]` on by default

warning: unused variable: `config`
  --> cli/src/benchmark.rs:11:34
   |
11 | pub fn benchmark(rootdir: &Path, config: &BenchmarkConfig) {
   |                                  ^^^^^^ help: if this is intentional, prefix it with an underscore: `_config`

warning: unused variable: `status`
   --> cli/src/validation.rs:559:17
    |
559 |             let status = s.fmi2DoStep(current_time, step_size, 0);
    |                 ^^^^^^ help: if this is intentional, prefix it with an underscore: `_status`

warning: unused variable: `e`
   --> cli/src/validation.rs:643:13
    |
643 |         Err(e) => {
    |             ^ help: if this is intentional, prefix it with an underscore: `_e`

warning: unused variable: `e`
   --> cli/src/validation.rs:654:17
    |
654 |             Err(e) => {
    |                 ^ help: if this is intentional, prefix it with an underscore: `_e`

warning: unused variable: `e`
   --> cli/src/validation.rs:661:17
    |
661 |             Err(e) => {
    |                 ^ help: if this is intentional, prefix it with an underscore: `_e`

For more information about this error, try `rustc --explain E0283`.
warning: `unifmu` (lib) generated 8 warnings
error: could not compile `unifmu` (lib) due to 1 previous error; 8 warnings emitted

Would it be possible to get assistance on correcting this? It looks like the error primarily comes from cli/src/utils.rs on line 21; where options hasn't been properly typescripted.

clagms commented 4 months ago

Hi Michelle! I don't think we've ever come across this error. A few troubleshooting suggestions (sorry that they are sparse):

  1. Is this platform specific error? Have you tried following instructions from a docker container or a windows machine?
  2. Is this a version specific error? Normally the build process should work with the latest compiler. Could you clarify the versions you're using?
  3. You seem to already have a feeling where things need to be improved. If you add the type annnotations to the code to see if the error goes away?

Thank you very much for your patience!

michellebieger commented 4 months ago
  1. Is this platform specific error? Have you tried following instructions from a docker container or a windows machine?

I would like to get it into a Docker container--this is just me following the README for this repository, where it says I must compile this first locally and then via Docker.

  1. Is this a version specific error? Normally the build process should work with the latest compiler. Could you clarify the versions you're using?

I've just git clone'd this repository and tried to follow the instructions; so I assume this is the latest version. I've also been trying to find a way to use the PyPi unifmu package in a poetry environment to generate an FMU and then deploy to Docker--in this I also have a few questions--namely, how to get the generated model into Docker? How I can specify what the intended release environment (Windows, Mac, etc.) should be? And just generally I'm not sure I'm generating it correctly--I've done the following: create a new poetry environment, putting my requirements.txt, builder.py file in the new repository, then add unifmu to the poetry .toml file and run poetry run unifmu generate python model.

  1. You seem to already have a feeling where things need to be improved. If you add the type annnotations to the code to see if the error goes away?

I'm not an expert in this langauge at all; I did try adding in the type annotations but it didn't resolve the issue!

Thanks so much for replying--would love any additional guidance you have as I'm not sure I'm understanding the documentation very well!

clagms commented 4 months ago

Thanks for the quick reply @michellebieger ! I've asked for some help internally to try and figure out whether the build has broke in the past couple of months. @sagilar is aware of this.

One more question, if you don't mind: why is it that you need to build the unifmu from source? Are the binaries in the releases not enough?

Normally it should just be to download a released version and run the command line. You can also run the binary from a docker container running ubuntu. Then I think the fact that you're on a mac no longer matters (but I am not certain here).

Thank you for your patience! Drop me an email if you want to schedule a meeting or something: https://clagms.github.io/contact/

Daniella1 commented 4 months ago

Hi @michellebieger,

I tried fixing the issue and compiled it on my windows computer, then on the other OSs (mac included) using the docker image, and they all seemed to work. Can you see if you can compile the library with the updated code on your Mac?