I have been trying to get dap-mode for c++ to work. Below is my config related to dap-mode

(use-package dap-mode
  :after lsp-mode
  :commands dap-debug
  :hook ((c++-mode python-mode . dap-ui-mode) (python-mode . dap-mode))
  :config
  (dap-auto-configure-mode t)

  (setq dap-python-debugger 'debugpy)
  (require 'dap-python)

  (require 'dap-gdb-lldb)
  (require 'dap-lldb)
  (setq dap-lldb-debug-program "/usr/bin/lldb-vscode")
;;; ask user for executable to debug if not specified explicitly (c++)
  (setq dap-lldb-debugged-program-function (lambda () (read-file-name "Select file to debug.")))

  ;;; default debug template for (c++)
  (dap-register-debug-template
   "C++ LLDB dap"
   (list :type "lldb-vscode"
         :cwd nil
         :args nil
         :request "launch"
         :program nil))
;; (defun dap-python--pyenv-executable-find (command)
;;   (with-venv (executable-find "python")))

(add-hook 'dap-stopped-hook
	  (lambda (arg) (call-interactively #'dap-hydra)))

(defun dap-debug-create-or-edit-json-template ()
    "Edit the C++ debugging configuration or create + edit if none exists yet."
    (interactive)
    (let ((filename (concat (lsp-workspace-root) "/launch.json"))
	  (default "~/.config/emacs/default-launch.json"))
      (unless (file-exists-p filename)
	(copy-file default filename))
      (find-file-existing filename))))

The problem I am facing currently is that every time i run

dap-debug

while the file is open i get prompted for executable and when i select the candidate, I get the error

Wrong type argument: stringp, nil

From what I learned we get the above error when a function get a nil value while expecting a string but I don’t understand why the function will get a nil value when i selected the correct executable with appropriate compiler flags.

I would appreciate any help in the matter.