Sometimes we mess up the system by experimenting and loiting around core parts of the code. Apparently I did the same. As I am currently working on integrating Clap-st with the commandline, I happened to fiddle with session manager and activate methods. And the result was I broke the image and whenever I try to open it, the image opens and closes immediately. The foolish thing I did here was I didn`t commit the code and this is the main problem.
So after a bit of searching different sources I was able to recover my image. So to help someone in the future, in this blog post I would like to go through the ways to recover the image and get your lost code back in case you break it too like me.
Method 1: Use the Pharo.changes
This is one of the simplest methods. But with this method you need to have knowledge on the mistake you made. So as to change it. This is how this method works,
- Copy or change the Pharo.changes file name with an .cs extension. Like Pharo.cs
- Download a new image.
- Open the new image.
- Drag the .cs file created in step 1 onto the new image. (or open the file from World menu > Tools > File Browser)
- Use the change browser option to retrieve all the code you wrote. or install the changes.
Problem: But sometimes you won`t be able to install the changes due to the same mistake because of which the image broke in the first place. So, a quick work around is to use the change browser and there is another problem with this, you need to manually copy the code contents and create new methods. Overall this is the easiest and safest way.
Method 2: Use Epicea
Epicea is the latest code changes tool which tracks all the changes you make. Epicea is buitl with Ombu sessions, these sessions are stored on your computer and every codec change is tracked and stored. So, this is an easy way to recover the lost code. Epicea comes installed with Pharo 6.0. Go run Epicea, go to World menu > Tools > Code Changes. If you are on linux and in case you encounter an error saying “Error- cannot locate cairo library” simply do ‘sudo apt-get install libcario2:i386’. This should solve the error. The steps to use Epicea is as follows
- Same as above, grab a new image from the pharo file server.
- Open the image and run Code Changes ( World menu > Tools > Code Changes)
- On the left corner click on the file browser, go to the folder in which your previous image is there and navigate to the directory “pharo-local” and then selecct ‘ombu-sessions’.
- Baam!! All the changes you made are there, you can go through and apply them to the new image one by one.
- With Epicea you can also browse the code without applying, comment a change, file out the code and filter all the changes with various options available.
Method 3: Using Oz Object Spaces
This is an old tool usually called as Oz Recovery Tools and doesn`t exist currently. But this is a cool one. This tool was built by my mentor Guille sometime back in 2013. You can checkout about Oz and how it works on his blog.
Method 4: The obvious one “Go into the VM and hack it”
I am not so familiar how this is done. But while searching I found a link to a discussion on the mailing list, where one of the contributor Sean P. DeNigris had a broken image and he went into the source code and made the changes.
Method 5: Using the commandline handler eval
I found another discussion on the mailing list where one of the contributor Bernat Romagosa had a similar problem and he has an easy solution. So to recover, go to the terminal and run the command
eval "SmalltalkImage current backupTo: 'recover'". This will make a copy of the image into a new image called “recover.image”. And this image will not have the default execution unlike saveAs so you will have the image back and you should make corresponding changes to make sure it won`t break again.
These are a few good resources I found. Do comment if there is anything wrong in my post or in case you know a new method to recover a broken image. Always open to feedback or comments.