Skip to content

[enhancement]: Allow reinstall of adapter if io-packags.json is corrupt #3017

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
1 task done
mcm1957 opened this issue Feb 5, 2025 · 2 comments
Open
1 task done

Comments

@mcm1957
Copy link
Contributor

mcm1957 commented Feb 5, 2025

No existing issues.

  • There is no existing issue for my request.

Description

At froum a user reposrted that he cannot install / upgrade backitup. The reason was a broken io-package.json. He got the following messeg every time he wanted to install the adapter::

host.vm-iobroker02 install adapter backitup
host.vm-iobroker02 error: reading io-package.json /opt/iobroker/node_modules/iobroker.backitup/io-package.json: Unexpected end of JSON input
thorsten@vm-iobroker02:/opt/iobroker$

Related forum topic: https://forum.iobroker.net/topic/79683/backup-l%C3%A4sst-sich-nicht-installieren

The problem is that during an installation request iob tries to detect the currently installed version. As reading i-package.json fails (dur to corrupt file) the installation process aborts. It looks lie even a deinstallation does not really work (but I did not verify this).

I would suggest to adapt th sinstallation code in such a way that every time io-package.json (and eventually other critical files) cannot be read the install command should behave just like it does when performing a reinstallation. (npm deinstall followed be npm install). This would fix such cases and is the expected behavior for a user trying to (re-)install anyway.

Note: As the reinstallation code already dies a removal of the npm / code parts followed by a reinstalltion this fixing would save the current paramater settings and thus have benfits above a iob remove followed by a manual deletion of the node_modules tree too

Why?

User would expect thet the system will try to fix fixable erros when perforing a ne installation / reinstallation attempt

How?

see above

@Apollon77
Copy link
Collaborator

In such speci al cases

  • cd /opt/iobroker
  • npm i iobroker.backitup
  • iob u backitup

in work case also "rm -rf /opt/iobroker/node_modules/iobroker.backitup" if npm has a problem reinstalling

done? ;-)

I am not sure if we need to extra handle that case, but thats just my personal opinion

@mcm1957
Copy link
Contributor Author

mcm1957 commented Feb 6, 2025

Yes this will work of course. But thats NOT a solution for a standard user.

I will not guide a user to use npm directly as this would cause additional problems if used at wrong place while I will for sure try to help in such cases by suggesting to issue an iobroker install xxx command.

As the complete code for (npm) removal and install does already exist at js-controller (see reinstall path) the only extension which should be required is to ignore / catch a parsing error at io-package.json and i.e. assume we have installed 0.0.0 or something like this to let the improvement work. Thats at least my guess without reading the corresponding code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants