arduino / arduino/Arduino

Updating/Downgrading Arduino-Pico core fails at file extraction

Open
#11,842 4 comments 2 reactions 1 assignee Claimed by @per1234 View on GitHub
Type: Bug Waiting for feedback
Dominant language
Java
Stars
14.6k
Forks
7k
PR merge metrics
No merged PRs in 30d

Description

## Versions
Arduino IDE: Latest 1.8.19
OS: Windows 11 x64, (`ver`: `Version 10.0.22000.1219`), in Oracle VirtualBox from [Microsoft](https://developer.microsoft.com/de-de/windows/downloads/virtual-machines/)
[Arduino-Pico](https://github.com/earlephilhower/arduino-pico): 2.6.3 -> 2.6.1

## Description

Per https://github.com/earlephilhower/arduino-pico/issues/976.

Users report that when upgrading or downgrading the Arduino-Pico core from 2.6.1 to 2.6.3 (or reverse), updating of the core would fail at the Python interpreter. This leaves the Python interpreter package folder without some crucial files without which it cannot start, and so users get a
```
Fatal Python error: initfsencoding: unable to load the file system codec
ModuleNotFoundError: No module named 'encodings'
```
when attempting to further compile something.

## Reproduction

The steps I used (some may not be needed though):
1. Install the Arduino IDE from the .zip package for Windows
2. Install Arduino-Pico's latest version [as described](https://github.com/earlephilhower/arduino-pico#installing-via-arduino-boards-manager)
3. Compile a blink sketch for the Pico. It should compile normally
4. Close the Arduino IDE
5. Install Python3 from https://www.python.org/downloads/, tick the checkmark for "Add python to PATH"
6. Reopen the Arduino IDE
7. Go to the board manager to downgrade the RP2040 core to 2.6.1

## Expected Behavior

The downgrade is done successfully.

## Actual behavior

The downgrade fails with

![grafik](https://user-images.githubusercontent.com/26485477/204144595-ace17b95-f128-424d-9a83-3a17d11d6dda.png)

Exception text
```
Can't extract file C:\Users\User\AppData\Local\Arduino15\packages\rp2040\tools\pqt-python3\1.0.1-base-3a57aed\_ctypes.pyd, file already exists!
java.lang.RuntimeException: java.io.IOException: Can't extract file C:\Users\User\AppData\Local\Arduino15\packages\rp2040\tools\pqt-python3\1.0.1-base-3a57aed\_ctypes.pyd, file already exists!
at cc.arduino.contributions.packages.ui.ContributionManagerUI.lambda$onInstallPressed$2(ContributionManagerUI.java:179)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.io.IOException: Can't extract file C:\Users\User\AppData\Local\Arduino15\packages\rp2040\tools\pqt-python3\1.0.1-base-3a57aed\_ctypes.pyd, file already exists!
at cc.arduino.utils.ArchiveExtractor.extract(ArchiveExtractor.java:215)
at cc.arduino.utils.ArchiveExtractor.extract(ArchiveExtractor.java:82)
at cc.arduino.contributions.packages.ContributionInstaller.install(ContributionInstaller.java:141)
at cc.arduino.contributions.packages.ui.ContributionManagerUI.lambda$onInstallPressed$2(ContributionManagerUI.java:172)
... 1 more
```

The Python folder is half-deleted / upgraded, with many files missing, crippling it so heavily that `python3.exe` cannot start anymore.

![grafik](https://user-images.githubusercontent.com/26485477/204144641-1b25707c-554f-4876-909e-170ad0e4aa15.png)

Should look like

![grafik](https://user-images.githubusercontent.com/26485477/204144670-d792688d-788e-4a37-b694-214faccfacdb.png)

## Additional context

### Additional reports

- https://forum.arduino.cc/t/modulenotfounderror-no-module-named-encodings/1194694
- Note this user is using Arduino IDE 2.x

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.