[SOLVED] Gitlab-runner: custom executor is missing RunExec

Hello,
I have issue setting up a custom executor for gitlab-runner in LXC container. Whatever I tried ends with following error

WARNING: custom executor is missing RunExec
ERROR: Job failed: custom executor is missing RunExec
FATAL: custom executor is missing RunExec  

What I did?
Following this example
https://docs.gitlab.com/runner/executors/custom_examples/lxd.html

$ whoami
gitlab-runner

$ gitlab-runner list
Runtime platform                                    arch=amd64 os=linux pid=25175 revision=de7731dd version=12.1.0
Listing configured runners                          ConfigFile=/home/gitlab-runner/.gitlab-runner/config.toml

$ gitlab-runner register -n \
    --url http://gitlab.example.com/ \
    --registration-token xxxxx \
    --executor custom \
    --description "lxd-executor" \
    --builds-dir "/builds" \
    --cache-dir "/cache" \
    --custom-run-exec "/opt/lxd-executor/run.sh" \
    --custom-prepare-exec "/opt/lxd-executor/prepare.sh" \
    --custom-cleanup-exec "/opt/lxd-executor/cleanup.sh"

Registering runner... succeeded                     runner=Fay-xxxx
Runner registered successfully. Feel free to start it, but if it's running already the config should be automatically reloaded! 

$ gitlab-runner list
Runtime platform                                    arch=amd64 os=linux pid=25306 revision=de7731dd version=12.1.0
Listing configured runners                          ConfigFile=/home/gitlab-runner/.gitlab-runner/config.toml
lxd-executor                                        Executor=custom Token=xxxxx URL=http://gitlab.example.com/

$ cat /home/gitlab-runner/.gitlab-runner/config.toml
concurrent = 1
check_interval = 0

[session_server]
  session_timeout = 1800

[[runners]]
  name = "lxd-executor"
  url = "http://gitlab.example.com/"
  token = "xxxxx"
  executor = "custom"
  builds_dir = "/builds"
  cache_dir = "/cache"
  [runners.custom_build_dir]
  [runners.cache]
    [runners.cache.s3]
    [runners.cache.gcs]
  [runners.custom]
    prepare_exec = "/opt/lxd-executor/prepare.sh"
    run_exec = "/opt/lxd-executor/run.sh"
    cleanup_exec = "/opt/lxd-executor/cleanup.sh"

$ gitlab-runner exec custom test
Runtime platform                                    arch=amd64 os=linux pid=25524 revision=de7731dd version=12.1.0
Running with gitlab-runner 12.1.0 (de7731dd)
WARNING: custom executor is missing RunExec
ERROR: Job failed: custom executor is missing RunExec
FATAL: custom executor is missing RunExec

The configuration file has the run_exec specified but running job locally complains it doesn’t :confused: What am I doing wrong?

Thanks in advance

As Tomasz pointed out the gitlab-runner exec command is not using configuration file and all his configuration needs to be passed as command arguments

gitlab-runner exec custom \
              --builds-dir "/builds" \
              --cache-dir "/cache" \
              --custom-run-exec "/opt/lxd-executor/run.sh" \
              --custom-prepare-exec "/opt/lxd-executor/prepare.sh" \
              --custom-cleanup-exec "/opt/lxd-executor/cleanup.sh" \
              test

Source: https://gitlab.com/gitlab-org/gitlab-runner/issues/4570