hackwaly / ocamlearlybird

OCaml debug adapter

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

the selected switch is not installed

grybouilli opened this issue · comments

Hello!
I'm a french student in my first year of prepatory school and in my cs class we've been using ocaml for a few months now and I really wanted to set vscode up to compile and debug my projects on it... So I tried multiple stuff and eventually came upon your repo which seems do be doing exactly what I'm looking for.

It's just that I'm not sure I'm doing the right thing to install your debug adapter.
Here's what I've done so far:
-I installed the extension you advised (Ocaml debugger)
-I copied the repository into my workspace file
-I created a switch using this command line: opam switch create . ocaml-base-compiler.4.06.1

When I try to run the debugger I get an error:

> Executing task: dune build --workspace /home/grybouilli/OPT/a_rendre/dune-workspace.dev ocaml_debug_adapter/main.bc <

        opam (internal) (exit 2)
/usr/bin/opam config env --switch 4.06.1 --sexp --set-switch > /tmp/dune43bdab.output
[ERROR] The selected switch 4.06.1 is not installed.

The terminal process terminated with exit code: 1

So, can someone help me on this please?

EDIT: So I ran opam switch create 4.06.1 and it seemed to do the trick. Now I have to deal with some missing lwt_ppx library... keeping you updated

EDIT: have to downgrade dune and it should be good

It should work on 4.07.1

opam switch 4.07.1
opam install earlybird

You should set up opam's env according to their doc. The way you used I've not tested

I did as you suggested but I still have the same problem now: it says dune 2.5.0 is not supported and that the only supported versions are:

  • 1.0 to 1.12
  • 2.0 to 2.2

do you know how I can downgrade dune?
also, once I ran your commands, should I add any files to my workspace? Should I only add the .vscode file from the repo or the whole thing?
because if I don't add anything the debugger won't enable itself
the exact error when debugging:

1 | (lang dune 2.5)
               ^^^
Error: Version 2.5 of dune is not supported.
Supported versions:
- 1.0 to 1.12
- 2.0 to 2.2
The terminal process terminated with exit code: 1

EDIT: I managed to downgrade dune to 2.1.3 by running opam install "dune>=2.2"
I now get the following error when starting the debug:

> Executing task in folder OPT_VScode: dune build --workspace /home/grybouilli/OPT_VScode/ocamlearlybird-0.1.5/dune-workspace.dev ocaml_debug_adapter/main.bc <

Error: Don't know how to build ocaml_debug_adapter/main.bc
The terminal process terminated with exit code: 1

apparently it fails to build main.bc. Here's my dune-workspace.dev file:

(lang dune 1.3)
(profile debug)
(context (opam (switch 4.07.1) (merlin)))

UPDATE:
So I was using earlybird 0.1.5 files by switching to 0.1.4.
but I honestly don't understand any of the stuff that is going on
https://zupimages.net/viewer.php?id=20/16/452r.png

Your lanuch.json configured wrong. Paste your lanuch.json and tasks.json of vsocde

the launch.json

{
  // Use IntelliSense to learn about possible attributes.
  // Hover to view descriptions of existing attributes.
  // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Debug",
      "type": "ocaml-debugger",
      "request": "launch",
      "program": "${workspaceRoot}/_build/default/ocaml_debug_adapter/main.bc",
      "arguments": ["--server", "--port=4711"],
      "preLaunchTask": "build-debug",
      "console": "internalConsole",
      "env": {
        "OCAMLRUNPARAM": "b"
      }
    },
    {
      "name": "Debug By Debug Server",
      "type": "ocaml-debugger",
      "request": "launch",
      "program": "${workspaceRoot}/_build/default/ocaml_debug_adapter/main.bc",
      "arguments": ["--server", "--port=4712"],
      "preLaunchTask": "build-debug",
      "console": "internalConsole",
      "env": {
        "OCAMLRUNPARAM": "b"
      },
      "debugServer": 4712
    },
    {
      "name": "earlybird",
      "type": "ocaml-debugger",
      "request": "launch",
      "program": "${workspaceRoot}/_build/default/main.bc",
      "console": "internalConsole",
      "dotMerlins": ["${workspaceRoot}/.merlin"],
      "noDebug": false,
      "stopOnEntry": false,
      "env": {
        "OCAMLRUNPARAM": "b"
      }
    }
  ]
}

the tasks.json

{
  // See https://go.microsoft.com/fwlink/?LinkId=733558
  // for the documentation about the tasks.json format
  "version": "2.0.0",
  "tasks": [
    {
      "label": "build-debug",
      "type": "shell",
      "command": "dune build ocaml_debug_adapter/main.bc --profile debug",
      "problemMatcher": ["$ocamlc"],
      "group": {
        "kind": "build",
        "isDefault": true
      }
    }
  ]
}

What program do you want to debug? ocamlearlybird is the debugger. What's your program?