Installing cldk
CLDK is a Python SDK hosted on PyPI and can be installed using your preferred Python package manager.
Installation
Section titled “Installation”The Python SDK can be installed directly from PyPI using any Python package manager such as pip, poetry, or uv:
pip install cldkpoetry add cldkuv add cldkProgramming Language Specific Dependencies
Section titled “Programming Language Specific Dependencies”CLDK supports program analysis for multiple languages and requires additional dependencies to support specific languages. The following tabs list the additional dependencies required for each language:
For Python analysis as well as to use the CLDK Python SDK, you will need to install the Python programming language with version 3.11 or later. We recommend using a package manager like pyenv to install and manage Python dependencies.
For Java analysis, CLDK relies on a companion project called codeanalyzer. codeanalyzer is a Java project and you will therefore need to install the Java Development Kit (JDK) with java version 11 or later.
You can use a package manager like SDKMAN to install the JDK. First, install SDKMAN by running the following command:
-
To install
SDKMAN, open your terminal and enter the following command and follow the instructions to complete the installation:Terminal window curl -s "https://get.sdkman.io" | bash -
Open a new terminal or source the SDKMAN! scripts:
Terminal window source "$HOME/.sdkman/bin/sdkman-init.sh"
Next, install java 11 or later using SDKMAN:
-
You can list all available java versions with:
Terminal window sdk list java | grep semYou should see something like this:
Terminal window Semeru | | 21.0.5 | sem | | 21.0.5-sem| | 17.0.13 | sem | | 17.0.13-sem| | 11.0.25 | sem | | 11.0.25-sem| | 8.0.432 | sem | | 8.0.432-sem -
Install Java 11 or above (we’ll go with
11.0.25-sem):Terminal window sdk install java 11.0.25-sem -
Set Java 11 as the current (or default) Java version:
Terminal window sdk use java 11.0.25-sem# If want to default to java 11 for all sessions, use the following command instead:# sdk default java 11.0.25-sem -
Verify the installation:
Terminal window java -versionThis should output the version of the installed Java.
Terminal window openjdk 11.0.25 2024-10-15IBM Semeru Runtime Open Edition 11.0.25.0 (build 11.0.25+9)Eclipse OpenJ9 VM 11.0.25.0 (build openj9-0.48.0, JRE 11 Linux amd64-64-Bit Compressed References 20241107_1233 (JIT enabled, AOT enabled)OpenJ9 - 1d5831436eOMR - d10a4d553JCL - edded3f65c based on jdk-11.0.25+9)
Finally, to enable building Java projects automatically, you will need to install the maven build tool. You can install maven using a package manager like SDKMAN:
-
Install Maven:
Terminal window sdk install maven -
Make sure
mvncommand is available in thePATH. Ifmvnis not in your path, add the following to your~/.zshrc,~/.bashrcor~/.bash_profilefile:Terminal window export PATH="$HOME/.sdkman/candidates/maven/current/bin:$PATH"Then, source the file to apply the changes:
Terminal window source ~/.zshrc # or ~/.bashrc or ~/.bash_profile -
Verify the installation:
Terminal window mvn -versionThis should output the version of the installed Maven.
For TypeScript and JavaScript analysis, CLDK relies on a companion backend, codeanalyzer-ts. It ships as a prebuilt, self-contained binary and does not require Bun or Node to run. Install the codeanalyzer-typescript package, which adds a cants command to your PATH.
Install it from PyPI:
pip install codeanalyzer-typescriptOr with Homebrew:
brew install codellm-devkit/homebrew-tap/codeanalyzer-typescriptVerify the installation:
cants --helpThe package is named codeanalyzer-typescript, but the installed command is cants. To resolve library call targets, the analyzer requires a project’s dependencies; keep npm on your PATH and the analyzer materializes node_modules automatically (skip with --no-build). See the codeanalyzer-ts backend reference for full CLI options.
Use rustup to install Rust and manage toolchains. It keeps Rust versions isolated and lets you switch between them when needed.
- Install Rustup Run the following command in your terminal:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | shFollow the on-screen instructions to complete the installation.
- Configure Your Environment Add Rust to your PATH by appending this line to your shell init script:
source $HOME/.cargo/env- Verify Installation Confirm that Rust is installed correctly by checking the version:
rustc --versionExpected output (version may vary):
rustc 1.70.0 (90c541806 2023-05-31)Additional Development Tools
Section titled “Additional Development Tools”Some operating systems may require additional development tools:
-
Make sure you have the Xcode Command Line Tools installed. You can install them using the following command:
Terminal window xcode-select --install -
Additionally, you may need to install the following packages using Homebrew:
Terminal window brew install openssl readline sqlite3 xz zlib tcl-tk libffi
-
Install the required development tools using the following command:
Terminal window sudo apt-get install build-essential python3-dev libssl-dev zlib1g-dev \libbz2-dev libreadline-dev libsqlite3-dev curl git \libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev
-
Install the required development tools using the following command:
Terminal window sudo dnf group install c-development development-tools gcc make \patch zlib-devel bzip2 bzip2-devel readline-devel sqlite sqlite-devel\openssl-devel tk-devel libffi-devel xz-devel
Supported Python Versions
Section titled “Supported Python Versions”CLDK is compatible with Python versions 3.11 and later. The following table lists the supported Python versions and the corresponding CLDK versions:
| Python Version | Compatible cldk Versions |
|---|---|
| 3.11 | ≥0.4.0 |