JetBrains Space Help

Develop in a Dev Environment

Before you start developing in a dev environment:

  1. Install an IDE compatible with Space dev environments: JetBrains Fleet (cloud-friendly IDE) or JetBrains Gateway (a thin client based on IntelliJ IDEA). To install an IDE, you can use JetBrains Toolbox App.

  2. (Optional) Set up the environment for your project. If you skip this step, the environment will use the default container (which may miss the tooling and runtimes required by your project) and will have no warm-up data (project indexes, referenced libraries, and so on).

  3. Make sure you have at least the Project member role in the project that you want to work with. By default, the Project member role provides the Create dev environments permission. If you don't have this permission, the Open in IDE button will not be available to you.

Opening a project in a dev environment

  1. Open the required project.

  2. Do one of the following:

    • Open then the required project repository, then click Open in IDE.

    • On the project sidebar, choose Dev Environments, then click New environment.

  3. In the New Dev Environment window, specify the environment settings:

    • In the list of project branches, choose the branch you want to work with.

    • In Instance type, depending on the required compute resources, select a suitable dev environment instance.

    • Using IDE and IDE version, specify the IDE you want to use for development. Note that this IDE version must be installed on your local machine.

    • In Warm-up snapshot, choose the warm-up snapshot created during the dev environment preparation.

    • Specify Environment name. It'll help to distinguish this environment from others within the project.

    New dev environment
  4. Click Create.

  5. After this, Space will open the project in the selected IDE.

Performing code review in a dev environment

If you're assigned to perform a code review, you can do this in a dev environment.

  1. Open the required project.

  2. On the project sidebar, choose Code Reviews, then choose the required review.

  3. In the top right corner, click Open in IDE.

    Open code review in a dev environment
  4. In the New Dev Environment window, specify the environment settings:

    • In the list of project branches, choose the branch you want to work with.

    • In Instance type, depending on the required compute resources, select a suitable dev environment instance.

    • In IDE, choose the IDE you want to use for development. Note that the IDE must be installed on your local machine.

    • In Warm-up snapshot, choose the warm-up snapshot created during the dev environment setup.

    • Specify Environment name. It'll help to distinguish this environment from others within the project.

  5. Click Create.

  6. After this, Space will open the project in the selected IDE.

Sharing a dev environment with other team members

Dev environments let you collaboratively review, edit, and debug code with your colleagues in real time. To start collaborative work, you must share your dev environment. Note that you can share the environment only with those team members who have the Git Repositories: Write permission in your project. By default, these are members with the Project Admin, Project Member, and Project Collaborator roles.

To share a dev environment with a team member

  1. Open the project.

  2. In the sidebar, choose Dev Environments.

  3. Find the dev environment you want to share and in the dev environment menu Menu choose Share.

  4. In the Sharing Options window, choose Shared. Space will generate a sharing link.

  5. Copy the link and share it with a team member.

Developing GUI applications in dev environments

With dev environments you can develop not only web applications but also applications with native user interface. This is possible with the help of VNC or RDP technologies. The idea is to install a VNC server to a dev environment, forward the server port to your localhost, and use a local VNC client to work with the dev environment's remote desktop.

To start developing a GUI application in a dev environment

  1. On your local machine, install a VNC client. For example, VNC Viewer from RealVNC.

  2. Open your project in a dev environment.

  3. Install and run a VNC server in a dev environment. For example, X11VNC server:

    1. In JetBrains Fleet, open Terminal and run

      apt update && apt install x11vnc xvfb
    2. Run the server:

      x11vnc --create

      The VNC server will run on port 5900.

  4. Configure port forwarding for the port 5900:

    1. Press Ctrl+Shift+K (Cmd+Shift+K on macOS) and start typing forward port. Select the Forward Port action.

    2. Specify the port 5900. The destination port for your localhost will be shown in the Network Dashboard window. For example, it'll be port 63608.

  5. On your local machine, run the VNC client and connect to localhost:63608. This will run the VNC terminal window.

  6. Use the VNC terminal window to build and run the UI application you develop in the dev environment.

Using Docker in a dev environment

During development, quite often you need to run a service (say, a database server) in a Docker container.

To run Docker commands in a dev environment

  1. If you use a custom dev environment container image, make sure it includes Docker. The default image already includes Docker and Docker Compose.

  2. In your IDE, open Terminal and run docker commands as if you do it on your local machine.

Important: A dev environment itself also runs in a container. To help you run Docker in Docker, dev environments use the docker.sock socket. This means that your Docker commands will run not in a dev environment container but in the virtual machine that hosts the container.

Mounting a volume to a container

Suppose you want to run a Docker container and mount a directory on your dev environment into the container. If you specify a directory on a dev environment as a mount source, this will fail: docker will try to resolve this path not in the dev environment container but in the host machine.

To solve this issue, use the HOST_PROJECT_PATH environment variable. It points to the root directory of your source code on the host machine.

For example, to mount the directory with the project source code to /var/opt/project:

docker run -v $HOST_PROJECT_PATH:/var/opt/project ubuntu:latest

Port forwarding in a dev environment

To give you access to TCP ports of a dev environment, Space uses port forwarding. This lets you access web applications you develop in a dev environment from the browser running on your local machine.

To make port forwarding work, your dev environment container must have the lsof tool installed.

To forward a port

  1. Press Ctrl+Shift+K (Cmd+Shift+K on macOS) and start typing forward port. Select the Forward Port action.

  2. Specify the port that you want to forward. The destination port for your localhost will be shown in the Network Dashboard window.

To forward a port

  1. In the IDE, open Settings | Tools | Port Forwarding.

  2. Add the port that you want to forward.

Last modified: 26 January 2022