Skip to main content
All CollectionsGetting StartedThe computational environment
Using the postInstall script for further customization
Using the postInstall script for further customization

Download, extract, compile – use the full set of tools available on Linux to set up your runtime environment.

Updated over a week ago

When you begin a new capsule, you will first choose a base environment, and then (probably) use the built-in package management system to install common libraries. In general, if you can use the package managers to install libraries, you should, because they take care of some capsule optimization features, such as removing unused files, without user intervention.

Sometimes, however, you will need software that isn't currently available through a package manager, or which needs a precisely specified order of operations. For these use cases, use the postInstall script. Here, you can  run any commands that you could run on a Linux system (e.g., curl , unzip /tar , or git clone ). It will be available underneath the package managers in the 'Environment' screen.

Because the script will be run as part of the build phase, any commands will be run once, and will then be cached as part of your capsule's custom environment. See Monitoring and inspecting the result of the environment setup phase for more information.

A few things to note:

  • Many software installation instructions will specify commands such as sudo apt-get install python-dev; sudo  is neither necessary nor available on Code Ocean and can simply be omitted.

  • The working directory for the postInstall script is / (root), which means if you include a command like mkdir mylibrary to create a folder, when you later need to refer to that folder, it'll be available at /mylibrary.

  • While you can use clone git repositories using the git clone command, this will bring in the entire repo including its history, which would take longer and use up more space when all you need is a specific version of the repo. One way to avoid this is to use the argument --depth 1 to the command (shallow clone in git parlance). Another way is to download an archived release, if available, which would look like curl -sL | tar xz.

Example use cases

For scripts that install new or additional languages, see Setting up new or additional languages on Code Ocean

For MATLAB specifically, see Installing user-provided MATLAB toolboxes.

Did this answer your question?