Code Ocean offers many base environments with different languages pre-installed. You can also use the environment & configuration options to install multiple languages in one compute capsule. Available package managers will suffice for many common languages; less common languages will likely require a postInstall script.

Which environment should I start with?

If you:

  • are not using a pre-installed language, use a base Ubuntu (18.04 or 16.04) environment;
  • need proprietary software, such as MATLAB or Stata, start from an environment with proprietary language;
  • use a GPU, select an environment with GPU access (these will be explicitly labeled as such, or will reference CUDA or a deep learning framework);
  • need general flexibility, start from an image with Conda these will have Python as well).

Installing a language using package managers:

The following are all available as apt-get packages:

  • build-essential for the C/C++ toolchain (gcc/g++, make, etc.);
  • r-base for R (r-base-dev will help you install R packages);
  • python for Python (add python-pip for pip installer support);
  • perl for Perl (add cpanm if needed);
  • luajit for Lua (add luarocks if needed);
  • default-jdk for Java;
  • gfortran for Fortran. 

Once you add R or python, the commands Rscript or python will become available, respectively.

 Installing langauges through Conda

If your base image has a conda installer, or if you add it via postInstall script, you can add languages and language-specific packages via supplemental conda channels.

  • python is available by default;
  •  julia and lua are available through conda-forge;
  •  r is available from channel r.

Installing languages using the postInstall script:

Less common languages will likely require specialized postInstall script to install. For example:

C#:
Mono is an open source implementation of Microsoft's .NET Framework. The Mono project website has instructions for installing Mono on Ubuntu 16.04

Start by choosing the "Other" language, which will get you a minimal Ubuntu environment. You can then write a postInstall script using the commands from Mono's instructions as is, with one small change: sudo is not required (nor available by default) on Code Ocean. The resulting postInstall script, with sudo taken out, looks like this:

#!/bin/bash
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
echo "deb http://download.mono-project.com/repo/ubuntu xenial main" | tee /etc/apt/sources.list.d/mono-official.list
apt-get update -qq && apt-get install -y mono-devel

As a side note, in order to build your project and run it, use the following commands in a run.sh shell script:

xbuild /p:Configuration=Release myproject.csproj
mono bin/Release/myproject.exe

GHDL
Run the following postInstall script:

#!/bin/bash
buildDeps="ca-certificates gcc gnat make zlib1g-dev"
apt-get update && apt-get install -y $buildDeps
release="20181129" # or whichever release is appropriate
curl -L https://github.com/ghdl/ghdl/archive/$release.tar.gz | tar xz
cd ghdl-$release
./configure --prefix=/usr/local
make && make install
apt-get purge -y --autoremove $buildDeps && rm -rf /var/lib/apt/lists/*

Modelica
Run the following postInstall script:


#!/bin/bash
apt-get update && apt-get install -y lsb-release
for deb in deb deb-src; do echo "$deb http://build.openmodelica.org/apt `lsb_release -cs` nightly"; done | tee /etc/apt/sources.list.d/openmodelica.list
curl -s http://build.openmodelica.org/apt/openmodelica.asc | apt-key add -
apt-key fingerprint
apt update -qq && apt install -y openmodelica
apt-get purge -y --autoremove lsb-release && rm -rf /var/lib/apt/lists/*

What if I need proprietary software that isn't currently supported?

Contact us at support@codeocean.com and we will be happy to look into it.

Did this answer your question?