Package Managers and Adding Packages

Package Managers

Package Managers are automatically added to the Capsule Environment Editor based on the Starter Environment chosen for the Capsule. When a Custom Base Image is used, Code Ocean will automatically detect the appropriate package managers and make them available in the Environment Editor.

Every Code Ocean Recommended Starter Environment includes apt-get, the command–line tool for working with APT (Advanced Package Tool) software packages, as it is generally the preferred way to install packages in Linux distributions.

Adding Packages

After you choose the Starter Environment, you can add packages using the package managers to further establish your computational environment. When adding a package without a version number, the system will download the latest version of the package.

Once you have selected a base image, attached all of the packages through the package managers or postInstall script, set Environmental Variables, and added secrets if needed, the environment will build once be saved to cache. The system detects changes to the environment (i.e., changes in the Dockerfile) to determine whether to trigger a rebuild or not. If the environment is not modified, it utilizes the cache information from the previous build to skip the build phase. Changes such as a change of a version, adding or removing packages from the environment, environmental variables, and secrets will trigger a rebuild. This system ensures your results are reproducible using the exact packages and versions at run time.

Auto Complete Package Names

Each package manager contains a dropdown list of common packages which will automatically begin completing when you begin typing a package in the field.

This list is case sensitive and can also suggest items when searched for as sub-strings.

Advanced Settings for Package Managers

Configure Package Managers

Some packages require specific configurations for installation, for example, configuring the Bioconda channel for the Conda or Mamba package managers.

  1. Select Configure [package manager name].

  2. Enter the information for the additional setting.

Reset Package Versions to "Latest"

This affects all packages installed via the chosen package manager and allows you to install the latest version of all packages in bulk. Instead of removing each version, you can use this feature to do it all at once.

  1. Select Reset package versions to 'latest'.

There is no confirmation message for this action. Use it with caution.

A preferred practice is to commit changes before resetting all of the package versions in the package manager so that you can revert the change.

Remove All Packages

Instead of removing the packages one by one, you can remove all packages installed via a specific package manager in bulk.

  1. Select Remove all packages.

There is no confirmation message for this action. Use it with caution.

A preferred practice is to commit changes before removing all the packages in the package manager so that you can revert the change.

The removal will fail if the package is currently used by another package manager. Note that there will be no pop-up message to indicate this issue.

Edit Bulk Packages

This feature is useful when you want to add, change, or remove multiple packages in bulk. You can drag and drop supported file types (i.e. requirement.txt for pip or environment.yml for conda) to add multiple packages or even just copy and paste a list of packages.

  1. Select Edit Bulk.

A text editor will appear with the currently listed packages of that package manager. You can drag and drop the dependency files directly to the text editor window, and modify multiple packages at once. Click Save when you are done editing.

If you try to add a non-supported file type to the package manager, the system will return an error message.

Install Packages from Dependency Files in the Capsule

You can populate packages in your Capsule environment directly from the most common dependency files:

  • requirements.txt - pip package installer environment file

  • environment.yml - conda package installer environment file

  • lock.json - R CRAN package installer environment file

To install packages from a dependency file:

  1. Navigate to the dependency file in the Capsule's File Tree

  2. Select Install packages

The name and the file type have to be the same as the list above. Otherwise, the option to Install packages won't show up in the drop-down menu

Using Post-Install Script to Install Complex Packages

Some packages may require building from source or downloading files. In this case, it is better to install them via the Post-Install script. To learn more about the Post-Install, visit the Post-Install Script Guide.