In this post I will describe how I created a portable installation of Julia Pro.
Portable Installation
In the past Windows applications used to keep all configuration files and data files within the folder of the installation of the application.
Modern Windows applications use different approach where the binary files of the program are kept in one folder (Usually inside Program Files
folder) and settings are kept in (Usually):
- The
%USERPROFILE%
folder (UsuallyC:\Users\<UserName>
). - The
%APPDATA%
folder (UsuallyC:\Users\<UserName>\AppData\Roaming
).
3 Inside the Registry.
Of course some applications can use a combinations of those.
Portable installation means it uses none of those. It uses the classic old approach where the application has built in folder to keep all its configuration and it doesn’t touch the Registry.
I like this concept. In my system besides Visual Studio and MATLAB non of the applications I use are integrated to the system. All of them are portable (Most of them come from PortableApps).
It allows me to format, install or do what ever I want with my C
drive and all programs are untouched.
It also keeps the performance of Windows like on its installation day (Though for modern Windows (7 and above) it is like that in any case). For other it will allow putting it on a USB Drive / Network Drive and use it whenever they want on any computer.
Portable Julia Pro
Gladly, it seems that Julia Pro installation doesn’t use the registry (Note: *Keep it that way guys, great choice!). It means it uses the Environment Variables to write data onto the drive. It mainly uses %USERPROFILE%
.
So all we need is to install it to any folder we want and trick it to think %USERPROFILE%
is located on the same folder it was installed. Easy to do…
Installation Process
- Install Julia Pro according to its installation guide (Don’t run the installer with Admin rights!). Chose Shared Drive option. Chose a folder of your choice to install it. Let’s call it
JuliaPro
from now on. - Once installation is done go to
JuliaPro
folder and create a folder inside it calledProfile
. - Go to
%USERPROFILE%
folder and look for a folder named.juliapro
. Move it into the folderJuliaPro\Profile\
. - Locate the file
Juno.bat
inJuliaPro\
. Edit it with any text editor. Add the following lines on its top just after the@ECHO OFF
command:
if not exist "%CD%\Profile\ProgramData" mkdir "%CD%\Profile\ProgramData"
if not exist "%CD%\Profile\Public" mkdir "%CD%\Profile\Public"
if not exist "%CD%\Profile\AppData\Roaming" mkdir "%CD%\Profile\AppData\Roaming"
if not exist "%CD%\Profile\Documents" mkdir "%CD%\Profile\Documents"
if not exist "%CD%\Profile\AppData\Local\Temp" mkdir "%CD%\Profile\AppData\Local\Temp"
set ALLUSERSPROFILE=%CD%\Profile\ProgramData
set APPDATA=%CD%\Profile\AppData
set HOMEPATH=%CD%\Profile
set ProgramData=%CD%\Profile\ProgramData
set Public=%CD%\Profile\Public
set TEMP=%CD%\Profile\AppData\Local\Temp
set TMP=%CD%\Profile\AppData\Local\Temp
set USERPROFILE=%CD%\Profile
set JULIADOC=%CD%\..\..\Documents\Julia
The above just means when we launch Juno it will be tricked to use the Profile
folder we created.
5. Open Juno using Juno.bat
and enjoy Almost portable Julia Pro installation.
I write Almost because it is portable in the manner it writes everything (Configuration, packages, etc…) to the Profile
folder yet there is one thing missing. If we copy this folder to another path once we launch Juno it won’t find Julia Binary Files. Why is that?
Well, in Juno (Atom) we have a preference which sets the Julia binary file path.
The variable is called juliaPath
and it is inside JuliaPro\.atom\config.CSON
.
By default (Also the only officially way supported) it uses absolute path for Julia binary file.
So we have 2 choices, either remember to change it manually when we copy the folder to another path or use non officially supported feature (According to @pfitzseb ) - Use relative path.
So, let’s say we installed JuliaPro on D:\
drive, namely, D:\JuliaPro
. Then juliaPath
will have the value juliaPath: "D:\\JuliaPro\\Julia-1.2.0\\bin\\julia.exe
(In this case we used Julia 1.2.0
).
If we replace this by juliaPath: ".\\Julia-1.2.0\\bin\\julia.exe"
(Namely the relative path to JuliaPro
) we will have a completely portable installation of Julia Pro.
Pay attention this is not officially supported and the Relative Path evaluation might stop one day :-).
Until then, Put Julia in your OneDrive and enjoy it everywhere :-).
Questions
Some questions for the Julia Pro packagers:
4. I set the following environment variables: %ALLUSERSPROFILE%
, %APPDATA%
, %HOMEPATH%
, %ProgramData%
, %Public%
, %TEMP%
, %TMP%
and %USERPROFILE%
. Is there any other variable Julia might use? Is there a way it override the user definitions of those?
5. Does Julia / Julia Pro use Registry entries and not only system variables?