2006/09/17

How to handle multiple profiles and installations

When I began working with extensions and attempted to fix some bugs, I always used the same Firefox profile, the one I used for my day-to-day browsing. Of course, why wouldn't I? I didn't know I could have more than one profile. I didn't even know what a profile in Firefox was. But that changed quickly, as I learned how to handle multiple profiles and installations, and my life as a developer was greatly simplified. I can now test my (or somebody else's) extensions without worrying about losing my precious (for me) bookmarks and history. The same applies to bug fixing, alpha/beta testing and general tweaking. It's a powerful resource and you should know about it.
There are several places where you'll find information about this. This post is somewhat redundant, but I think it helps reinforce what's out there, and hopefully I'll be able to give some extra insight about these concepts. A good resource you can read and I used for this post is: How to Manage Profiles, from Mozilla support.
Some definitions
Let's start with the basics. In this post I will frequently refer to profiles and installations, so I should first explain how I define them.
An installation is the actual Mozilla (probably XUL Runner, too) application you install on your system. It can be Firefox, Thunderbird, Sunbird, etc. On Windows systems you will usually find it under "C:\Program Files\Mozilla Firefox" or something of the sort.
A normal user downloads and installs the latest version and then focuses on enjoying it. The auto update feature ensures the user is always up to date, safe and happy. It's a different story with developers and enthusiasts. We usually want to play with the latest versions, even if they haven't been officially released. This is when having multiple installations comes in handy.
Firefox 2 was recently in beta, and as a Firefox fan, I installed it and used it regularly. I started writing this post using Firefox 2 Beta 2, as a matter of fact (yes, I can be very slow). The stable version of Firefox at the time was 1.5.0.7, and I had that one installed too. I also have the latest "bleeding edge" development version of what will become Firefox 3, code name Minefield (warning: very unstable). Add to that the localized Spanish version of 1.5.0.7 and others.
An installation holds all the binaries and libraries required to run the program. On the other hand, profiles hold the user's information, such as bookmarks, history, browsing cache and installed extensions.
Think of your current operating system, such as Windows, Linux or Mac OS. Different users can log in with different user names and passwords, and all the customizations they perform on their system profile are saved independently from other users' profiles. Profiles in Firefox, Thunderbird, etc are similar in concept. You're allowed to have different "sub-users" in the same operating system user account. Each profile will hold its own bookmarks, history, cookies, etc. Everything that is associated with a specific individual will be kept in that profile, independent from other profiles. This way you'll be able to create "disposable" profiles that won't make you cry when you screw up and destroy years of gathering bookmarks in less than a second. Hasn't happened to me so far, I'm just saying...
How to set it up
OK, now let's get to work.
Installing multiple versions of an application on your computer should be easy enough. From now on I'll assume we're talking about Firefox, and that you already have your every-day default installation of Firefox on your computer.
Say you want to install another version of Firefox, such as a localized version or the latest alpha test version. On Windows all you need to do is select the advanced option in the installer, and take two settings into account. First, the installation folder. It should be different from the one in which you have your original installation. All installations should have different folders to avoid overwriting important files. Secondly, shortcuts. You should probably uncheck any shortcut option in the new installation, also to prevent overwriting. On Mac OS, all you need is to have different names for the applications so that one doesn't overwrite the other. Shortcuts are discussed later with more detail.
It's better that you don't run the newly installed version of Firefox until you're done reading the whole post. It may save your data.
Let's create some profiles. The first thing you need to do is run Firefox with the -p argument. On Windows you can do this by right-clicking on a Firefox shortcut (you probably want to make a copy of the shortcut and rename it as Profile Manager), clicking on Properties and adding "-p" (without quotes) at the end of the Target textbox, outside the quoted text. It should now look something like this:
"C:\Program Files\Mozilla Firefox\firefox.exe" -p
Click on Apply and close the Properties window. Close all Firefox windows. Double clicking the icon should open the Profile Manager now.
On other systems the easiest approach is to open a Terminal window and run Firefox with the -p option directly:
./firefox -p
You may need to be in the Firefox installation directory to do this. On Mac OS you don't need to close your Firefox windows to open the profile manager. I think it has something to do with the BSD roots of the operating system and the way it handles processes. Another point in their favor :).
The Profile Manager window looks something like this:

Creating and editing profiles should be easy enough. As a tip, use single words to name your profiles; it's easier to set up the shortcuts later this way.
How to run it
Let's assume that you created a new profile called "test". Note that if you use your original Firefox shortcut (without the -p option) you'll get your usual default profile. That's good because having new profiles shouldn't interrupt your normal browsing experience.
To open your new profile you need to create a shortcut using the -p option, followed by your profile name. On Windows it would be something like this:
"C:\Program Files\Mozilla Firefox\firefox.exe" -p test
Something similar applies to most Linux distributions, as most desktop managers should handle the shortcut concept that supports command line options. I won't list how to do it as there are probably lots of ways to do so.
On Mac OS X things are a little tricky. As far as I know, Mac OS doesn't have anything like shortcuts, so there are two alternatives that I'm aware of. The first one is simply to run firefox from the Terminal window, using a regular console. I don't like it because I'm not a fan of consoles. I wanted to find a way to emulate other architecture's shortcuts, so I finally came up with option number 2: Automator. Automator is a program that comes with Mac OS X, and it allows you to automate a number of tasks and workflows. There's a lot you can do with it, but for now we only care about running our profile. To do this, open Automator, in Applications. On the second column scroll down to an item called Run Shell Script and drag it to the panel on the right. Here's where you should add the script that opens your profile, or the Profile Manager for that matter. It should look something like this:
#!/bin/bash
/Applications/Internet/Firefox/Firefox.app/Contents/MacOS/firefox-bin -p test &

Run it just to check that it works. You can save the workflow anywhere you want. I particularly like the Desktop, because this workflow will in fact work as our shortcut. You'll have to change the default application of the workflow (Ctrl+click on the workflow > Get Info, Open with) so that it opens with Automator Launcher and not Automator. This way you get the full shortcut experience. That should do the trick.
To open the new profile, you need to first close all your Firefox windows (except on Mac OS) and open the new shortcut. If everything worked right, you'll see a Firefox window that looks fresh out of installation.
You've now successfully created a new profile and you're free to use it. You'll have a new set of bookmarks, history, extensions, themes and settings to play with. You'll be able to completely FUBAR this profile with no repercussions to your personal information. You can create as many profiles as you want and do with them as you please. That's one sweet deal in my opinion.
Mixing profiles and installations
Ok, so we're done we've seen how each to them work, now let's see how they work together. First of all I'll clarify that different Mozilla applications use a different set of profiles, so your Firefox information and your Thunderbird information are completely independent. This is kind of expected, but it's good to know.
On the other hand, different flavors of the same applications will use the same sets of profiles. So if you install Firefox 1.5 and Firefox 2 on the same computer, they will in fact use the same profiles. Again, expected, as you don't want users having to migrate information when they upgrade. But this is very important if you're testing alpha versions or localized versions of Firefox in the same computer. These applications come with no guarantee regarding your personal information. They are developer testing versions and should not be used unless you understand you could lose everything.
So here's my advice to you: if you're playing with multiple versions of Firefox (or Thunderbird or whatever): you should create profiles exclusively for these applications. Do not use your main profile for them, as they may be using different storage schemes or pre-production code which may damage your information.
OK, so now let's get to it. It's actually quite simple. If you read all the shortcut juggling how-to, you may have noticed (or already knew) that these shortcuts have two parts: the application, and the additional options, in our case profile selection. As I mentioned at the beginning of this now enormous blog post you should have your installations on different paths, so if you want to open the test profile you created with your other version of Firefox, all you need to do is change the first part of your shortcuts to point to this version. Something like this:
"C:\Program Files\Mozilla Firefox 3 Alpha\firefox.exe" -p test
So if you're a regular alpha tester or builder, and like to get your hands dirty frequently, I would recommend as a general practice to have dedicated profiles for these test versions, and to have specific customized shortcut to access them. Never, ever double click right away on the shortcut of an alpha version unless you know the risk of opening it with your default profile.
This is of course playing if safe, as Firefox engineers don't make a habit out of releasing code that will delete all your information. But people make mistakes, and you should always take that in mind.
It took a long time to write this, so I expect some gaps to exist. Hopefully the basics were covered and at least adequately explained. If you spot any blatant errors, please let me know ;)

Labels: , , ,


Comments:
On OS X: Saving the Automator workflow as an Application instead of a Workflow saves you the trouble of having to associate the workflow file with Automator Launcher.
 
Post a Comment



<< Home

This page is powered by Blogger. Isn't yours?