IDAES / idaes-ext

IDAES developer repo for those building the idaes binary solvers and related tools.
Other
9 stars 11 forks source link

PETSc Example cannot be run on macOS 14.5 due to Library not loaded: libX11.6.dylib #272

Open fahim831 opened 6 months ago

fahim831 commented 6 months ago

I am trying to run the simplest PETSc example. However, on the line where I call petsc.petsc_dae_by_time_element, I get an error message. I have tried running brew install xquartz --cask and restarting my computer as well but keep getting the below error message:

2024-05-29 16:38:58 [INFO] idaes.solve.petsc-dae: dyld[3865]: Library not loaded: /usr/local/opt/libx11/lib/libX11.6.dylib
2024-05-29 16:38:58 [INFO] idaes.solve.petsc-dae:   Referenced from: <F588438D-238F-3459-8B4A-7CC7BCFD83E8> /Users/$USER/.idaes/bin/petsc
2024-05-29 16:38:58 [INFO] idaes.solve.petsc-dae:   Reason: tried: '/libX11.6.dylib' (no such file), '/Users/$USER/.idaes/bin/libX11.6.dylib' (no such file), '/usr/local/opt/libx11/lib/libX11.6.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/usr/local/opt/libx11/lib/libX11.6.dylib' (no such file), '/usr/local/opt/libx11/lib/libX11.6.dylib' (no such file), '/usr/local/lib/libX11.6.dylib' (no such file), '/usr/lib/libX11.6.dylib' (no such file, not in dyld cache)

By the way, I can solve DAEs with pyomo.dae outside of IDAES right now.

andrewlee94 commented 6 months ago

In order to help, we will need to know more about the system you are working on.

Looking at the error message it appears that there is a missing .dylib file, so you may need to install that separately.

fahim831 commented 6 months ago

The system is macOS Sonoma 14.5.

How should I install that file separately? I installed petsc using this from the instructions: daes get-extensions --extra petsc

andrewlee94 commented 6 months ago

Unfortunately we don't have a lot of people who use Macs. @eslickj @adowling2 @Robbybp @bknueven Would one of you be able to provide any insight on this?

Robbybp commented 6 months ago

Have you tried brew install libx11? There seems to be a homebrew formula for this library.

Robbybp commented 6 months ago

I haven't seen this before, but also haven't updated to MacOS 14. Have you tried this on MacOS 13?

lbianchi-lbl commented 6 months ago

This is just a guess from my side, but could the machine architecture (ARM/Apple Silicon vs Intel) be relevant here? As of today, I'm not sure of the extent to which macOS is supported by the various subcomponents of the IDAES extensions.

fahim831 commented 6 months ago

I just used brew install libx11 and restarted the terminal but it didn't help. I get the same error.

I don't think it's possible to revert my system back to 13 as it came with 14 and I didn't do the update myself.

@lbianchi-lbl I don't know if machine architecture is the issue but this does have an M2 chip so you may be onto something. Is there anything I can do to check?

Robbybp commented 6 months ago

If you have the the x11 library, but petsc can't find it, maybe you need to update DYLD_LIBRARY_PATH? I can try to reproduce this (I have a MacOS 14 machine at home), but may not get around to it for a while.

bknueven commented 6 months ago

I do have macOS 14.5 with an ARM chip. But I cannot reproduce this issue. I have attached the output of conda list in case it is useful. watertap_env.log

EDIT: Further, I cannot find the missing library in the places the error message says it looks.

fahim831 commented 6 months ago

@Robbybp Thank you, I will see how I can update that path and to what, after I try installing some of the packages in the other comment.

@bknueven Thank you. Maybe I will try installing the packages starting with lib and see if the required library gets installed among those.

adowling2 commented 6 months ago

I've had to use LD PATH to get solver executables to work when not doing import idaes on an M1-Mac.

fahim831 commented 6 months ago

After searching the issue a bit more, adding the DYLD_LIBRARY_PATH seemed to be a risky thing to do. Since I only needed that one file, I went to /opt/X11/lib, where the libX11.6.dylib file was, and manually just copied it to /usr/local/opt/libx11/lib based on the error message's list of places it looked at before returning the error. It works now. Thanks, everyone.

dangunter commented 6 months ago

Maybe adding the flag mentioned here to the configuration of the build will help: https://lists.mcs.anl.gov/pipermail/petsc-users/2020-April/040728.html

eslickj commented 6 months ago

I think you can use install_name_tool to change where an executable looks for a library. Then you don't need to set DYLD_LIBRARY_PATH. I don’t remember PETSc linking X11. If there is a new build, I wonder in configure picked up X11 just because it’s there on whatever its being built on.

eslickj commented 6 months ago

https://github.com/IDAES/idaes-ext/blob/67ab6e4fb4e3a586271bf43e83a0ae5d94c7b6ef/scripts/compile_solvers.sh#L472

That’s the section that copies the dependencies from homebrew. X11 isn’t there. And I don’t think it was previously a dependency, but i guess license permitting it could be added.

Get-extensions has a —release option. You could try to go back to previous releases to see if they work.

adowling2 commented 6 months ago

@fahim831 another option to try instead of copying the file is to make a symbolic link. (I'm posting here in case someone in the future comes across this issue.)