Portable Julia

See Julia Portable Mode o Standalone

3 Likes

In case this applies to your situation: I use the git bash. Here is my bash script to set up the portable Julia:

#
set -o errexit 
set -o nounset

# Make sure we are in the folder in which the portable Julia is installed.
MyPortableJulia=julia-1.5.0
if [ ! -d $(pwd)/$MyPortableJulia ] ; then
    echo "Need to be in the folder with the portable Julia, $MyPortableJulia"
    exit 1
fi

# Locate the Julia depot in the current folder.
export MyDepot=$(pwd)/.$MyPortableJulia-depot
if [ ! -d $MyDepot ] ; then
    mkdir $MyDepot
fi
export JULIA_DEPOT_PATH=$MyDepot

# Make sure we can start Julia just by referring to the program name.
export PATH=$(pwd)/$MyPortableJulia/bin:$PATH

# Bring up the Julia prompt.
echo JULIA_DEPOT_PATH=$MyDepot
julia

A newer version, which starts VS code, looks like this:

#
set -o errexit 
set -o nounset

# Make sure we are in the folder in which the portable Julia is installed.
MyPortableJulia=julia-1.5.0
if [ ! -d $(pwd)/$MyPortableJulia ] ; then
    echo "Need to be in the folder with the portable Julia, $MyPortableJulia"
    exit 1
fi

# Locate the Julia depot in the current folder.
export MyDepot=$(pwd)/.$MyPortableJulia-depot
if [ ! -d $MyDepot ] ; then
    mkdir $MyDepot
fi
export JULIA_DEPOT_PATH=$MyDepot

# Make sure we can start Julia just by referring to the program name.
export PATH=$(pwd)/$MyPortableJulia/bin:$PATH

VSCode-win32-x64-1.48.1/Code

This file can be executed in Windows 10 just by double-clicking it.

2 Likes

A Windows batch file. This one starts (a portable) VS code executable
after setting the depot path.

@echo off
rem This needs to be changed if you switch versions of Julia
set MyPortableJulia=julia-1.5.0
rem Grab the folder where the portable Julia installation lives
set MyPortableJuliaDir=%~d0%~p0
rem Set Julia depot: all package data goes in here
set MyDepot="%MyPortableJuliaDir%.%MyPortableJulia%-depot"
set JULIA_DEPOT_PATH=%MyDepot%
rem Start VS Code to play with Julia
"%MyPortableJuliaDir%VSCode-win32-x64-1.48.1/Code.exe"
1 Like

Sorry, the Windows batch file doesn’t work at the moment: VS code error

Edit: I abandoned the batch file. I can get the job done with a bash script: much nicer to program. And it can be operated with the same double-click as a batch.

I will teach a course soon where the students will be provided with examples in the Julia programming language. In order to facilitate the procedure I will supply them with a bundle (zip file) that needs to be expanded (anywhere), and a script that the students double-click to install Julia, required packages, and a portable, preconfigured VSCode that pops up at the end of the installation. For anyone interested: http://hogwarts.ucsd.edu/~pkrysl/shared/Portable_Julia.zip

The installation is totally local to the expanded folder (it will not clobber any pre-existing Julia installation or depot), which can be anywhere, even on a USB stick. Hence portable Julia environment.

15 Likes

An update has been posted: http://hogwarts.ucsd.edu/~pkrysl/shared/Portable_Julia-1.6.zip

Julia 1.6 release candidate 1 is used. The newest VS code. The user’s system does not need to have Git installed: the portable version of it is included. All the user needs to do is to double-click a batch file: everything installs itself, and VS code pops up preconfigured for work with Julia. Thanks to Julia 1.6 the installation is much quicker than it used to be: 4 minutes flat till the editor comes up on my slowish laptop with Wi-Fi connection.

Works on Windows10 systems.

7 Likes

Thanks to @musm for making the Windows portable installer!

-viral

1 Like

Indeed! Thanks, @musm.

One more update: users not raised on *nix systems sometimes insist on having spaces in their usernames, despite advice to the contrary. My script was broken as it did not handle that case properly. I updated the script so that user names with spaces in them do not cause any trouble.

5 Likes

This is cool, I have done something similar, we should compare notes at some point:

2 Likes

Hi,

I am exited. Are there plans to provide it in a form that is easy to getting updated,
once a new Julia-Version is out?

Regards,

Stefan

Hi Stefan, I have plans to integrate Juliaup (GitHub - JuliaLang/juliaup: An experimental Julia version manager) into this distribution in order to update Julia from the command line. Juliaup in itself is a really cool project and might fill some of the gaps that Juliawin set out to fill (like easily having separate Julia versions on the same machine). Juliaup isn’t portable though in the same way as Juliawin, but Juliaup does make it easy to replicate an environment elsewhere, which might be better for most modern use cases. As you can tell I’m a big fan of Juliaup

Portable Julia update: bundled with Julia 1.7.1, newest VSCode (1.63.2).
Portable_Julia-1.7.zip

Edit: With VSCode 1.64.2 and Julia 1.7.2.
Portable_Julia-1.7.2.zip

6 Likes

There is now a superior Julia-cum-VSCode on a stick (i.e. portable): GitHub - PetrKryslUCSD/VSCode_Julia_portable: Portable Julia running in VSCode
The download is all of 4KB. Double click a batch file, and a few minutes later you have an open editor + Julia up and running. (Windows 7 and up.)

2 Likes

But that requires an internet connection, correct? Can you think of a way to put everything on USB stick so that the person using it does NOT need an internet connection?

As you suggested, create the usb stick on a system that does have internet connection, but then you can use anywhere.

1 Like

Different topic: I cannot really use your version yet for two reasons:

  1. In my tutorial (KiteSimulators.jl/PackageInstallation.md at main · aenarete/KiteSimulators.jl · GitHub) I assume access to a windows terminal that has julia in the search path. I could not find that in your project.
  2. You install vscode in such a way that it starts with your tutorial. No offence, but I would prefer my tutorial or no tutorial at all.

Do you see a way to address these issues?

Maybe you could consider this?

  1. VSCode has a built-in terminal. Use that, it will have access to Julia.
  2. Changing the initial project is easy. In fact, all it takes is to change this block of shell script

    But, opening a folder to the project you would like to switch to in the editor is literally just a couple of steps.

Well, I know that, I use it every day. But it does not solve my need for a real windows terminal. Reasons:

  1. Not all commands work in the vscode terminal. For example the command bin\run_julia (a file run_julia.bat exists) works in the windows terminal, but not in the vscode terminal
  2. often my git credentials work in the windows terminal, but not in in the vscode terminal
  3. if I teach and the situation is that a command does not work, then the reason often is a misconfiguration of vscode. To debug this situation I prefer to have a pure terminal where not much can be misconfigured.

And of course bash is more nice than the standard windows terminal, but I cannot expect every student to have bash installed.

Well, that is the point of this install: it provides a preconfigured bash. And, of course your editor can start one:

The Julia process runs from a bash in the editor, so that I have a sane “shell”!

And, it is possible to start a new terminal WINDOW from your vscode, which is preconfigured to find the portable julia:


Or, like this with powershell:

I do not know why the batch file would not run. But we can try to debug…

Hope this helps?