Perl5-IDEA icon indicating copy to clipboard operation
Perl5-IDEA copied to clipboard

Add dev container setting for Perl5 Interpreter

Open TobseF opened this issue 5 months ago • 2 comments

I want to create a replaceable workspace for our Perl project setup - with Dev-Containers. So I created a Docker image with all the Perl and modules and linked it in a .devcontainer file. After starting the dev container, the developer should be able to run and debug a perl-script without additional setup.

The only thing I'm missing is the Perl5 interpreter setup: Image

After the first start, this is set to: Disable Perl5 support.

Running a script without the setting, the Perl interpreter will fail with "Unable to detect perl interpreter for project"

Image

In devcontainers there is an option to set settings in the devcontainer.json:

      "settings": {
        "com.intellij:app:BaseRefactoringSettings.move_search_for_references_for_file": false,
        "com.intellij:app:HttpConfigurable.use_proxy_pac": true
      }

Is this supported out of the box, and if yes how can I find the right setting? If not, to add this for the Perl interpreter would help to set up a dev-container without any hacks.

I also tried to copy perl5.local.xml to the project in the postStartCommand in the devcontainer.json. But this will not recognized. Maybe because the container already started the IDE in this state. But also a restart does not help.

So is there any way to update the Perl plugin config in a dev container? I think such an option would also help others to speed up their project setup with Perl.

📂 Project Structure

  • .devcontainer
    • devcontainer.json
    • Dockerfile
    • perl5local.xml
    • setup-perl-config.sh
    • runConfigurations
      • test_pl-xml

🛠️ Files

devcontainer.json

{
  "name": "minimal_ubuntu",
  "dockerFile": "./Dockerfile",
  "onCreateCommand": {
    "update": "apt update && apt -y upgrade"
  },
  "postStartCommand": "/bin/bash /workspaces/app/.idea/setup-perl-config.sh",
  "customizations": {
    "jetbrains" : {
      "plugins": [
       "com.perl5",
        "org.jetbrains.plugins.gitlab",
        "izhangzhihao.rainbow.brackets.lite",
        "Batch Scripts Support",
        "String Manipulation",
        "zielu.gittoolbox",
        "GrepConsole",
        ],
      "settings": {
        "com.intellij:app:BaseRefactoringSettings.move_search_for_references_for_file": false,
        "com.intellij:app:HttpConfigurable.use_proxy_pac": true
      }
    },
    "settings": {
    },
    "backend": "IntelliJ"
  }
}

Dockerfile

FROM perl:5.34 AS builder

RUN apt-get update && apt-get install -y build-essential \
    cpanminus \
    libssl-dev \
    libmariadb-dev-compat libmariadb-dev \
    libdbd-mysql-perl
RUN cpanm Carton
RUN apt install -y git

COPY perl5local.xml /workspaces/app/.idea/perl5local.xml
COPY perl5shared.xml /workspaces/app/.idea/perl5shared.xml
COPY runConfigurations/test_pl.xml /workspaces/app/.idea/runConfigurations/test_pl.xml
COPY setup-perl-config.sh /workspaces/app/.idea/setup-perl-config.sh

WORKDIR /IdeaProjects/tmc/
COPY cpanfile .
RUN PROFILES=test,debug carton install

setup-perl-config.sh

#!/bin/bash
echo "[INFO] Setting up IntelliJ Perl config..."

cp /workspaces/app/.idea/perl5local.xml /IdeaProjects/tmc/.idea/perl5local.xml
cp /workspaces/app/.idea/perl5shared.xml /IdeaProjects/tmc/.idea/perl5shared.xml
cp /workspaces/app/.idea/runConfigurations/test_pl.xml /IdeaProjects/tmc/.idea/runConfigurations/test_pl.xml

TobseF avatar Jul 01 '25 15:07 TobseF

This is a new thing for me tbh. After recent changes you should be able to use perl with remote development pretty comfortably. The intended workflow is:

  • you create a devcontainer.json
  • put it into .devcontainer/devcontainer.json
  • use the Gateway app to set up the environment for you. It will build the image and install the IDE inside of it.
  • GW will start the image with project dir mounted inside the container as a project dir.
  • Backend part of the IDE will start inside the container, and locally you will have a ligthweight JBC app.
  • So, you don't need to copy anything insde the container, only configure the environment.

But, this does not work for me yet, escalated this to the JetBrains: https://youtrack.jetbrains.com/issue/IJPL-198423/Devcontainer-does-not-start-with-Cant-retrieve-image-ID-from-build-stream

Created a sample project that I intend to make working: https://github.com/Camelcade/perl-devcontainer-sample

After we will make it start, i will take a look into providing additional options to pre-configure project. E.g. add and select sdk.

hurricup avatar Jul 24 '25 05:07 hurricup

https://youtrack.jetbrains.com/issue/IJPL-174611/Let-plugin-developers-and-IDEs-define-their-plugin-settings-in-JSON

hurricup avatar Jul 24 '25 09:07 hurricup