Sign in Join
Wiki copytemporary

Multiple Lazarus: what changed

Revision 1 to 2. Removed lines have a minus sign; added lines have a plus sign.

OldNewLine
11## Multiple Lazarus instances
22
33You can have one directory with Lazarus in it on your system or more. These directories can contain the same or different versions of Lazarus and can be made to work independent of each other (see the section dealing with **--primary-config-dir** below). Because you don't have to install Lazarus and the versions may be the same, the concept of having more than one Lazarus directory on your system will be called "multiple instances" in this article.\
44Runthrough for Linux at [[DualLaz]].
55
66## Important
77
88- Make Backups of
99 - Your primary config (e.g. ~/.lazarus under Unix)
1010 - Your projects *.lpi and *.lps
1111
1212## Who needs multiple Lazarus instances and who does not?
1313
1414You need multiple Lazarus instances...
1515
1616- to have several versions of Lazarus
1717- to have one Lazarus version compiled with several different versions of [[FPC]]
1818
1919You don't need multiple instances...
2020
2121- to test your project with different [[Widgetset|widgetsets]]
2222- to [[Cross compiling|cross compile]]
2323
2424## The Lazarus directory
2525
2626The Lazarus directory (i.e. the directory where the Lazarus application is) is overridable using --lazarusdir, this is useful when running Lazarus from e.g. USB sticks with varying mountpoints or driveletters.
2727
2828## The config directory
2929
3030All IDE options for an instance are saved to a config directory. Under Linux, macOS and BSD the default config directory is ~/.lazarus. Note the beginning dot, which makes it a hidden directory.
3131
3232On Windows, settings are saved to the User AppData folder, which maps to a different directory depending on the Windows version (and language, in Windows XP and earlier). See also information here: Windows. Note that you won't see the configuration directory in Windows unless you select to see hidden and system files. To view the directory, type:
3333
3434```dos
3535%localappdata%
3636```
3737
3838in the Start/Run box or in the address bar of Windows Explorer, which should bring you to the Local Application Data directory. For default installs, the settings are stored in the Lazarus directory shown there.
3939
4040| Operating System | Default location for the config directory | Remarks |
4141|----|----|----|
4242| Linux, macOS, BSD, other UNIXes | ~/.lazarus | Hidden directory |
4343| Windows XP | C:\Documents and Settings\\\<User name\>\Local Settings\Application Data\lazarus | English Windows; others may have different paths |
4444| Windows Vista and higher | C:\Users\\\<User name\>\AppData\Local\lazarus\\ | Regardless of selected language |
4545
4646The config directory can **not** be shared between different Lazarus versions. A newer Lazarus can read older configs and will update them automatically. There is no guarantee that an older version can read config files of a newer version. It is always a good idea to make a backup of your configs from time to time for time you might’ve change something weird and not know what it was.
4747
4848### Solution for separating instances using multiple config dirs
4949
5050The config directory can be given on the command line with the --primary-config-path parameter (shorter version: --pcp). For example:
5151
5252``` bash
5353lazarus --primary-config-path=~/.lazarus2
5454```
5555
5656will start an IDE using *~/.lazarus2* as config directory. This way you can have an arbitrary number of config directories and start several independent Lazarus instances. As Lazarus creates the settings files from default if they don't exist, you can specify empty directories if you want.
5757
5858If you use this often, then a small shell script can be created:
5959
6060``` bash
6161#!/bin/sh
6262/path/to/lazarus --primary-config-path=~/.lazarus2
6363```
6464
6565In Windows you cannot use ~ so use instead, for example, a shortcut on the desktop with the following parameters to call Lazarus:
6666
6767``` bash
6868\path\to\lazarus.exe --primary-config-path=lazarusconf
6969```
7070
7171This will place the lazarus configuration directory inside the lazarus directory.
7272
7373### Using lazarus.cfg file
7474
7575Another way for setting config directory is using a “lazarus.cfg" file and putting it into the folder with the Lazarus executable and putting this line into it :
7676
7777``` bash
7878--primary-config-path=\path\to\config\folder
7979```
8080
8181You can make a config folder any where you like and set it's path to the cfg file. After that Lazarus will use this lazarus.cfg file and there is no need to make a shell script or use shortcut file with the —-pcp parameter.
8282
8383For example, for a Windows installation it will be like this : A config folder and a lazarus.cfg file near the Lazarus executable and put a value like this for example into the cfg file :
8484
8585```Dos
8686--primary-config-path=C:\Lazarus2\config\
8787```
8888
8989And run Lazarus. It will ask for some config values and after that you can make a simple shortcut for later use without any parameters.
9090
9191### Config directory files
9292
9393See the [[pcp|Primary Config Path]] page.
9494
9595*lazarus.dci* - stores the Lazarus Code Templates
9696
9797*editoroptions.xml* - information about colors, fonts and other editor options
9898
9999*miscellaneousoptions.xml* - packages information
100100
101101*environmentoptions.xml* - stores the history of opened projects and files (Recent Opened Files and Projects)
102102
103103## The Lazarus files
104104
105105The Lazarus source archive is contained in a single directory. You can simply compile Lazarus (eg, for [[Installing Lazarus on Linux|Linux]] or for [[Installing Lazarus on Windows|Windows]]) and a lot of files and subdirectories will be created, but and all will be below that single subdirectory.
106106
107107A Lazarus instance (sources and resources) is a single subdirectory. Just copy this directory and you get a whole new Lazarus instance.
108108
109109You don't need to *install* Lazarus to be able to run it. But if you do indeed *install* Lazarus, you get some nice shortcuts on your desktop and some file types (e.g. lpk, lpi, pas) are associated with that Lazarus installation. These things are platform dependent. You can have only one formally installed Lazarus but secondary installs work just as well, typically you will start the one you want with a script or cd-ing to its own directory and starting it there. A formal install is typically added to your PATH so care might be needed, when using a secondary copy, that you don't get the 'on path' executable, some users prefer to have no formally installed copies for that reason, Lazarus, built from source works fine from its source directory.
110110
111111Newer installers support *installing* Lazarus multiple times. Alternatively, You can also add another Lazarus instance **manually** quite easily. Of course, file associations etc. can only be linked to one single Lazarus instance.
112112
113113### Linux
114114
115115See the instructions for [[Installing Lazarus on Linux|Installing Lazarus from Source]] and repeat that as many times, each in a new directory, as you like. It often makes sense to use your distro provided version of FPC (as long as its up to date) and build your Lazarus from source. Don't bother to "install" Lazarus, its fine to just have it all in your own file space, cd into the desired directory and launch lazarus from the command line. Just make sure each Lazarus directory has its own config directory (and knows how to find it).
116116
117117If you do decide to have one or more Lazarus "installs", its a good idea not to have a package installed version as well. They tend to cause some PATH confusion.
118118
119119Find a 2015 run-through for Linux 64 bit at [[DualLaz]].
120120
121121#### Example 1 : A normally installed Lazarus instance plus the git version
122122
123123Download and install the Lazarus debian- & .rpm - packages as normal.
124124
125125Then download the Lazarus git archive to a directory of your choice, preferably somewhere in your home directory (e.g. ~/lazarus). See here [[Getting Lazarus|Getting Lazarus from the GitLab server]].
126126
127127Start your **secondary** Lazarus with:
128128
129-`/home/you/lazarus/startlazarus --pcp=~/.lazarus2nd`
129+```text
130+/home/you/lazarus/startlazarus --pcp=~/.lazarus2nd
131+```
130132
131133#### Example 2 : A normally installed Lazarus instance plus a manual copy
132134
133135i.e. you obtain two subdirectories:
134136
135-`/usr/lib/lazarus     original  copy     via debian install`\
136-`/home/you/lazarus    secondary copy `
137+```text
138+/usr/lib/lazarus original copy via debian install
139+/home/you/lazarus secondary copy
140+```
137141
138142or you may look at:
139143
140-`/home/you/development/lazarus    original copy      via fpcUP install`\
141-`/home/you/lazarus                secondary copy `
144+```text
145+/home/you/development/lazarus original copy via fpcUP install
146+/home/you/lazarus secondary copy
147+```
142148
143149Download and install the Lazarus debian-packages as usual.
144150
145151Then copy the Lazarus directory to your home directory and change the ownership of the files:
146152
147153``` bash
148154cp -a /usr/lib/lazarus $(HOME)/
149155chown $USER:$USER -R $(HOME)/lazarus
150156```
151157
152158(Note: The chown line assumes that your group has the same name as your username. If not, replace \$USER:\$USER with your username:groupname)
153159
154160Now change your Lazarus desktop/menu shortcut to start the **secondary** copy
155161
156-`/home/you/lazarus/startlazarus --pcp=~/.lazarus2nd`
162+```text
163+/home/you/lazarus/startlazarus --pcp=~/.lazarus2nd
164+```
157165
158166Then start the IDE and change the environment options: Tools -\> Options -\> Environment / Lazarus directory to the **secondary** subdir, namely /home/you/lazarus
159167
160168In recent Lazarus versions, you are also given a screen to name the other important paths, so you would name the secondary sudirs in the 2ndary config.
161169
162170Also, inside the /home/you/development/fpc/bin/x86_64-linux/**fpc.cfg** text file, all paths should rather point to your secondary copy. To make sure everything is fine, run **startlazarus** from within xterm and watch the errormessages. make sure all paths are found (very difficult currently).
163171
164172You now have a secondary copy that which you can edit and recompile. Don't forget to close source files of the primary /usr/lib/lazarus.
165173
166174### Windows
167175
168176#### Example 1: GIT and Release
169177
170178This is to have both GIT and last release version of Lazarus.
171179
1721801\) Install Lazarus last release and check setup option 'create desktop shortcut', you will get 'Lazarus.lnk' on the desktop.
173181
1741822\) Get Lazarus from GIT and compile, then create a shortcut on your desktop for 'lazarus.exe' and rename it to 'Lazarus GIT.lnk'.
175183
176184Then you can set the config dir for each version editing the shortcut path to the executable:
177185
178186This is for release, because you don't change the primary config path parameter, the config will be saved in the default path:
179187
180188```dos
181189C:\lazarus\startlazarus.exe
182190```
183191
184192For GIT, store the settings e.g. in the folder 'C:\lazgitcfg\\':
185193
186194```dos
187195C:\FPC\laz\startlazarus.exe --primary-config-path=C:\lazgitcfg
188196```
189197
190198## Installation of multiple Lazarus
191199
192200### Windows - Using the installer
193201
194202On Windows the installer (Version 1.1) can create a secondary installation. And it will ask for a folder to store the config.
195203
196204- Install:
197205 - Make sure you back up ALL your existing configurations BEFORE you install.
198206 - AGAIN: Make sure you back up ALL your existing configurations BEFORE you install.
199207 - After install check that the correct config is used\
200208 See the file "lazarus.cfg" in the installation directory. And Menu "View" \> "IDE Internals" \> "About IDE"
201209 - If you see a message about upgrading/downgrading the config, then the installation is incorrect. Press "Cancel"
202210- Usage
203211 - Do not share packages between installations; rather you must have several independent copies of each package
204212 - Backup lpi and lps files (if you share projects). Ideally store sessions (lps) in the "IDE config directory"\
205213 Menu: "Project" \> "Project Options" \> Session
206214- Uninstall:
207215 - If you plan to uninstall: back up everything again
208216- Update:
209217 - If you plan to update, back up everything again
210218 - After updating, check that the correct config is still being used\
211219 See the file "lazarus.cfg" in the installation directory. And Menu "View" \> "IDE Internals" \> "About IDE"
212220
213221The Windows Installer is able to create secondary installations, which allows you to have different versions installed that do not interfere with each other.
214222
215223All you need to do is tick the checkbox "secondary installation" (when choosing the install directory), and follow the instructions. You will then be asked for a new empty folder where the config will be stored (this can be a subfolder in the install directory).
216224
217225If you update an installation using the Windows Installer, it will detect when the selected directory contains a secondary install.
218226
219227In order to always be able to quickly see which IDE you are using, and also to check that the correct config is loaded, it is advisable to make changes to some visual attributes. A possibility is to change the gutter color in the editor.
220228
221229#### Windows - Adding a cross compiler install
222230
223231The installation packages for cross compilers can be added to secondary installations, too. However, they will currently give a warning that the folder is not empty. This warning can be ignored.
224232
225233# Visually distinguish
226234
227235To distinguish each Lazarus visually you can:
228236
229237- Set a different color for the gutter - the left column of the source editor where the line numbers and break points are shown.
230238- Set the title of the IDE
231239
232240---
233241*From the Free Pascal wiki, page "Multiple Lazarus", as it stood on 2023-11-08 after a change by Dbannon, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*

Back to history