Making science reproducible @nextjournal

Julia 1.0

This article is installing Julia 1.0 and providing it as a reusable environment. If you just want to use Julia 1.0 in your own articles, see the Reusing section below. Futher down you will see how it was built.

Building the Environment

We base this off our Minimal Bash image. Notice how the JULIA_VERSION environment variable is set on the runtime.

Julia 1.0.1
Julia 1.0.1 (Bash)Minimal Bash
exporting environment
Type: Nextjournal
Environment:Minimal Bash
Resources:
Environment Variables:
PATH/usr/local/julia/bin:/usr/local/nvidia/bin:/usr/local/cuda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
JULIA_PATH/usr/local/julia
JULIA_GPG3673DF529D9049477F76B37566E3C7DC03D6E495
JULIA_VERSION1.0.1
Download this environment as a Docker image from:

The exact version we're installing is 1.0.1.

echo ${JULIA_VERSION}

Here, we download the archive using curl.

tarArch='x86_64'
dirArch='x64'
JULIA_VERSION_SHORT=${JULIA_VERSION/-rc/}
echo "https://julialang-s3.julialang.org/bin/linux/${dirArch}/${JULIA_VERSION_SHORT%[.-]*}/julia-${JULIA_VERSION}-linux-${tarArch}.tar.gz.asc"
curl -fL -o julia.tar.gz.asc "https://julialang-s3.julialang.org/bin/linux/${dirArch}/${JULIA_VERSION_SHORT%[.-]*}/julia-${JULIA_VERSION}-linux-${tarArch}.tar.gz.asc"
curl -fL -o julia.tar.gz "https://julialang-s3.julialang.org/bin/linux/${dirArch}/${JULIA_VERSION_SHORT%[.-]*}/julia-${JULIA_VERSION}-linux-${tarArch}.tar.gz"

Next, the signature is checked using gpg. This ensures we've downloaded the correct image.

sha256="9ffbcf7f4a111e13415954caccdd1ce90b5c835cee9f62d6ac708f5b752c87dd"
echo "${sha256} *julia.tar.gz" | sha256sum -c -; \

savedAptMark="$(apt-mark showmanual)"; \
if ! command -v gpg > /dev/null; then \
  apt-get update; \
  apt-get install -y --no-install-recommends gnupg dirmngr; \
  rm -rf /var/lib/apt/lists/*;
fi;
export GNUPGHOME="$(mktemp -d)";
gpg --keyserver  ipv4.pool.sks-keyservers.net --recv-keys "$JULIA_GPG";
gpg --batch --verify julia.tar.gz.asc julia.tar.gz;
command -v gpgconf > /dev/null && gpgconf --kill all;
rm -rf "$GNUPGHOME" julia.tar.gz.asc;

apt-mark auto '.*' > /dev/null
[ -z "$savedAptMark" ] || apt-mark manual $savedAptMark
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false
PATH=$JULIA_PATH/bin:$PATH
mkdir "$JULIA_PATH";
tar -xzf julia.tar.gz -C "$JULIA_PATH" --strip-components 1;
rm julia.tar.gz;

Lastly, we check that we can run Julia.

julia -v
julia -e 'using Pkg
  Pkg.update()
  Pkg.add("JSON")'
julia -e 'using JSON'

Testing it

Lastly, let's create a Julia code cell that uses our newly built Julia image.

Base.VERSION

And it works 🎉