home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
71.07k stars 29.73k forks source link

ADS integration Exec format error on latest docker #74067

Open jandeschuttere opened 2 years ago

jandeschuttere commented 2 years ago

The problem

When starting the latest docker on a raspberry pi 4 the ADS integration seems to be broken, sounds like a build problem targeting the wrong architecture.

I've had a couple of issues (like MySql 8 suddenly requiring the mysql_native_password plugin instead of the previously already working caching_sha2_password) which I was able to work around but this one is blocking for me as it completely breaks the integration with my Beckhoff which is at the heart of my home control.

Labels provided through this image are:

"io.hass.arch": "armv7",
"io.hass.base.arch": "armv7",
"io.hass.base.image": "homeassistant/armv7-base:3.16",
"io.hass.base.name": "python",
"io.hass.base.version": "2022.06.0",
"io.hass.machine": "raspberrypi4",
"io.hass.type": "core",
"io.hass.version": "2022.7.0.dev20220627",
"org.opencontainers.image.authors": "The Home Assistant Authors",
"org.opencontainers.image.created": "2022-06-27 03:32:54+00:00",
"org.opencontainers.image.description": "Open-source home automation platform running on Python 3",
"org.opencontainers.image.documentation": "https://www.home-assistant.io/docs/",
"org.opencontainers.image.licenses": "Apache License 2.0",
"org.opencontainers.image.source": "https://github.com/home-assistant/core",
"org.opencontainers.image.title": "Home Assistant",
"org.opencontainers.image.url": "https://www.home-assistant.io/",
"org.opencontainers.image.version": "2022.7.0.dev20220627"

Labels of the image that is still working for me:

"io.hass.arch": "armv7",
"io.hass.base.arch": "armv7",
"io.hass.base.image": "homeassistant/armv7-base:3.14",
"io.hass.base.name": "python",
"io.hass.base.version": "2022.02.0",
"io.hass.machine": "raspberrypi4",
"io.hass.type": "core",
"io.hass.version": "2022.6.0.dev20220506",
"org.opencontainers.image.authors": "The Home Assistant Authors",
"org.opencontainers.image.created": "2022-05-06 03:33:40+00:00",
"org.opencontainers.image.description": "Open-source home automation platform running on Python 3",
"org.opencontainers.image.documentation": "https://www.home-assistant.io/docs/",
"org.opencontainers.image.licenses": "Apache License 2.0",
"org.opencontainers.image.source": "https://github.com/home-assistant/core",
"org.opencontainers.image.title": "Home Assistant",
"org.opencontainers.image.url": "https://www.home-assistant.io/",
"org.opencontainers.image.version": "2022.6.0.dev20220506"

What version of Home Assistant Core has the issue?

core-2022.7.0.dev20220627

What was the last working version of Home Assistant Core?

core-2022.6.0.dev20220506

What type of installation are you running?

Home Assistant Container

Integration causing the issue

ADS

Link to integration documentation on our website

https://www.home-assistant.io/integrations/ads/

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

These is just one snippet of the many similar issues reported, figured this stacktrace is sufficient:

ERROR (MainThread) [homeassistant.config] Platform error: light
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/loader.py", line 618, in get_platform
    cache[full_name] = self._import_platform(platform_name)
  File "/usr/src/homeassistant/homeassistant/loader.py", line 635, in _import_platform
    return importlib.import_module(f"{self.pkg_path}.{platform_name}")
  File "/usr/local/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 992, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/usr/src/homeassistant/homeassistant/components/ads/__init__.py", line 10, in <module>
    import pyads
  File "/usr/local/lib/python3.10/site-packages/pyads/__init__.py", line 12, in <module>
    from .ads import open_port, close_port, get_local_address, read_state, \
  File "/usr/local/lib/python3.10/site-packages/pyads/ads.py", line 18, in <module>
    from .pyads_ex import (
  File "/usr/local/lib/python3.10/site-packages/pyads/pyads_ex.py", line 82, in <module>
    _adsDLL = ctypes.CDLL(adslib)
  File "/usr/local/lib/python3.10/ctypes/__init__.py", line 374, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: Error loading shared library /usr/local/lib/python3.10/site-packages/pyads/adslib.so: Exec format error

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config.py", line 877, in async_process_component_config
    platform = p_integration.get_platform(domain)
  File "/usr/src/homeassistant/homeassistant/loader.py", line 627, in get_platform
    raise ImportError(
ImportError: Exception importing homeassistant.components.ads.light


### Additional information

_No response_
BeezLoisbert commented 1 year ago

Hey guys,

are there any positive reports regarding the problem?

alemonta commented 1 year ago

Unfortunately, also with core 2023.3.0 still the same issue...

BeezLoisbert commented 1 year ago

Unfortunately i am not familiar with the development of home assistant.

Is there any information whether this problem has already been dealt with?

Unfortunately, 9 months have passed and the problem still exists :(

alemonta commented 1 year ago

Home Assistant 2023.4.5 Supervisor 2023.04.0 Operating System 10.0 Frontend 20230411.1 - latest

Still bugged.

reib3n commented 1 year ago

Hello guys, as this Issue still persists, I now switched from ADS to Modbus communication with my CX8190. It is ab bit more complex and slower as ADS but it works for my scenarios.

jowies01 commented 1 year ago

Spinned up a new Home Assistant Yellow Deployment ( on version 2023.5.2 ) problem still exist and work-arround did not work because there was no version 2022.6.7 because the Yellow implementation only started on 2022.7.0

Any sugestion to a solution?

jandeschuttere commented 1 year ago

I expect all distribution types of Home Assistant are having pip as part of the command line (for those using docker, don't forget to first go into the running docker container). You could try pip install pyads, that should install it for you. After that was successful you can restart the Home Assistant instance and it should have registered.

I'm sorry to not be able to investigate the root problem further, time has not been, and is still not, on my side I'm afraid

jowies01 commented 1 year ago

Pip is indeed installed but in the container there is no 'make' so installation of pyads was failing

In the mean time, I've installed an older version of homeassistant ( not yellow specific ) and did the quick & dirty trick... after restart it was working again.

lgroen91 commented 1 year ago

Hi All,

Having the same issue while integrating my Beckhoff CX1010 into home assistant. Finally i fixed this by putting the complete integration in Node Red.

I’ve used the node-red-contrib-ads-client for adding the ADS functionality to my Home Assistant.

Hopefully this will help some of you to get ADS running again.

Running: Home Assistant 2023.6.3 Supervisor 2023.06.4 Operating System 10.3 RPI 3

BeezLoisbert commented 1 year ago

Hi All,

it's still not working ...

Unfortunately, I don't have enough programming skills to fix the problem at the source.

So I'll keep hoping for a miracle

Greets

BeezLoisbert commented 12 months ago

Hi All,

the problem still exists under Core Version 2023.9.1

Greets

jarisinisalo commented 11 months ago

For those looking for a (dirty) workaround the package from the working version is compatible it seems with the new release. Assuming you are using docker the following steps might help you out until this gets a fix:

Given: containerA is the name of your working container, containerB is the name of the new container with the faulty adslib.

docker cp containerA:/usr/local/lib/python3.9/site-packages/pyads /tmp
docker stop containerA
docker start containerB
docker cp /tmp/pyads containerB:/usr/local/lib/python3.10/site-packages/
docker restart containerB

If you are not using docker, the digest is basically.. take the pyads lib from the working version, copy it in the location that the new homeassistant build is using.

Is this workaround still working in python3.11? Have you guys tried? Can't seem to get it working anymore.

SaWey commented 10 months ago

Just making an update here to let you know I might have found the reason and solution. See https://github.com/home-assistant/wheels/issues/458#issuecomment-1763185835 and https://github.com/stlehmann/pyads/pull/363

The core ads library version will need to be bumped when the pull request has been merged.

alemonta commented 10 months ago

For those looking for a (dirty) workaround the package from the working version is compatible it seems with the new release. Assuming you are using docker the following steps might help you out until this gets a fix: Given: containerA is the name of your working container, containerB is the name of the new container with the faulty adslib.

docker cp containerA:/usr/local/lib/python3.9/site-packages/pyads /tmp
docker stop containerA
docker start containerB
docker cp /tmp/pyads containerB:/usr/local/lib/python3.10/site-packages/
docker restart containerB

If you are not using docker, the digest is basically.. take the pyads lib from the working version, copy it in the location that the new homeassistant build is using.

Is this workaround still working in python3.11? Have you guys tried? Can't seem to get it working anymore.

Hi, I confirm it still works with python 3.11, it's just matter of matching the destination folder accordingly:

docker cp /tmp/pyads containerB:/usr/local/lib/python3.11/site-packages/

A.

BeezLoisbert commented 10 months ago

Just making an update here to let you know I might have found the reason and solution. See home-assistant/wheels#458 (comment) and stlehmann/pyads#363

The core ads library version will need to be bumped when the pull request has been merged.

Hey,

that sounds really good!

Does anyone know how long it usually takes for the request to be implemented?

I wait happily :D

gibii88 commented 8 months ago

Hi, Is there any news about it? Do we know if it has already been released?

Thanks!

alemonta commented 8 months ago

Hi, Is there any news about it? Do we know if it has already been released?

Thanks!

at the moment nothing changed: Core 2023.12.3 Supervisor 2023.12.0 Operating System 11.2 (RBPI4) The issue is still there, the workaround described above (copying the old working pyads libs from python 3.9 into python 3.11 folders) is still valid. 🤷‍♂️

jowies01 commented 8 months ago

Some news on the release?

drindal82 commented 6 months ago

I really really need this to work. any news?

KCU1976 commented 6 months ago

I really really need this to work. any news?

I "solved" the issue for me by switching to an Intel based pc (old NUC) so I don't have to patch every time. It has the added benefit of being a lot faster and not running out of ram when compiling esphome things . Perhaps you can do the same?

jandeschuttere commented 6 months ago

SaWey is doing a great job at getting it through the process, the PR of the issue in the external package was merged. 2 days ago there was someone looking at trying to release it but was not yet able to do so, I would expect that a resolution is imminent. Great work @SaWey!

drindal82 commented 5 months ago

SaWey is doing a great job at getting it through the process, the PR of the issue in the external package was merged. 2 days ago there was someone looking at trying to release it but was not yet able to do so, I would expect that a resolution is imminent. Great work @SaWey!

any news on a release date?

gibii88 commented 5 months ago

I don't understand if the PR is approved or not..any update?

kwiatkowskimarcinb commented 5 months ago

It still doesn't work on the latest Home Assistant Core 2024.3.3 on Home Assistant Green Hardware.

@homeassistant - can we do something about it, as the root cause seems to be known:

HA has changed the way they manage dependencies, which caused the problem on most systems."

and ads is a core integration?

alemonta commented 5 months ago

News on this issue: Allow for platform dependent builds ADS Component error: Exception importing homeassistant.components.ads

BartDurnez commented 2 months ago

Issue fixed, this topic can be closed. Working fine now with latest home assistant core build.

See Bump pyads to 3.4.0 #116934

Great work!