My code is gone, help!

So I was working on a project and when I was finally done with my coding session today, I went to push to GitHub like I usually do, when I encountered an unknown error. After that everything started going downhill, I couldn’t push or pull from my repo, and I couldn’t convert my code to blocks anymore. This is a serious issue and I’m worried I might lose all of my code. Anyone, please look into this, I will be grateful for any solution, tips, help or assistance.
And here’s the reposotory

2 Likes

I would suggest saving the project as an image until you can fix it so if you lose it you can just reopen the image in Arcade

2 Likes

But how? The only option it gives me is to save to GitHub.

1 Like

Then press the download button and select any device. The code is also in the .uf2 file you get and can drag it into the editor just like an image.

2 Likes

First, commit your local changes! Then try this

You hit a bug in makecode. Do you remember what you were doing right before the bug happened?

In any case, no worries! You’re using GitHub which means all of your changes from your previous commits are saved. Open the GitHub button and click “History”. Then click one of the dates and click “restore”. This will take your project back in time to that date and restore whatever you had then

Also, this is a non-destructive thing so you can always go back to what you currently have if it doesn’t work out.

2 Likes

Before you go through the steps I mentioned, make sure you commit any local changes you have. THis will make it easier for me to debug it if things go wrong

2 Likes


How do I restore from here?

1 Like

Yeah, well that’s the problem, like I said:

I can’t do anything. You could say I’m stuck in some sort of limbo.

1 Like

Ah, I see. Well try and copy the JavaScript and put it in a file on your computer or paste it here.

2 Likes

As a matter of fact, I already did. It seems for some reason tho that it still won’t convert to blocks. Extention error? Idk but here’s the code-
oh wait the limit is 30000 words and my code has 90000. snap.

1 Like

save it as a .txt file and attach it to your post

2 Likes

Alright, here is your code:

2 Likes

I did but MakeCode forums don’t allow txt files

1 Like

Thank you so much! Some sprites are slightly broken, but that can do with some manual tweaking. Anyways, how were you able to restore this?

1 Like

I took the code and put it into a new project, added the missing extensions, and switched to blocks.

The GitHub project won’t switch to blocks because it has a broken pxt.json file. If you look at the files list, there is an entry that says “null”. I’ve seen this bug a few times but I haven’t been able to figure out what causes it. If you go into the pxt.json and delete this text exactly (including the comma):

Screen Shot 2021-07-21 at 10.20.21 AM

Then it should be able to go back to blocks

2 Likes

I can’t tell you how grateful i am for this, you saved my entire project, not only that it wouldn’t convert but it also wouldn’t run the simulator.

1 Like

No problem! Sorry this happened in the first place. Hopefully I can figure out what’s causing this bug soon.

2 Likes

I would really like to be of use figuring that out by giving some feedback, but I really don’t know what happened. I was just finishing my coding session, I implemented the things I wanted to put in and when I went to save that happened. I think though it might be some kind of request error as it gave me the “check your internet connection” error message. Maybe it couldn’t connect and it mistakenly inserted the null value at that location:

Anyways, thanks again!

1 Like

A bit of advice. I have 3 ways of saving my projects (this always works for me)

  1. Using the Cloud :smiley:
    With the beta editor, I can save my projects to the cloud, so If they get deleted (bc of clearing cookies) I can always get them back :slight_smile:
  2. Saving
    Saving always helps. I save them as an image, so if they get deleted, or if they break, I can insert the image into Makecode :slight_smile:
  3. Links
    I use a google doc (well sometimes) and I paste it inside of it. If they get deleted, I can click the link and edit that code I had.

These work for me (especially with Cboy Azure) so hopefully these can work for you @S0m3_random_guy!

1 Like

These are all good options, there are two more methods I’m aware of:

  • Create a download file for a hardware device. The generated .uf2 file contains a copy of the source code and is loadable via “import” or drag&drop in the editor.

  • Use the share dialog to get an arcade.makecode.com link, and save that link in a document. This link will remain usable even if you don’t end up sharing it in the forum.

As a variant 9f the cut&paste method, you can also store the code in a plain text file and use the git tool to keep local history.

1 Like