microsoft / pxt-microbit

A Blocks / JavaScript code editor for the micro:bit built on Microsoft MakeCode
https://makecode.microbit.org
Other
721 stars 590 forks source link

Windows Store app cannot open old files #4931

Closed martinwork closed 1 year ago

martinwork commented 1 year ago

Describe the bug Arising from support ticket https://support.microbit.org/helpdesk/tickets/60133 (private)

Having used the Windows Store app about 2 years ago to create a large number of projects, most will now not load. No hex files were saved. There are error messages:

Extension Errors /Looks like there are some errors in the extensions added to this project. How would you like to proceed?/Try to fix/Ignore errors and open

Neither option works.

Most of the files that have been opened are missing most or all of the code, so trying more is not really an option.

I have installed the old app, and see the same About box as them. The versions tagged are very recent. Could the update to https://github.com/Microsoft/pxt-microbit/releases/tag/v4.0.24 (Nov 18, 2022) have broken the app for loading old files?

I have found my code in the folders inside C:\Users\USERNAME\AppData\Local\Packages\MicrobitEducationalFounda.196216C47839B_e88r6s0b2swar\LocalState\microbit Is there a good way to turn that into a hex file, given that they have a lot of files!

Any help with recovering the old code would be greatly appreciated.

Expected behavior Able to load files created in the app.

Screenshots image

micro:bit version (please complete the following information): not hardware related

Desktop (please complete the following information):

martinwork commented 1 year ago

@abchatra?

martinwork commented 1 year ago

It may be relevant to understand what has happened, to know that the user had installed the new app. If I am understanding correctly, the projects are now in folder AppData\Local\Packages\MicrosoftCorporationII.MicrosoftMakeCodeformicrobi_8wekyb3d8bbwe whereas a recent backup has the projects in AppData\Local\Packages\MicrobitEducationalFounda.196216C47839B_e88r6s0b2swar

abchatra commented 1 year ago

@martinwork All the code should be as is in main.ts. C:\Users\USERS\AppData\Local\Packages\MicrobitEducationalFounda.196216C47839B_e88r6s0b2swar\LocalState\microbit\Flashing-Heart-7\main.ts

They should be able to copy paste the code.

abchatra commented 1 year ago

Also I am unsure how they are loading this files? Can you ask more info?

martinwork commented 1 year ago

Thanks @abchatra. Yes, I've described copy & paste from main.ts in Javascript mode, and looking at pxt.json for which extensions were used. I was hoping for something easier!

I'm don't know what you mean by "how they are loading this files". I think they have launched the old store app that they used 2 years ago, and tried to open an old project from the home page as usual.

I could be misunderstanding, but the strange part is that the projects seem to have moved to MicrosoftCorporationII.MicrosoftMakeCodeformicrobi_8wekyb3d8bbwe on their computer, though they find them in MicrobitEducationalFounda.196216C47839B_e88r6s0b2swar on their backup. made before they added the new store app.

I'll check...

abchatra commented 1 year ago

Interesting. I am not sure why projects would have moved unless they copied manually.

martinwork commented 1 year ago

Yes, they didn't copy across when I installed the new app.

MoJeeza commented 1 year ago

Gentlemen: Ok, so here is the timeline (to the best of my recollection). Jan 27,2023 - I perform an image backup of my c: drive Jan 30, 2023 - sometime on that day, I launch the old Microsoft Store App which gives me a notification at the top of the screen: "This app is no longer supported. For the latest updates, click here" to install our new app! Learn More <-- "click here and Learn More" are links So I click and a new app is installed. Also confirmed by "Add or Remove Programs" in Windows system Settings. Old App install date: 2018-04-19 Size: 137Mb New App install date: 2023-01-30 Size: 604Kb

At no time did I get a prompt to overwrite the old install or a choice of where to install or to save old settings (the usual questions one would expect when upgrading). It just continued and installed. I think the only option was if I wanted to create shortcuts on the desktop or "start" and "task bar". Which I confirmed.

Of course then I launched the New app and found nothing listed. Went into a total mental breakdown (???)...where are my projects?

Went back to the old App and saw hundreds of my projects.

So the natural instinct is to click on one to open...clicked on the the first icon (which I guess was the last project I had accessed). It took a while to open and when it did:

Pop up screen shows:

Extension Errors Looks like there are some errors in the extensions added to this project.

How would you like to proceed? Try to fix Ignore errors and open

So, I tried both options. And the result was heart stopping - virtually blank project - I have the "start" block and 3 other blocks to setup my wifi (for the esp8266 module)

So this was a complex project that collected environment data (dust, humidity, temperature, etc...) and using RTC send data over wifi to ThingSpeak portal.

MicrosoftCorporationII.MicrosoftMakeCodeformicrobi_8wekyb3d8bbwe <-- this folder's creation date matches the installation date/time of the New App. HOWEVER this folder structure matches closely (not exactly) with the one mentioned below: Except that there is no folder named "microbit" under the folder "LocalState".

MicrobitEducationalFounda.196216C47839B_e88r6s0b2swar <-- this folder's creation date is 2018-04-19 and last modified date of 2020-08-15. (which matches the last project modified date when I list projects by "last modified" date in the "view all" of the App) Except there is one project that is listed in the App with a recent modified date and that is the one that I tried to open and lost all the code as explained above. So if I sort the project folders on my backup disk image file the project whose code I lost was the last project touched (2020-12-07) but in the app that is showing as modified recently.

All my original projects are under: C:\Users\xxxxx\AppData\Local\Packages\MicrobitEducationalFounda.196216C47839B_e88r6s0b2swar\LocalState\microbit

So to answer your question: No I did not move any files - in fact it was Martin who pointed out where the projects were stored. I had no idea where they were.

Let me know if you need further details. Hope this helps. Your dedication to resolve this is greatly appreciated. Kind regards

martinwork commented 1 year ago

@abchatra @MoJeeza

Having seen one of the projects, I suspect that it doesn't open because an included extension did not specify the versions of it's dependencies, and a dependency has changed its API. So the old included extension version is pulling in a newer dependency with a changed API, which creates errors in main.ts.

Unfortunately MakeCode leaves the project with a blank main.ts.

I suppose one possibility would be to switch to Javascript mode with the errors listed, as happens when the Javascript is pasted into a new project.

Should MakeCode avoid loading dependencies with tags that are more recent than the parent extension tag? Is the tag date known?

Should extensions always specify the versions of dependencies?

abchatra commented 1 year ago

I will close this as this is an issue with the extension. Can extension be updated to new API's?

martinwork commented 1 year ago

@abchatra The root problem was that a dependency without a version specified had made breaking changes to it's API. It was the user code that was using the old APIs.

It is unfortunate that MakeCode's reaction to the errors is to delete all the user's code, leaving them with blank javascript, so they don't get a chance to fix the errors.

abchatra commented 1 year ago

@martinwork do you have a repro? I don't think editor deletes the script, it throws errors.