2021-11-24 12:41:07 -08:00
---
title: "Local Development"
---
2020-03-21 15:56:46 -07:00
# DataHub Developer's Guide
2020-03-21 15:54:15 -07:00
2023-12-01 14:23:11 -05:00
## Requirements
2022-04-05 03:15:21 +01:00
2023-12-15 13:28:33 -06:00
- [Java 17 JDK ](https://openjdk.org/projects/jdk/17/ )
2023-12-01 14:23:11 -05:00
- [Python 3.10 ](https://www.python.org/downloads/release/python-3100/ )
- [Docker ](https://www.docker.com/ )
2024-01-03 15:58:50 -06:00
- [Docker Compose >=2.20 ](https://docs.docker.com/compose/ )
2023-12-01 14:23:11 -05:00
- Docker engine with at least 8GB of memory to run tests.
2022-04-28 03:38:09 +05:30
2023-12-01 14:23:11 -05:00
On macOS, these can be installed using [Homebrew ](https://brew.sh/ ).
```shell
2023-12-21 13:50:39 -05:00
# Install Java
brew install openjdk@17
2023-12-01 14:23:11 -05:00
# Install Python
brew install python@3 .10 # you may need to add this to your PATH
# alternatively, you can use pyenv to manage your python versions
# Install docker and docker compose
brew install --cask docker
```
2022-04-28 03:38:09 +05:30
2020-03-21 15:54:15 -07:00
## Building the Project
Fork and clone the repository if haven't done so already
2023-12-01 14:23:11 -05:00
```shell
2020-03-21 15:54:15 -07:00
git clone https://github.com/{username}/datahub.git
```
Change into the repository's root directory
2023-12-01 14:23:11 -05:00
```shell
2020-03-21 15:54:15 -07:00
cd datahub
```
Use [gradle wrapper ](https://docs.gradle.org/current/userguide/gradle_wrapper.html ) to build the project
2023-12-01 14:23:11 -05:00
```shell
2020-03-21 15:54:15 -07:00
./gradlew build
```
2022-04-05 03:15:21 +01:00
Note that the above will also run run tests and a number of validations which makes the process considerably slower.
We suggest partially compiling DataHub according to your needs:
2023-12-01 14:23:11 -05:00
- Build Datahub's backend GMS (Generalized metadata service):
```
./gradlew :metadata-service:war:build
```
- Build Datahub's frontend:
```
./gradlew :datahub-frontend:dist -x yarnTest -x yarnLint
```
- Build DataHub's command line tool:
2022-04-05 03:15:21 +01:00
2023-12-01 14:23:11 -05:00
```
./gradlew :metadata-ingestion:installDev
```
- Build DataHub's documentation:
```
./gradlew :docs-website:yarnLintFix :docs-website:build -x :metadata-ingestion:runPreFlightScript
# To preview the documentation
./gradlew :docs-website:serve
```
## Deploying Local Versions
2022-04-05 03:15:21 +01:00
Run just once to have the local `datahub` cli tool installed in your $PATH
2023-12-01 14:23:11 -05:00
```shell
2022-04-05 03:15:21 +01:00
cd smoke-test/
python3 -m venv venv
source venv/bin/activate
pip install --upgrade pip wheel setuptools
pip install -r requirements.txt
cd ../
```
Once you have compiled & packaged the project or appropriate module you can deploy the entire system via docker-compose by running:
2023-12-01 14:23:11 -05:00
```shell
2023-02-08 14:12:40 -08:00
./gradlew quickstart
2022-04-05 03:15:21 +01:00
```
Replace whatever container you want in the existing deployment.
I.e, replacing datahub's backend (GMS):
2023-12-01 14:23:11 -05:00
```shell
2024-01-05 09:48:59 -06:00
(cd docker & & COMPOSE_DOCKER_CLI_BUILD=1 DOCKER_BUILDKIT=1 docker compose -p datahub -f docker-compose-without-neo4j.yml -f docker-compose-without-neo4j.override.yml -f docker-compose.dev.yml up -d --no-deps --force-recreate --build datahub-gms)
2022-04-05 03:15:21 +01:00
```
Running the local version of the frontend
2023-12-01 14:23:11 -05:00
```shell
2024-01-05 09:48:59 -06:00
(cd docker & & COMPOSE_DOCKER_CLI_BUILD=1 DOCKER_BUILDKIT=1 docker compose -p datahub -f docker-compose-without-neo4j.yml -f docker-compose-without-neo4j.override.yml -f docker-compose.dev.yml up -d --no-deps --force-recreate --build datahub-frontend-react)
2022-04-05 03:15:21 +01:00
```
2023-12-01 14:23:11 -05:00
2020-03-21 15:54:15 -07:00
## IDE Support
2023-12-01 14:23:11 -05:00
The recommended IDE for DataHub development is [IntelliJ IDEA ](https://www.jetbrains.com/idea/ ).
You can run the following command to generate or update the IntelliJ project file.
```shell
2020-03-21 15:54:15 -07:00
./gradlew idea
```
2023-12-01 14:23:11 -05:00
2020-03-21 15:54:15 -07:00
Open `datahub.ipr` in IntelliJ to start developing!
2020-05-07 15:59:16 -07:00
For consistency please import and auto format the code using [LinkedIn IntelliJ Java style ](../gradle/idea/LinkedIn%20Style.xml ).
2023-04-06 09:36:55 +09:00
## Windows Compatibility
2023-12-01 14:23:11 -05:00
For optimal performance and compatibility, we strongly recommend building on a Mac or Linux system.
2023-04-06 09:36:55 +09:00
Please note that we do not actively support Windows in a non-virtualized environment.
If you must use Windows, one workaround is to build within a virtualized environment, such as a VM(Virtual Machine) or [WSL(Windows Subsystem for Linux) ](https://learn.microsoft.com/en-us/windows/wsl ).
This approach can help ensure that your build environment remains isolated and stable, and that your code is compiled correctly.
2020-03-21 15:54:15 -07:00
## Common Build Issues
2023-12-01 14:23:11 -05:00
#### Getting `Unsupported class file major version 57`
2020-03-21 15:54:15 -07:00
You're probably using a Java version that's too new for gradle. Run the following command to check your Java version
2023-12-01 14:23:11 -05:00
```shell
2020-03-21 15:54:15 -07:00
java --version
```
2023-12-01 14:23:11 -05:00
2023-12-15 13:28:33 -06:00
While it may be possible to build and run DataHub using newer versions of Java, we currently only support [Java 17 ](https://openjdk.org/projects/jdk/17/ ) (aka Java 17).
2020-03-21 15:54:15 -07:00
2023-12-01 14:23:11 -05:00
#### Getting `cannot find symbol` error for `javax.annotation.Generated`
2020-03-21 16:03:28 -07:00
2023-12-15 13:28:33 -06:00
Similar to the previous issue, please use Java 17 to build the project.
2020-03-21 16:07:49 -07:00
You can install multiple version of Java on a single machine and switch between them using the `JAVA_HOME` environment variable. See [this document ](https://docs.oracle.com/cd/E21454_01/html/821-2531/inst_jdk_javahome_t.html ) for more details.
2020-03-21 16:03:28 -07:00
2023-12-01 14:23:11 -05:00
#### `:metadata-models:generateDataTemplate` task fails with `java.nio.file.InvalidPathException: Illegal char <:> at index XX` or `Caused by: java.lang.IllegalArgumentException: 'other' has different root` error
2020-03-21 15:54:15 -07:00
2023-12-01 14:23:11 -05:00
This is a [known issue ](https://github.com/linkedin/rest.li/issues/287 ) when building the project on Windows due a bug in the Pegasus plugin. Please refer to [Windows Compatibility ](/docs/developers.md#windows-compatibility ).
2020-04-02 07:48:37 -07:00
2023-12-01 14:23:11 -05:00
#### Various errors related to `generateDataTemplate` or other `generate` tasks
2020-04-02 07:48:37 -07:00
2023-12-01 14:23:11 -05:00
As we generate quite a few files from the models, it is possible that old generated files may conflict with new model changes. When this happens, a simple `./gradlew clean` should reosolve the issue.
2020-08-01 16:17:43 -07:00
2023-12-01 14:23:11 -05:00
#### `Execution failed for task ':metadata-service:restli-servlet-impl:checkRestModel'`
2020-08-01 16:17:43 -07:00
This generally means that an [incompatible change ](https://linkedin.github.io/rest.li/modeling/compatibility_check ) was introduced to the rest.li API in GMS. You'll need to rebuild the snapshots/IDL by running the following command once
2023-12-01 14:23:11 -05:00
```shell
2022-03-02 01:45:41 +01:00
./gradlew :metadata-service:restli-servlet-impl:build -Prest.model.compatibility=ignore
2020-08-01 16:17:43 -07:00
```
2020-09-30 06:45:03 -07:00
2023-12-01 14:23:11 -05:00
#### `java.io.IOException: No space left on device`
2020-09-30 06:45:03 -07:00
This means you're running out of space on your disk to build. Please free up some space or try a different disk.
2022-12-14 18:30:45 +01:00
2023-12-01 14:23:11 -05:00
#### `Build failed` for task `./gradlew :datahub-frontend:dist -x yarnTest -x yarnLint`
2022-12-14 18:30:45 +01:00
This could mean that you need to update your [Yarn ](https://yarnpkg.com/getting-started/install ) version