pulp icon indicating copy to clipboard operation
pulp copied to clipboard

The CBC binary artefact appears to be incompatible with Apple silicon and it's seemingly undocumented

Open roganjoshp opened this issue 4 months ago • 3 comments

On a base install, from pulp.apis.listSolvers(onlyAvailable=True) you will get ['PULP_CBC_CMD']. If you try to run this on any simple example with problem.solve(pulp.PULP_CBC_CMD("problem_name")) you will get:

OSError: [Errno 86] Bad CPU type in executable: '/Users/my_name/.pyenv/versions/conway/lib/python3.13/site-packages/pulp/apis/../solverdir/cbc/osx/i64/cbc'

I spent hours trying to solve this. If you search for "python pulp OSError: [Errno 86] Bad CPU type in executable" you will find lots of open threads with suggestions ranging from "use Rosetta" to straight-up trampling the binary on an installation-by-installation basis.

To the best of my knowledge, this isn't documented anywhere. I answered the top search result on SO and the solution is remarkably simple.

If I am missing the reference in the documentation, please direct me to it so I can include it in my answer (and perhaps it needs to be more prominent). If it is missing from the documentation, I'm happy to put in a PR to provide a brief guide on the issue (but please tell me where you think it should live). Finally, I'm not sure if this constitutes a bug, given that the binary being distributed simply won't run on my M4 chip (and seemingly others) and this is unexpected behaviour, particularly for people unfamiliar with all the different solvers that are being wrapped.

roganjoshp avatar Aug 13 '25 09:08 roganjoshp

Thanks.

Believe it or not, we have a dedicated part of the documentation for errors with the cbc binary:

https://coin-or.github.io/pulp/guides/how_to_debug.html#error-while-trying-to-execute-cbc-exe

I'd say that may be a good place to put your alternative through a PR.

Alternatively, you can add a COIN_CMD section here: https://coin-or.github.io/pulp/guides/how_to_configure_solvers.html

pchtsp avatar Aug 13 '25 09:08 pchtsp

Seems like PuLP should not even be trying to execute that pre-packaged binary. I guess there is an issue with how PuLP determines the platform. It should just say that there is no binary available for the current platform (i.e., pulp.apis.listSolvers(onlyAvailable=True) should return []) when the provided binary is incompatible.

With that said, there are binaries available for Apple silicon that could be added to the PuLP repo (https://github.com/coin-or/Cbc/releases/tag/releases%2F2.10.12) to make it work out of the box. Of course, this is not the recommended way of distributing binaries, as has been discussed.

Installing binaries with homebrew is also easy, as noted in the SO answer, but the best way is to install with the conda recipe, which is just conda install pulp. If you don't want to install conda, there is micromamba.

tkralphs avatar Aug 13 '25 17:08 tkralphs

I was with you right up until you mentioned conda and its ilk. I don't want to try install another tool.

i.e., pulp.apis.listSolvers(onlyAvailable=True) should return []

Totally agreed. I would rather it show nothing than give a pretence that something in the base distro should work

To me, an ideal situation would be to have a CLI that forces me to build the core backend for my system. However, that's not very convenient in itself; a better fix may be to throw a warning before the error to suggest that homebrew might work if you detect it's MacOS?

roganjoshp avatar Aug 13 '25 18:08 roganjoshp