-
-
Notifications
You must be signed in to change notification settings - Fork 431
Prevent overwriting existing libraries and platforms at first IDE start-up #1169
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
Conversation
1db02e9
to
69de5e5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code looks good to me.
Thank you for the cleanup and extracting the logic into a standalone contribution. 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AlbyIanna it is working great for me. I did run into a problem while testing, but it turned out to be a pre-existing bug not related to the changes made here (#1192).
I do have one question though: I notice that if the "Arduino AVR Boards" platform installation fails due to there being a pre-existing installation, the installation of the "Arduino_BuiltIn" library never happens:
Failed to install platform: arduino:avr.
Error: 2 UNKNOWN: Platform arduino:avr@1.8.4 already installed: could not overwrite
The primary purpose of this installation is to provide the expected boards and libraries on a fresh install. If there is already a pre-existing installation of "Arduino AVR Boards" then it is not a fresh install and so the library installation is not so important. That, as well as the unresolved issue with those libraries unexpectedly getting priority under certain conditions (#1055) makes me fine with the libraries installation being skipped in this case, so I don't think this needs to be addressed.
However, I would be concerned if the reverse of that behavior (skipping the "Arduino AVR Boards" platform installation if the "Arduino_BuiltIn" library installation failed) could occur, since the platform installation is more important and also no longer potentially disruptive after the change made in this PR. Is it possible that could happen, or is the order of the platform installation followed by the library installation guaranteed by the code? I have not produced such behavior in my tests.
I can confirm that the order of the platform installation followed by the library installation, so this scenario shouldn't be possible.
But this behavior was not expected. It should be easy to fix 🔨 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My sole concern has been allayed and everything worked just fine during my testing. So this is a 👍 from me.
Thanks Alberto!
Please use |
69de5e5
to
1b214e7
Compare
I've upgraded arduino-cli to |
await this.localStorageService.setData( | ||
InitLibsPlatforms.INIT_LIBS_AND_PACKAGES, | ||
true | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you changed the logic with the try{} catch{}
; why do not IDE2 sets this flag after the installation.
Potential issue:
- Is it the first start? yes,
- Store that the libs and AVR were installed,
- Install the libs and AVR,
- It fails,
- Next IDE2 start; is it the first start? No, but nothing is installed.
What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Is it the first start? yes,
- Store that the libs and AVR were installed,
- Install the libs and AVR,
- It fails,
- Next IDE2 start; is it the first start? No, but nothing is installed.
This behavior is expected in my opinion.
As @per1234 stated here above:
The primary purpose of this installation is to provide the expected boards and libraries on a fresh install.
This, I believe, means that we should try to install built-in cores and libraries only once (during the first start-up), even if the installation fails because of pre-existing installations.
Does it make sense?
If we all agree with the behavior above, then I see no value in moving the setting of INIT_LIBS_AND_PACKAGES after the installation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This behavior is expected in my opinion.
Another use case:
- User has a fresh env and will open the IDE2 for the very first time,
- No internet connection,
- Install will fail but IDE2 stores that the install was already run,
- User starts the IDE2 the second time with an Internet connection,
- Nothing will happen.
If this is expected, please proceed with the merge.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was just doing some investigation into this.
As Akos mentioned, there are two distinct types of failure during this process:
- Intended failure when the installation would result in an overwrite
- Unintended failure due to something like no Internet access (Communicate first run Internet access requirement to user #784)
The installation should never be attempted again in the event of the former type of failure, but the IDE does really need to eventually be able to handle the latter gracefully. That could be in the form of clearly communicating about the problem to the user and leaving it up to them to use Boards and Library Manager to make the failed installations, or handling it automatically by trying again on the next restart.
The lack of handling for the latter type of failure was a pre-existing issue, so it is only the former type of failure that is of direct concern to this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, that makes sense! But in that case, moving the initialization of INIT_LIBS_AND_PACKAGES is not enough. I will work on a fix! Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
UPDATE: Fixed by 6c4482f
Failed to install platform: arduino:avr.
Error: 2 UNKNOWN: Platform arduino:avr@1.8.4 already installed: could not overwriteFailed to install library: Arduino_BuiltIn:1.0.0.
Error: 2 UNKNOWN: Library SD@1.2.4 is already installed, but with a different version: SD@1.2.3
Expected:
Failed to install platform: arduino:avr.
Error: 2 UNKNOWN: Platform arduino:avr@1.8.4 already installed: could not overwrite
Failed to install library: Arduino_BuiltIn:1.0.0.
Error: 2 UNKNOWN: Library SD@1.2.4 is already installed, but with a different version: SD@1.2.3
I've added some logic to better handle errors here. Now I'm setting Please @per1234 @kittaakos check it again and tell me if this is what you expected 🙏 I've also added a new line in the error messages printed in the output panel. |
arduino-ide-extension/src/browser/contributions/init-libs-platforms.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
Motivation
The first time the IDE is launched, it has a mechanism in place to automatically install the most common libraries and platforms, in order to deliver a better out-of-the-box experience for a majority of users.
Right now though, this process would overwrite libraries and platforms that were previously installed by the user.
Change description
--no-overwrite
flag of the arduino-cliOther information
Reviewer checklist