openhab / openhabian

openHABian - empowering the smart home, for Raspberry Pi and Debian systems
https://community.openhab.org/t/13379
ISC License
818 stars 251 forks source link

nodejs and npm are conflicting packages to be installed in nodejs-apps.bash #1840

Closed WolfgangSn closed 4 months ago

WolfgangSn commented 4 months ago

Issue information:

nodejs and npm are to be installed together in nodejs-apps.bash since code introduction of

      if cond_redirect apt-get --quiet install --download-only --yes nodejs npm; then echo "OK"; else echo "FAILED"; return 1; fi
      if cond_redirect apt-get install --yes -o DPkg::Lock::Timeout="$APTTIMEOUT" nodejs npm; then echo "OK"; else echo "FAILED"; return 1; fi

According to apt info nodejs these are conflicting packages and can't be installed together.

Package: nodejs
Version: 18.17.1-deb-1nodesource1
Priority: optional
Section: web
Maintainer: Operations Nodesource <operations@nodesource.com>
Installed-Size: 177 MB
Provides: nodejs-dev, nodejs-doc, nodejs-legacy, npm
Depends: libc6 (>= 2.28), libatomic1 (>= 4.8), libgcc1 (>= 1:3.5), libstdc++6 (>= 5.2), python3-minimal, ca-certificates
Conflicts: nodejs-dev, nodejs-doc, nodejs-legacy, npm
Replaces: nodejs-dev (<= 0.8.22), nodejs-legacy, npm (<= 1.2.14)
Homepage: https://nodejs.org
Download-Size: 25.9 MB
APT-Manual-Installed: yes
APT-Sources: https://deb.nodesource.com/node_18.x bookworm/main armhf Packages

See also https://community.openhab.org/t/unable-to-install-frontail-on-fresh-install-oh-4/153751/3

mstormi commented 4 months ago

@Larsen-Locke you introduced that in https://github.com/openhab/openhabian/commit/4e8f73154021a3c8e1fdb23f84bb8edad202b0d8

Can you please revoke or fix it ?

Larsen-Locke commented 4 months ago

o.k. I made a PR which changes back like it was before (install only nodejs). I'm absolutely confused: Because of bookworm I added npm because npm was not automatically installed together with nodejs. Maybe somebody with more knowledge about nodejs should help here. Maybe we should remove all this keyring-stuff. But then I think it doesn't work with buster.

mstormi commented 4 months ago

o.k. I made a PR which changes back like it was before (install only nodejs).

ok thanks I merged it.

Maybe we should remove all this keyring-stuff. But then I think it doesn't work with buster.

No we should not. Using keyring-protected repos is a fundamental build principle.

Check out the bookworm openHABian build (the new 3rd downloadable image) if it contains npm or works without, then if required add conditional install of npm on bookworm only.

mstormi commented 4 months ago

@Larsen-Locke BATS build check failing because of missing npm. https://github.com/openhab/openhabian/actions/runs/7854205779/job/21434704483#step:8:276

I'm not sure. I think it's a debian bug that nodejs and npm cannot be installed together but I don't know how to handle this other than to wait that the debian (or RaspiOS?) people find out.

Can you split it into two commands install nodejs first then npm second ? Make sure to continue in the script should any of them fail. Please test before making it a PR.

WolfgangSn commented 4 months ago

May I kindly ask why nodejs and npm are needed together ? In the past only nodejs was installed and everything is working. Just would like to better understand the problem.

Larsen-Locke commented 4 months ago

nodejs is included in bookworm but without npm. This was an attempg (not working) for a solution that works with all different debian versions. "Everything is working" is relative. We need it working for all different os

mstormi commented 4 months ago

If I understand correctly it was not needxed to install npm on pre-bookworm. So I suggest to keep the code to install nodejs, then check for an installed npm and only install it when it's not there. That should work on bookworm while not break install on any other distro, or am I overlooking something ?

Larsen-Locke commented 4 months ago

No we should not. Using keyring-protected repos is a fundamental build principle.

Nobody wants to remove package protection. But we don't need to import keys if already included in the os. Check out the bookworm openHABian build (the new 3rd downloadable image) if it contains npm or works without, then if required add conditional install of npm on bookworm only.

As I said: In bookworm npm has to be installed with an apt-get install -y npm. Just add that and it should be fine. Sorry I cannot help at the moment.

Larsen-Locke commented 4 months ago

If I understand correctly it was not needed to install npm on pre-bookworm.

yes. Because it's installed with nodejs. Don't ask me why npm is sometimes installed with nodejs and sometimes has to be installed seperately. But I checked twice.

I think too that the best we can to is an additional apt-get install -y npm if the os is bookworm

WolfgangSn commented 4 months ago

@Larsen-Locke

"Everything is working" is relative. We need it working for all different os

I am sorry for the wording "everything". I was in a hurry when I wrote that entry. What I wanted to say is that functionality is available on my system - and yes - you are right it needs to work in all different OSs.

Did a quick analysis and I think I now have a more clear picture why it works in my case, why not for others and why the error pops up.

In my case neither nodejs nor npm was installed when I started to use the beta bookworm image. So openhabian-config installed nodejs from deb.nodesource.com. This installation contains npm related stuff in the nodejs package.

Looking into the bookworm distribution indeed nodejs does not contain npm.

So as far as I understand if npm is already installed from OS installing nodejs from deb.nodesource.com it will complain about the installed npm.

mstormi commented 4 months ago

It's impossible to track workings of a package/feature such as frontail across all variants of images, repos, distros, even more so as with repos and packages ever changing, it's a moving target.

I've now changed code to install npm whenever it isn't there right after nodejs installation. The Github cloud install worked incl. the BATS test (which among others is attempting to install frontail). It still fails but would have passed if there hadn't been an issue with another package, but that's not related to node/npm.

Please validate if possible.

mstormi commented 4 months ago

As there was no further feedback I assume it's currently working. Reopen here if not.