From 860e802df276da0f3aa29bc88af60d74b5e978ce Mon Sep 17 00:00:00 2001
From: Jeremie Dimino <jeremie@dimino.org>
Date: Fri, 9 Apr 2021 13:29:41 +0100
Subject: [PATCH] Drop support for upgrading jbuilder projects

Signed-off-by: Jeremie Dimino <jeremie@dimino.org>
---
 CHANGES.md                                    |   2 +
 bin/common.ml                                 |   5 +-
 bin/common.mli                                |   6 +-
 bin/ocaml_merlin.ml                           |   8 +-
 bin/upgrade.ml                                |   2 +-
 boot/libs.ml                                  |   1 -
 src/dune_engine/action_builder.ml             |   3 +-
 src/dune_engine/dune                          |   1 -
 src/dune_engine/include_stanza.ml             |   5 +-
 src/dune_engine/source_tree.ml                |  37 +-
 src/dune_engine/source_tree.mli               |   6 -
 src/jbuild_support/atom.ml                    |  32 --
 src/jbuild_support/atom.mli                   |   1 -
 src/jbuild_support/dune                       |   6 -
 src/jbuild_support/lexer.mli                  |   1 -
 src/jbuild_support/lexer.mll                  | 223 -----------
 src/jbuild_support/string_with_vars.ml        | 190 ---------
 src/jbuild_support/string_with_vars.mli       |  11 -
 src/upgrader/dune                             |   9 +-
 src/upgrader/dune_upgrader.ml                 | 367 +-----------------
 .../a-dune-proj/a-dune-proj.opam              |   0
 .../embed-jbuild.t/a-dune-proj/dune           |   5 -
 .../embed-jbuild.t/a-dune-proj/dune-project   |   2 -
 .../a-jbuild-proj/a-jbuild-proj.opam          |   0
 .../embed-jbuild.t/a-jbuild-proj/jbuild       |   7 -
 .../test-cases/embed-jbuild.t/run.t           |  29 --
 .../test-cases/fallback-dune.t/jbuild/jbuild  |   5 -
 .../test-cases/syntax-versioning.t/run.t      |   9 +-
 .../test-cases/upgrader.t/jbuild              |  20 -
 .../test-cases/upgrader.t/jbuild.inc          |   4 -
 .../test-cases/upgrader.t/run.t               |  66 ----
 test/expect-tests/dune_lang/dune              |   1 -
 test/expect-tests/dune_lang/sexp_tests.ml     | 149 ++-----
 test/unit-tests/dune                          |   2 +-
 test/unit-tests/sexp_tests.ml                 |  94 ++---
 35 files changed, 109 insertions(+), 1200 deletions(-)
 delete mode 100644 src/jbuild_support/atom.ml
 delete mode 100644 src/jbuild_support/atom.mli
 delete mode 100644 src/jbuild_support/dune
 delete mode 100644 src/jbuild_support/lexer.mli
 delete mode 100644 src/jbuild_support/lexer.mll
 delete mode 100644 src/jbuild_support/string_with_vars.ml
 delete mode 100644 src/jbuild_support/string_with_vars.mli
 delete mode 100644 test/blackbox-tests/test-cases/embed-jbuild.t/a-dune-proj/a-dune-proj.opam
 delete mode 100644 test/blackbox-tests/test-cases/embed-jbuild.t/a-dune-proj/dune
 delete mode 100644 test/blackbox-tests/test-cases/embed-jbuild.t/a-dune-proj/dune-project
 delete mode 100644 test/blackbox-tests/test-cases/embed-jbuild.t/a-jbuild-proj/a-jbuild-proj.opam
 delete mode 100644 test/blackbox-tests/test-cases/embed-jbuild.t/a-jbuild-proj/jbuild
 delete mode 100644 test/blackbox-tests/test-cases/embed-jbuild.t/run.t
 delete mode 100644 test/blackbox-tests/test-cases/fallback-dune.t/jbuild/jbuild
 delete mode 100644 test/blackbox-tests/test-cases/upgrader.t/jbuild
 delete mode 100644 test/blackbox-tests/test-cases/upgrader.t/jbuild.inc

diff --git a/CHANGES.md b/CHANGES.md
index c1afb6bf092..6a6e6c3d3fc 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -95,6 +95,8 @@ Unreleased
 - Allow dune-file as an alternative file name for dune files (needs to be
   enabled in the dune-project file) (#4428, @nojb)
 
+- Drop support for upgrading jbuilder projects (#...., @jeremiedimino)
+
 2.8.5 (28/03/2021)
 ------------------
 
diff --git a/bin/common.ml b/bin/common.ml
index 70b4a2d900b..ae777c5ab95 100644
--- a/bin/common.ml
+++ b/bin/common.ml
@@ -128,7 +128,7 @@ let print_entering_message c =
     in
     Console.print [ Pp.verbatim (sprintf "Entering directory '%s'" dir) ]
 
-let init ?log_file ?(recognize_jbuilder_projects = false) c =
+let init ?log_file c =
   if c.root.dir <> Filename.current_dir_name then Sys.chdir c.root.dir;
   Path.set_root (normalize_path (Path.External.cwd ()));
   Path.Build.set_build_dir (Path.Build.Kind.of_string c.build_dir);
@@ -156,8 +156,7 @@ let init ?log_file ?(recognize_jbuilder_projects = false) c =
     |> S.set_ancestor_vcs c.root.ancestor_vcs
     |> S.set_execution_parameters
          (Dune_engine.Execution_parameters.builtin_default
-         |> Dune_rules.Workspace.update_execution_parameters w)
-    |> S.set_recognize_jbuilder_projects recognize_jbuilder_projects);
+         |> Dune_rules.Workspace.update_execution_parameters w));
   Dune_rules.Global.init ~capture_outputs:c.capture_outputs;
   (* CR-soon amokhov: Right now, types [Dune_config.Caching.Duplication.t] and
      [Dune_cache_storage.Mode.t] are the same. They will be unified after
diff --git a/bin/common.mli b/bin/common.mli
index 51a6893eb71..81c86ac2203 100644
--- a/bin/common.mli
+++ b/bin/common.mli
@@ -22,11 +22,7 @@ val prefix_target : t -> string -> string
 
     Return the final configuration, which is the same as the one returned in the
     [config] field of [Dune_rules.Workspace.workspace ()]) *)
-val init :
-     ?log_file:Dune_util.Log.File.t
-  -> ?recognize_jbuilder_projects:bool
-  -> t
-  -> Dune_config.t
+val init : ?log_file:Dune_util.Log.File.t -> t -> Dune_config.t
 
 (** [examples \[("description", "dune cmd foo"); ...\]] is an [EXAMPLES] manpage
     section of enumerated examples illustrating how to run the documented
diff --git a/bin/ocaml_merlin.ml b/bin/ocaml_merlin.ml
index 4a88aa06407..c9bbf96ce78 100644
--- a/bin/ocaml_merlin.ml
+++ b/bin/ocaml_merlin.ml
@@ -29,9 +29,7 @@ let term =
              ouptut.")
   in
   let common = Common.set_print_directory common false in
-  let config =
-    Common.init common ~log_file:No_log_file ~recognize_jbuilder_projects:true
-  in
+  let config = Common.init common ~log_file:No_log_file in
   Scheduler.go ~common ~config (fun () ->
       match dump_config with
       | Some s -> Dune_rules.Merlin_server.dump s
@@ -66,9 +64,7 @@ module Dump_dot_merlin = struct
               "The path to the folder of which the configuration should be \
                printed. Defaults to the current directory.")
     in
-    let config =
-      Common.init common ~log_file:No_log_file ~recognize_jbuilder_projects:true
-    in
+    let config = Common.init common ~log_file:No_log_file in
     Scheduler.go ~common ~config (fun () ->
         match path with
         | Some s -> Dune_rules.Merlin_server.dump_dot_merlin s
diff --git a/bin/upgrade.ml b/bin/upgrade.ml
index 08864d671cf..ff49b00cfb2 100644
--- a/bin/upgrade.ml
+++ b/bin/upgrade.ml
@@ -15,7 +15,7 @@ let info = Term.info "upgrade" ~doc ~man
 
 let term =
   let+ common = Common.term in
-  let config = Common.init common ~recognize_jbuilder_projects:true in
+  let config = Common.init common in
   Scheduler.go ~common ~config (fun () -> Dune_upgrader.upgrade ())
 
 let command = (term, info)
diff --git a/boot/libs.ml b/boot/libs.ml
index 7dd70332aa2..66d1bee4b5b 100644
--- a/boot/libs.ml
+++ b/boot/libs.ml
@@ -29,7 +29,6 @@ let local_libraries =
   ; ("src/section", Some "Dune_section", false, None)
   ; ("vendor/build_path_prefix_map/src", Some "Build_path_prefix_map", false,
     None)
-  ; ("src/jbuild_support", Some "Jbuild_support", false, None)
   ; ("otherlibs/dune-rpc/private", Some "Dune_rpc_private", false, None)
   ; ("src/dune_rpc_server", Some "Dune_rpc_server", false, None)
   ; ("src/csexp_rpc", Some "Csexp_rpc", false, None)
diff --git a/src/dune_engine/action_builder.ml b/src/dune_engine/action_builder.ml
index 5a81aaa3135..74906a78b05 100644
--- a/src/dune_engine/action_builder.ml
+++ b/src/dune_engine/action_builder.ml
@@ -147,8 +147,7 @@ let strings p =
 
 let read_sexp p =
   let+ s = contents p in
-  Dune_lang.Parser.parse_string s ~lexer:Dune_lang.Lexer.token
-    ~fname:(Path.to_string p) ~mode:Single
+  Dune_lang.Parser.parse_string s ~fname:(Path.to_string p) ~mode:Single
 
 let if_file_exists p ~then_ ~else_ = If_file_exists (p, then_, else_)
 
diff --git a/src/dune_engine/dune b/src/dune_engine/dune
index 768112b1449..f4c1f77e850 100644
--- a/src/dune_engine/dune
+++ b/src/dune_engine/dune
@@ -20,7 +20,6 @@
   ocaml_config
   chrome_trace
   stats
-  jbuild_support
   dune_action_plugin
   dune_util
   build_path_prefix_map
diff --git a/src/dune_engine/include_stanza.ml b/src/dune_engine/include_stanza.ml
index f6d1b34cf09..22a583b0860 100644
--- a/src/dune_engine/include_stanza.ml
+++ b/src/dune_engine/include_stanza.ml
@@ -45,8 +45,5 @@ let load_sexps ~context:{ current_file; include_stack } (loc, fn) =
         Path.Source.equal f current_file)
   then
     error { current_file; include_stack };
-  let sexps =
-    Dune_lang.Parser.load ~lexer:Dune_lang.Lexer.token
-      (Path.source current_file) ~mode:Many
-  in
+  let sexps = Dune_lang.Parser.load (Path.source current_file) ~mode:Many in
   (sexps, { current_file; include_stack })
diff --git a/src/dune_engine/source_tree.ml b/src/dune_engine/source_tree.ml
index de7e5ed12a2..79606a097d0 100644
--- a/src/dune_engine/source_tree.ml
+++ b/src/dune_engine/source_tree.ml
@@ -54,8 +54,6 @@ module Dune_file = struct
 
   let alternative_fname = "dune-file"
 
-  let jbuild_fname = "jbuild"
-
   type kind =
     | Plain
     | Ocaml_script
@@ -358,21 +356,16 @@ end
 module Settings = struct
   type t =
     { ancestor_vcs : Vcs.t option
-    ; recognize_jbuilder_projects : bool
     ; execution_parameters : Execution_parameters.t
     }
 
   let builtin_default =
     { ancestor_vcs = None
-    ; recognize_jbuilder_projects = false
     ; execution_parameters = Execution_parameters.builtin_default
     }
 
   let set_ancestor_vcs x t = { t with ancestor_vcs = x }
 
-  let set_recognize_jbuilder_projects x t =
-    { t with recognize_jbuilder_projects = x }
-
   let set_execution_parameters x t = { t with execution_parameters = x }
 
   let t : t Memo.Build.t Fdecl.t = Fdecl.create Dyn.Encoder.opaque
@@ -464,26 +457,10 @@ end = struct
       (visited, init)
   end
 
-  let dune_file ~(dir_status : Sub_dirs.Status.t) ~recognize_jbuilder_projects
-      ~path ~files ~project =
+  let dune_file ~(dir_status : Sub_dirs.Status.t) ~path ~files ~project =
     let file_exists =
       if dir_status = Data_only then
         None
-      else if
-        (not recognize_jbuilder_projects)
-        && String.Set.mem files Dune_file.jbuild_fname
-      then
-        User_error.raise
-          ~loc:
-            (Loc.in_file
-               (Path.source (Path.Source.relative path Dune_file.jbuild_fname)))
-          [ Pp.text
-              "jbuild files are no longer supported, please convert this file \
-               to a dune file instead."
-          ; Pp.text
-              "Note: You can use \"dune upgrade\" to convert your project to \
-               dune."
-          ]
       else if
         Dune_project.accept_alternative_dune_file_name project
         && String.Set.mem files Dune_file.alternative_fname
@@ -524,13 +501,7 @@ end = struct
 
   let contents { Readdir.dirs; files } ~dirs_visited ~project ~path
       ~(dir_status : Sub_dirs.Status.t) =
-    let* recognize_jbuilder_projects =
-      let+ settings = Settings.get () in
-      settings.recognize_jbuilder_projects
-    in
-    let+ dune_file =
-      dune_file ~dir_status ~recognize_jbuilder_projects ~files ~project ~path
-    in
+    let+ dune_file = dune_file ~dir_status ~files ~project ~path in
     let sub_dirs = Dune_file.sub_dirs dune_file in
     let dirs_visited, sub_dirs =
       Get_subdir.all ~dirs_visited ~dirs ~sub_dirs ~parent_status:dir_status
@@ -613,7 +584,6 @@ end = struct
       | None -> Memo.Build.return None
       | Some (parent_dir, dirs_visited, dir_status, virtual_) ->
         let dirs_visited = Dirs_visited.Per_fn.find dirs_visited path in
-        let* settings = Settings.get () in
         let readdir =
           if virtual_ then
             Readdir.empty
@@ -628,8 +598,7 @@ end = struct
           else
             Option.value
               (Dune_project.load ~dir:path ~files:readdir.files
-                 ~infer_from_opam_files:settings.recognize_jbuilder_projects
-                 ~dir_status)
+                 ~infer_from_opam_files:false ~dir_status)
               ~default:parent_dir.project
         in
         let vcs = get_vcs ~default:parent_dir.vcs ~readdir ~path in
diff --git a/src/dune_engine/source_tree.mli b/src/dune_engine/source_tree.mli
index ef416449a98..72513aef28e 100644
--- a/src/dune_engine/source_tree.mli
+++ b/src/dune_engine/source_tree.mli
@@ -8,8 +8,6 @@ module Dune_file : sig
 
   val alternative_fname : string
 
-  val jbuild_fname : string
-
   type kind = private
     | Plain
     | Ocaml_script
@@ -82,10 +80,6 @@ module Settings : sig
       this is the vcs that will be used for the root. *)
   val set_ancestor_vcs : Vcs.t option -> t -> t
 
-  (** Whether we recognise jbuilder projects. This is only set to [true] by the
-      upgrader. *)
-  val set_recognize_jbuilder_projects : bool -> t -> t
-
   (** The default execution parameters. *)
   val set_execution_parameters : Execution_parameters.t -> t -> t
 end
diff --git a/src/jbuild_support/atom.ml b/src/jbuild_support/atom.ml
deleted file mode 100644
index 5303fc64223..00000000000
--- a/src/jbuild_support/atom.ml
+++ /dev/null
@@ -1,32 +0,0 @@
-open Stdune
-
-let is_valid str =
-  let len = String.length str in
-  len > 0
-  &&
-  let rec loop ix =
-    match str.[ix] with
-    | '"'
-    | '('
-    | ')'
-    | ';' ->
-      true
-    | '|' ->
-      ix > 0
-      &&
-      let next = ix - 1 in
-      str.[next] = '#' || loop next
-    | '#' ->
-      ix > 0
-      &&
-      let next = ix - 1 in
-      str.[next] = '|' || loop next
-    | ' '
-    | '\t'
-    | '\n'
-    | '\012'
-    | '\r' ->
-      true
-    | _ -> ix > 0 && loop (ix - 1)
-  in
-  not (loop (len - 1))
diff --git a/src/jbuild_support/atom.mli b/src/jbuild_support/atom.mli
deleted file mode 100644
index 213168f1ad4..00000000000
--- a/src/jbuild_support/atom.mli
+++ /dev/null
@@ -1 +0,0 @@
-val is_valid : string -> bool
diff --git a/src/jbuild_support/dune b/src/jbuild_support/dune
deleted file mode 100644
index f1e3b6608b0..00000000000
--- a/src/jbuild_support/dune
+++ /dev/null
@@ -1,6 +0,0 @@
-(library
- (name jbuild_support)
- (libraries stdune dune_lang)
- (synopsis "Internal Dune library, do not use!"))
-
-(ocamllex lexer)
diff --git a/src/jbuild_support/lexer.mli b/src/jbuild_support/lexer.mli
deleted file mode 100644
index e396cc7e010..00000000000
--- a/src/jbuild_support/lexer.mli
+++ /dev/null
@@ -1 +0,0 @@
-val token : Dune_lang.Lexer.t
diff --git a/src/jbuild_support/lexer.mll b/src/jbuild_support/lexer.mll
deleted file mode 100644
index 55d9f95bcb0..00000000000
--- a/src/jbuild_support/lexer.mll
+++ /dev/null
@@ -1,223 +0,0 @@
-{
-open Stdune
-open Dune_lang
-
-let error ?(delta = 0) lexbuf message =
-  let start = Lexing.lexeme_start_p lexbuf in
-  let loc : Loc.t =
-    { start = { start with pos_cnum = start.pos_cnum + delta }
-    ; stop = Lexing.lexeme_end_p lexbuf
-    }
-  in
-  User_error.raise ~loc [ Pp.text message ]
-
-let invalid_dune_or_jbuild lexbuf =
-  let start = Lexing.lexeme_start_p lexbuf in
-  let fname = Filename.basename start.pos_fname in
-  error lexbuf (sprintf "Invalid %s file" fname)
-
-let escaped_buf = Buffer.create 256
-
-type escape_sequence =
-  | Newline
-  | Other
-
-let eval_decimal_char c = Char.code c - Char.code '0'
-
-let eval_decimal_escape c1 c2 c3 =
-  (eval_decimal_char c1 * 100)
-  + (eval_decimal_char c2 * 10)
-  + eval_decimal_char c3
-
-let eval_hex_char c =
-  match c with
-  | '0' .. '9' -> Char.code c - Char.code '0'
-  | 'a' .. 'f' -> Char.code c - Char.code 'a' + 10
-  | 'A' .. 'F' -> Char.code c - Char.code 'A' + 10
-  | _ -> -1
-
-let eval_hex_escape c1 c2 = (eval_hex_char c1 * 16) + eval_hex_char c2
-
-(* The difference between the old and new syntax is that the old
-   syntax allows backslash following by any characters other than 'n',
-   'x', ... and interpret it as it. The new syntax is stricter in
-   order to allow introducing new escape sequence in the future if
-   needed. *)
-type escape_mode =
-  | In_block_comment (* Inside #|...|# comments (old syntax) *)
-  | In_quoted_string
-}
-
-let comment_body = [^ '\n' '\r']*
-let comment   = ';' comment_body
-let newline   = '\r'? '\n'
-let blank     = [' ' '\t' '\012']
-let digit     = ['0'-'9']
-let hexdigit  = ['0'-'9' 'a'-'f' 'A'-'F']
-
-let atom_char =
-  [^ ';' '(' ')' '"' ' ' '\t' '\r' '\n' '\012']
-
-(* rule for jbuild files *)
-rule token with_comments = parse
-  | newline
-    { Lexing.new_line lexbuf; token with_comments lexbuf }
-  | blank+
-    { token with_comments lexbuf }
-  | comment
-    { if with_comments then
-        comment_trail [Stdune.String.drop (Lexing.lexeme lexbuf) 1] lexbuf
-      else
-        token with_comments lexbuf
-    }
-  | '('
-    { Lexer.Token.Lparen }
-  | ')'
-    { Rparen }
-  | '"'
-    { Buffer.clear escaped_buf;
-      let start = Lexing.lexeme_start_p lexbuf in
-      let s = quoted_string In_quoted_string lexbuf in
-      lexbuf.lex_start_p <- start;
-      Quoted_string s
-    }
-  | "#|"
-    { let start = Lexing.lexeme_start_p lexbuf in
-      block_comment lexbuf;
-      if with_comments then begin
-        lexbuf.lex_start_p <- start;
-        Comment Legacy
-      end else
-        token false lexbuf
-    }
-  | "#;"
-    { Sexp_comment }
-  | eof
-    { Eof }
-  | ""
-    { atom "" (Lexing.lexeme_start_p lexbuf) lexbuf }
-
-and comment_trail acc = parse
-  | newline blank* ';' (comment_body as s)
-    { comment_trail (s :: acc) lexbuf }
-  | ""
-    { Lexer.Token.Comment (Lines (List.rev acc)) }
-
-and atom acc start = parse
-  | '#'+ '|'
-    { lexbuf.lex_start_p <- start;
-      error lexbuf "jbuild atoms cannot contain #|"
-    }
-  | '|'+ '#'
-    { lexbuf.lex_start_p <- start;
-      error lexbuf "jbuild atoms cannot contain |#"
-    }
-  | ('#'+ | '|'+ | (atom_char # ['|' '#'])) as s
-    { atom (if acc = "" then s else acc ^ s) start lexbuf
-    }
-  | ""
-    { if acc = "" then invalid_dune_or_jbuild lexbuf;
-      lexbuf.lex_start_p <- start;
-      Lexer.Token.Atom (Atom.of_string acc)
-    }
-
-and quoted_string mode = parse
-  | '"'
-    { Buffer.contents escaped_buf }
-  | '\\'
-    { match escape_sequence mode lexbuf with
-      | Newline -> quoted_string_after_escaped_newline mode lexbuf
-      | Other   -> quoted_string                       mode lexbuf
-    }
-  | newline as s
-    { Lexing.new_line lexbuf;
-      Buffer.add_string escaped_buf s;
-      quoted_string mode lexbuf
-    }
-  | _ as c
-    { Buffer.add_char escaped_buf c;
-      quoted_string mode lexbuf
-    }
-  | eof
-    { if mode = In_block_comment then
-        error lexbuf "unterminated quoted string";
-      Buffer.contents escaped_buf
-    }
-
-and quoted_string_after_escaped_newline mode = parse
-  | [' ' '\t']*
-    { quoted_string mode lexbuf }
-
-and block_comment = parse
-  | '"'
-    { Buffer.clear escaped_buf;
-      ignore (quoted_string In_block_comment lexbuf : string);
-      block_comment lexbuf
-    }
-  | "|#"
-    { ()
-    }
-  | eof
-    { error lexbuf "unterminated block comment"
-    }
-  | _
-    { block_comment lexbuf
-    }
-
-and escape_sequence mode = parse
-  | newline
-    { Lexing.new_line lexbuf;
-      Newline }
-  | ['\\' '\'' '"' 'n' 't' 'b' 'r'] as c
-    { let c =
-        match c with
-        | 'n' -> '\n'
-        | 'r' -> '\r'
-        | 'b' -> '\b'
-        | 't' -> '\t'
-        | _   -> c
-      in
-      Buffer.add_char escaped_buf c;
-      Other
-    }
-  | (digit as c1) (digit as c2) (digit as c3)
-    { let v = eval_decimal_escape c1 c2 c3 in
-      if mode = In_quoted_string && v > 255 then
-        error lexbuf "escape sequence in quoted string out of range"
-          ~delta:(-1);
-      Buffer.add_char escaped_buf (Char.chr v);
-      Other
-    }
-  | digit* as s
-    { if mode = In_quoted_string then
-        error lexbuf "unterminated decimal escape sequence" ~delta:(-1);
-      Buffer.add_char escaped_buf '\\';
-      Buffer.add_string escaped_buf s;
-      Other
-    }
-  | 'x' (hexdigit as c1) (hexdigit as c2)
-    { let v = eval_hex_escape c1 c2 in
-      Buffer.add_char escaped_buf (Char.chr v);
-      Other
-    }
-  | 'x' hexdigit* as s
-    { if mode = In_quoted_string then
-        error lexbuf "unterminated hexadecimal escape sequence" ~delta:(-1);
-      Buffer.add_char escaped_buf '\\';
-      Buffer.add_string escaped_buf s;
-      Other
-    }
-  | _ as c
-    { Buffer.add_char escaped_buf '\\';
-      Buffer.add_char escaped_buf c;
-      Other
-    }
-  | eof
-    { if mode = In_quoted_string then
-        error lexbuf "unterminated escape sequence" ~delta:(-1);
-      Other
-    }
-
-{
-  let token ~with_comments lexbuf = token with_comments lexbuf
-}
diff --git a/src/jbuild_support/string_with_vars.ml b/src/jbuild_support/string_with_vars.ml
deleted file mode 100644
index 8194ff6dd05..00000000000
--- a/src/jbuild_support/string_with_vars.ml
+++ /dev/null
@@ -1,190 +0,0 @@
-open Stdune
-
-type var_syntax =
-  | Parens
-  | Braces
-
-type var =
-  { loc : Loc.t
-  ; name : string
-  ; payload : string option
-  ; syntax : var_syntax
-  }
-
-type part =
-  | Text of string
-  | Var of var
-
-module Token = struct
-  type t =
-    | String of string
-    | Open of var_syntax
-    | Close of var_syntax
-
-  let tokenise s =
-    let len = String.length s in
-    let sub i j = String.sub s ~pos:i ~len:(j - i) in
-    let cons_str i j acc =
-      if i = j then
-        acc
-      else
-        String (sub i j) :: acc
-    in
-    let rec loop i j =
-      if j = len then
-        cons_str i j []
-      else
-        match s.[j] with
-        | '}' -> cons_str i j (Close Braces :: loop (j + 1) (j + 1))
-        | ')' -> cons_str i j (Close Parens :: loop (j + 1) (j + 1))
-        | '$' when j + 1 < len -> (
-          match s.[j + 1] with
-          | '{' -> cons_str i j (Open Braces :: loop (j + 2) (j + 2))
-          | '(' -> cons_str i j (Open Parens :: loop (j + 2) (j + 2))
-          | _ -> loop i (j + 1))
-        | _ -> loop i (j + 1)
-    in
-    loop 0 0
-
-  let to_string = function
-    | String s -> s
-    | Open Braces -> "${"
-    | Open Parens -> "$("
-    | Close Braces -> "}"
-    | Close Parens -> ")"
-end
-
-(* Remark: Consecutive [Text] items are concatenated. *)
-let rec of_tokens : Loc.t -> Token.t list -> part list =
- fun loc -> function
-  | [] -> []
-  | Open a :: String s :: Close b :: rest when a = b ->
-    let name, payload =
-      match String.lsplit2 s ~on:':' with
-      | None -> (s, None)
-      | Some (n, p) -> (n, Some p)
-    in
-    Var { loc; name; payload; syntax = a } :: of_tokens loc rest
-  | token :: rest -> (
-    let s = Token.to_string token in
-    match of_tokens loc rest with
-    | Text s' :: l -> Text (s ^ s') :: l
-    | l -> Text s :: l)
-
-let parse ~loc s = of_tokens loc (Token.tokenise s)
-
-module Upgrade_var = struct
-  type info =
-    | Keep
-    | Deleted of string
-    | Renamed_to of string
-
-  let map =
-    let macros =
-      [ ("exe", Keep)
-      ; ("bin", Keep)
-      ; ("lib", Keep)
-      ; ("libexec", Keep)
-      ; ("lib-available", Keep)
-      ; ("version", Keep)
-      ; ("read", Keep)
-      ; ("read-lines", Keep)
-      ; ("read-strings", Keep)
-      ; ("path", Renamed_to "dep")
-      ; ("findlib", Renamed_to "lib")
-      ; ("path-no-dep", Deleted "")
-      ; ("ocaml-config", Keep)
-      ]
-    in
-    let static_vars =
-      [ ( "<"
-        , Deleted
-            "Use a named dependency instead:\n\n\
-            \  (deps (:x <dep>) ...)\n\
-            \   ... %{x} ..." )
-      ; ("@", Renamed_to "targets")
-      ; ("^", Renamed_to "deps")
-      ; ("SCOPE_ROOT", Renamed_to "project_root")
-      ]
-    in
-    let lowercased =
-      [ ("cpp", Keep)
-      ; ("pa_cpp", Keep)
-      ; ("cc", Keep)
-      ; ("cxx", Keep)
-      ; ("ocaml", Keep)
-      ; ("ocamlc", Keep)
-      ; ("ocamlopt", Keep)
-      ; ("arch_sixtyfour", Keep)
-      ; ("make", Keep)
-      ]
-    in
-    let uppercased =
-      List.map lowercased ~f:(fun (k, _) -> (String.uppercase k, Renamed_to k))
-    in
-    let other =
-      [ ("-verbose", Keep)
-      ; ("ocaml_bin", Keep)
-      ; ("ocaml_version", Keep)
-      ; ("ocaml_where", Keep)
-      ; ("null", Keep)
-      ; ("ext_obj", Keep)
-      ; ("ext_asm", Keep)
-      ; ("ext_lib", Keep)
-      ; ("ext_dll", Keep)
-      ; ("ext_exe", Keep)
-      ; ("profile", Keep)
-      ; ("workspace_root", Keep)
-      ; ("context_name", Keep)
-      ; ("ROOT", Renamed_to "workspace_root")
-      ; ("corrected-suffix", Keep)
-      ; ("library-name", Keep)
-      ; ("impl-files", Keep)
-      ; ("intf-files", Keep)
-      ]
-    in
-    String.Map.of_list_exn
-      (List.concat [ macros; static_vars; lowercased; uppercased; other ])
-end
-
-let string_of_var { loc = _; name; payload; syntax } =
-  let s =
-    match payload with
-    | None -> name
-    | Some p -> sprintf "%s:%s" name p
-  in
-  match syntax with
-  | Parens -> sprintf "$(%s)" s
-  | Braces -> sprintf "${%s}" s
-
-let upgrade_to_dune s ~loc ~quoted ~allow_first_dep_var =
-  let map_var v =
-    match String.Map.find Upgrade_var.map v.name with
-    | None -> None
-    | Some info -> (
-      match info with
-      | Deleted repl ->
-        if v.name = "<" && allow_first_dep_var then
-          Some v.name
-        else
-          User_error.raise ~loc:v.loc
-            [ Pp.textf "this form is not allowed in dune files.%s" repl ]
-      | Keep -> Some v.name
-      | Renamed_to new_name -> Some new_name)
-  in
-  let map_part = function
-    | Text s -> Dune_lang.Template.Text s
-    | Var v -> (
-      match map_var v with
-      | None -> Text (string_of_var v)
-      | Some name -> Pform { name; payload = v.payload; loc = v.loc })
-  in
-  let parts = List.map (parse ~loc s) ~f:map_part in
-  match
-    List.fold_left parts ~init:(Some "") ~f:(fun acc part ->
-        match (acc, part) with
-        | Some s, Dune_lang.Template.Text s' -> Some (s ^ s')
-        | _ -> None)
-  with
-  | None -> Dune_lang.Ast.Template { quoted; parts; loc }
-  | Some s -> Dune_lang.Ast.atom_or_quoted_string loc s
diff --git a/src/jbuild_support/string_with_vars.mli b/src/jbuild_support/string_with_vars.mli
deleted file mode 100644
index aaaf09219f7..00000000000
--- a/src/jbuild_support/string_with_vars.mli
+++ /dev/null
@@ -1,11 +0,0 @@
-open Stdune
-
-(** Upgrade string with variables coming from a [jbuild] file to one suitable
-    for a [dune] file. Fail if the [<] variable is found and
-    [allow_first_dep_var] is [true]. *)
-val upgrade_to_dune :
-     string
-  -> loc:Loc.t
-  -> quoted:bool
-  -> allow_first_dep_var:bool
-  -> Dune_lang.Ast.t
diff --git a/src/upgrader/dune b/src/upgrader/dune
index edeb413be6c..8173abcb202 100644
--- a/src/upgrader/dune
+++ b/src/upgrader/dune
@@ -1,11 +1,4 @@
 (library
  (name dune_upgrader)
- (libraries
-  stdune
-  memo
-  opam_file_format
-  dune_lang
-  jbuild_support
-  dune_engine
-  fiber)
+ (libraries stdune memo opam_file_format dune_lang dune_engine fiber)
  (synopsis "Internal Dune library, do not use!"))
diff --git a/src/upgrader/dune_upgrader.ml b/src/upgrader/dune_upgrader.ml
index a8ccd7917ec..e0a4d7e7d07 100644
--- a/src/upgrader/dune_upgrader.ml
+++ b/src/upgrader/dune_upgrader.ml
@@ -15,7 +15,7 @@ type todo =
   }
 
 type project_version =
-  | Jbuild_project
+  | Unknown
   | Dune2_project
   | Dune1_project
 
@@ -160,351 +160,6 @@ module Common = struct
     )
 end
 
-module V1 = struct
-  open Common
-
-  let rename_basename base =
-    match
-      String.drop_prefix base ~prefix:Source_tree.Dune_file.jbuild_fname
-    with
-    | None -> base
-    | Some suffix -> "dune" ^ suffix
-
-  let upgrade_stanza stanza =
-    let open Dune_lang.Ast in
-    let simplify_field = function
-      | "action"
-      | "generate_runner"
-      | "lint"
-      | "preprocess"
-      | "self_build_stubs_archive" ->
-        false
-      | _ -> true
-    in
-    let is_rule_field = function
-      | "targets"
-      | "deps"
-      | "action"
-      | "locks"
-      | "fallback"
-      | "mode" ->
-        true
-      | _ -> false
-    in
-    let rec uses_first_dep_var = function
-      | Atom _
-      | Quoted_string _ ->
-        false
-      | List (_, l) -> List.exists l ~f:uses_first_dep_var
-      | Template x ->
-        List.exists x.parts ~f:(function
-          | Dune_lang.Template.Pform { name = "<"; _ } -> true
-          | _ -> false)
-    in
-    let rec map_var ~f = function
-      | (Atom _ | Quoted_string _) as x -> x
-      | List (loc, l) -> List (loc, List.map l ~f:(map_var ~f))
-      | Template x ->
-        Template
-          { x with
-            parts =
-              List.map x.parts ~f:(function
-                | Dune_lang.Template.Pform v -> f v
-                | x -> x)
-          }
-    in
-    let upgrade_string s ~loc ~quoted =
-      Jbuild_support.String_with_vars.upgrade_to_dune s ~loc ~quoted
-        ~allow_first_dep_var:true
-    in
-    let rec upgrade = function
-      | Atom (loc, A s) -> (
-        match s with
-        | "files_recursively_in" ->
-          Atom (loc, Dune_lang.Atom.of_string "source_tree")
-        | _ -> upgrade_string s ~loc ~quoted:false)
-      | Template _ as x -> x
-      | Quoted_string (loc, s) -> upgrade_string s ~loc ~quoted:true
-      | List (loc, l) ->
-        let l =
-          match l with
-          | [ (Atom (loc, A "fallback") as x) ] ->
-            [ Atom (loc, Dune_lang.Atom.of_string "mode"); x ]
-          | [ (Atom (_, A "include") as x)
-            ; (Atom (loc, A s) | Quoted_string (loc, s))
-            ] ->
-            let base = Filename.basename s in
-            let is_basename = base = s in
-            let new_base = rename_basename base in
-            let s =
-              if is_basename then
-                new_base
-              else
-                Filename.concat (Filename.dirname s) new_base
-            in
-            [ x
-            ; Dune_lang.Ast.add_loc ~loc (Dune_lang.atom_or_quoted_string s)
-            ]
-          | [ Atom _; List (_, [ Atom (_, A ":include"); Atom _ ]) ] ->
-            List.map l ~f:upgrade
-          | (Atom (_, A ("preprocess" | "lint")) as field) :: rest ->
-            upgrade field
-            ::
-            List.map rest ~f:(fun x ->
-                map_var (upgrade x) ~f:(fun (v : Dune_lang.Template.Pform.t) ->
-                    Dune_lang.Template.Pform
-                      (if v.name = "<" then
-                        { v with name = "input-file" }
-                      else
-                        v)))
-          | (Atom (_, A "per_module") as field) :: specs ->
-            upgrade field
-            ::
-            List.map specs ~f:(function
-              | List (loc, [ spec; List (_, modules) ]) ->
-                List (loc, upgrade spec :: List.map modules ~f:upgrade)
-              | sexp -> upgrade sexp)
-          | [ (Atom (_, A "pps") as field); List (_, pps) ] -> (
-            let pps, args =
-              List.partition_map pps ~f:(function
-                | (Atom (_, A s) | Quoted_string (_, s)) as sexp
-                  when String.is_prefix s ~prefix:"-" ->
-                  Right [ sexp ]
-                | List (_, l) -> Right l
-                | sexp -> Left sexp)
-            in
-            let args = List.concat args in
-            upgrade field :: pps
-            @
-            match args with
-            | [] -> []
-            | _ -> Atom (loc, Dune_lang.Atom.of_string "--") :: args)
-          | [ (Atom (_, A field_name) as field); List (_, args) ]
-            when match (field_name, args) with
-                 | "rule", Atom (_, A field_name) :: _ ->
-                   is_rule_field field_name
-                 | _ -> simplify_field field_name ->
-            upgrade field :: List.map args ~f:upgrade
-          | _ -> List.map l ~f:upgrade
-        in
-        let l =
-          if List.exists l ~f:uses_first_dep_var then
-            List.map l ~f:(function
-              | List (loc, (Atom (_, A "deps") as field) :: first :: rest) ->
-                List
-                  ( loc
-                  , field
-                    ::
-                    (let loc = Dune_lang.Ast.loc first in
-                     List
-                       ( loc
-                       , [ Atom (loc, Dune_lang.Atom.of_string ":<"); first ] ))
-                    :: rest )
-              | x -> x)
-          else
-            l
-        in
-        List (loc, l)
-    in
-    upgrade stanza
-
-  let load_jbuild_ignore path =
-    let path = Path.source path in
-    String.Set.of_list (Io.lines_of_file path)
-
-  let upgrade_file todo file sexps comments ~look_for_jbuild_ignore =
-    let dir = Path.Source.parent_exn file in
-    let new_file =
-      let base = Path.Source.basename file in
-      let new_base = rename_basename base in
-      Path.Source.relative dir new_base
-    in
-    let sexps =
-      List.filter sexps ~f:(function
-        | Dune_lang.Ast.List (_, [ Atom (_, A "jbuild_version"); _ ]) -> false
-        | _ -> true)
-    in
-    let sexps = List.map sexps ~f:upgrade_stanza in
-    let sexps, extra_files_to_delete =
-      (* Port the jbuild-ignore file if necessary *)
-      let jbuild_ignore = Path.Source.relative dir "jbuild-ignore" in
-      if not (look_for_jbuild_ignore && Path.exists (Path.source jbuild_ignore))
-      then
-        (sexps, [])
-      else
-        let data_only_dirs = load_jbuild_ignore jbuild_ignore in
-        let stanza =
-          Dune_lang.Ast.add_loc ~loc:Loc.none
-            (List
-               (Dune_lang.atom "data_only_dirs"
-                ::
-                List.map
-                  (String.Set.to_list data_only_dirs)
-                  ~f:Dune_lang.atom_or_quoted_string))
-        in
-        let sexps = stanza :: sexps in
-        (sexps, [ jbuild_ignore ])
-    in
-    let sexps =
-      Dune_lang.Parser.insert_comments
-        (List.map ~f:Dune_lang.Cst.concrete sexps)
-        comments
-    in
-    let contents =
-      let version = !Dune_project.default_dune_language_version in
-      Format.asprintf "%a@?" Pp.to_fmt
-        (Format_dune_lang.pp_top_sexps ~version sexps)
-    in
-    todo.to_rename_and_edit <-
-      { original_file = file; new_file; extra_files_to_delete; contents }
-      :: todo.to_rename_and_edit
-
-  (* This was obtained by trial and error. We should improve the opam parsing
-     API to return better locations. *)
-  let rec end_offset_of_opam_value : OpamParserTypes.value -> int = function
-    | Bool ((_, _, ofs), b) -> ofs + String.length (string_of_bool b)
-    | Int ((_, _, ofs), x) -> ofs + String.length (string_of_int x)
-    | String ((_, _, ofs), _) -> ofs + 1
-    | Relop (_, _, _, v)
-    | Prefix_relop (_, _, v)
-    | Logop (_, _, _, v)
-    | Pfxop (_, _, v) ->
-      end_offset_of_opam_value v
-    | Ident ((_, _, ofs), x) -> ofs + String.length x
-    | List ((_, _, ofs), _)
-    | Group ((_, _, ofs), _)
-    | Option ((_, _, ofs), _, _) ->
-      ofs (* this is definitely wrong *)
-    | Env_binding ((_, _, ofs), _, _, _) -> ofs
-
-  (* probably wrong *)
-
-  let upgrade_opam_file todo fn =
-    let open OpamParserTypes in
-    let s = Io.read_file (Path.source fn) ~binary:true in
-    let lb = Lexbuf.from_string s ~fname:(Path.Source.to_string fn) in
-    let t =
-      Opam_file.parse lb |> Opam_file.absolutify_positions ~file_contents:s
-    in
-    let substs = ref [] in
-    let add_subst start stop repl = substs := (start, stop, repl) :: !substs in
-    let replace_string (_, _, ofs) old repl =
-      let len = String.length old in
-      add_subst (ofs - len) ofs repl
-    in
-    let replace_jbuilder pos = replace_string pos "jbuilder" "dune" in
-    let rec scan = function
-      | String (jpos, "jbuilder") -> replace_jbuilder jpos
-      | Option (pos, String (jpos, "jbuilder"), l) ->
-        replace_jbuilder jpos;
-        let _, _, start = pos in
-        let stop = end_offset_of_opam_value (List.last l |> Option.value_exn) in
-        add_subst (start + 1) stop
-          (sprintf "build & >= %S"
-             (Dune_lang.Syntax.Version.to_string
-                !Dune_project.default_dune_language_version))
-      | List
-          (_, (String (jpos, "jbuilder") :: String (arg_pos, "subst") :: _ as l))
-        ->
-        replace_jbuilder jpos;
-        let _, _, start = arg_pos in
-        let stop = end_offset_of_opam_value (List.last l |> Option.value_exn) in
-        let start = start + 1 in
-        if start < stop then add_subst start stop ""
-      | List
-          ( _
-          , (String (jpos, "jbuilder")
-             :: String (arg_pos, ("build" | "runtest")) :: _ as l) ) ->
-        replace_jbuilder jpos;
-        let _, _, start = arg_pos in
-        let stop = end_offset_of_opam_value (List.last l |> Option.value_exn) in
-        let start = start + 1 in
-        let stop =
-          if start < stop then
-            stop
-          else
-            start
-        in
-        add_subst start stop {| "-p" name "-j" jobs|}
-      | Bool _
-      | Int _
-      | String _
-      | Relop _
-      | Logop _
-      | Pfxop _
-      | Ident _
-      | Prefix_relop _ ->
-        ()
-      | List (_, l)
-      | Group (_, l) ->
-        List.iter l ~f:scan
-      | Option (_, v, l) ->
-        scan v;
-        List.iter l ~f:scan
-      | Env_binding (_, v1, _, v2) ->
-        scan v1;
-        scan v2
-    in
-    let rec scan_item = function
-      | Section (_, s) -> List.iter s.section_items ~f:scan_item
-      | Variable (_, _, v) -> scan v
-    in
-    List.iter t.file_contents ~f:scan_item;
-    let substs = List.sort !substs ~compare:Poly.compare in
-    if List.is_non_empty substs then (
-      let buf = Buffer.create (String.length s + 128) in
-      let ofs =
-        List.fold_left substs ~init:0 ~f:(fun ofs (start, stop, repl) ->
-            if not (ofs <= start && start <= stop) then
-              Code_error.raise "Invalid text subsitution"
-                [ ("ofs", Dyn.Encoder.int ofs)
-                ; ("start", Dyn.Encoder.int start)
-                ; ("stop", Dyn.Encoder.int stop)
-                ; ("repl", Dyn.Encoder.string repl)
-                ];
-            Buffer.add_substring buf s ofs (start - ofs);
-            Buffer.add_string buf repl;
-            stop)
-      in
-      Buffer.add_substring buf s ofs (String.length s - ofs);
-      let s' = Buffer.contents buf in
-      if s <> s' then todo.to_edit <- (fn, s') :: todo.to_edit
-    )
-
-  let upgrade todo dir =
-    let lang_version = (1, 0) in
-    Dune_project.default_dune_language_version := lang_version;
-    let project = Source_tree.Dir.project dir in
-    let project_root = Dune_project.root project in
-    if project_root = Source_tree.Dir.path dir then (
-      ensure_project_file_exists project ~lang_version;
-      Package.Name.Map.iter (Dune_project.packages project) ~f:(fun pkg ->
-          let fn = Package.opam_file pkg in
-          if Path.exists (Path.source fn) then upgrade_opam_file todo fn)
-    );
-    if
-      String.Set.mem
-        (Source_tree.Dir.files dir)
-        Source_tree.Dune_file.jbuild_fname
-    then
-      let fn =
-        Path.Source.relative (Source_tree.Dir.path dir)
-          Source_tree.Dune_file.jbuild_fname
-      in
-      if Io.with_lexbuf_from_file (Path.source fn) ~f:Dune_lexer.is_script then
-        User_warning.emit
-          ~loc:(Loc.in_file (Path.source fn))
-          [ Pp.text
-              "Cannot upgrade this jbuild file as it is using the OCaml syntax."
-          ; Pp.text "You need to upgrade it manually."
-          ]
-      else
-        let files = scan_included_files fn ~lexer:Jbuild_support.Lexer.token in
-        Path.Source.Map.iteri files ~f:(fun fn' (sexps, comments) ->
-            upgrade_file todo fn' sexps comments
-              ~look_for_jbuild_ignore:(Path.Source.equal fn fn'))
-end
-
 module V2 = struct
   open Common
 
@@ -661,9 +316,16 @@ end
 let detect_project_version project dir =
   let in_tree = String.Set.mem (Source_tree.Dir.files dir) in
   Dune_project.default_dune_language_version := (0, 1);
-  if in_tree Source_tree.Dune_file.jbuild_fname then
-    Jbuild_project
-  else
+  if in_tree "jbuild" then (
+    let fn = Path.relative (Path.source (Source_tree.Dir.path dir)) "jbuild" in
+    User_warning.emit ~loc:(Loc.in_file fn)
+      [ Pp.text
+          "Since Dune 3.0.0 it is no longer possible to upgrade jbuilder \
+           projects. You need to use an older version of Dune to upgrade this \
+           project."
+      ];
+    Unknown
+  ) else
     let project_dune_version = Dune_project.dune_version project in
     let open Dune_lang.Syntax.Version.Infix in
     if project_dune_version >= (2, 0) then
@@ -673,7 +335,7 @@ let detect_project_version project dir =
     else if in_tree Source_tree.Dune_file.fname then
       Dune1_project
     else
-      Jbuild_project
+      Unknown
 
 let upgrade () =
   let open Fiber.O in
@@ -704,10 +366,7 @@ let upgrade () =
     List.iter current_versions ~f:(fun (dir, version) ->
         let d = Path.Source.to_string_maybe_quoted (Source_tree.Dir.path dir) in
         match version with
-        | Jbuild_project ->
-          log_update d "v1";
-          v1_updates := true;
-          V1.upgrade todo dir
+        | Unknown -> ()
         | Dune1_project ->
           log_update d "v2";
           v2_updates := true;
diff --git a/test/blackbox-tests/test-cases/embed-jbuild.t/a-dune-proj/a-dune-proj.opam b/test/blackbox-tests/test-cases/embed-jbuild.t/a-dune-proj/a-dune-proj.opam
deleted file mode 100644
index e69de29bb2d..00000000000
diff --git a/test/blackbox-tests/test-cases/embed-jbuild.t/a-dune-proj/dune b/test/blackbox-tests/test-cases/embed-jbuild.t/a-dune-proj/dune
deleted file mode 100644
index 8b6b59d6819..00000000000
--- a/test/blackbox-tests/test-cases/embed-jbuild.t/a-dune-proj/dune
+++ /dev/null
@@ -1,5 +0,0 @@
-(rule
- (targets version.ml)
-  (action
-   (with-stdout-to %{targets}
-    (echo "let version = \"%{version:a-dune-proj}\""))))
diff --git a/test/blackbox-tests/test-cases/embed-jbuild.t/a-dune-proj/dune-project b/test/blackbox-tests/test-cases/embed-jbuild.t/a-dune-proj/dune-project
deleted file mode 100644
index 1fe55753add..00000000000
--- a/test/blackbox-tests/test-cases/embed-jbuild.t/a-dune-proj/dune-project
+++ /dev/null
@@ -1,2 +0,0 @@
-(lang dune 1.0)
-(name a-dune-proj)
diff --git a/test/blackbox-tests/test-cases/embed-jbuild.t/a-jbuild-proj/a-jbuild-proj.opam b/test/blackbox-tests/test-cases/embed-jbuild.t/a-jbuild-proj/a-jbuild-proj.opam
deleted file mode 100644
index e69de29bb2d..00000000000
diff --git a/test/blackbox-tests/test-cases/embed-jbuild.t/a-jbuild-proj/jbuild b/test/blackbox-tests/test-cases/embed-jbuild.t/a-jbuild-proj/jbuild
deleted file mode 100644
index 1e88faa8269..00000000000
--- a/test/blackbox-tests/test-cases/embed-jbuild.t/a-jbuild-proj/jbuild
+++ /dev/null
@@ -1,7 +0,0 @@
-(jbuild_version 1)
-
-(rule
- ((targets (version.ml))
-  (action
-   (with-stdout-to ${@}
-    (echo "let version = \"${version:a-jbuild-proj}\"")))))
diff --git a/test/blackbox-tests/test-cases/embed-jbuild.t/run.t b/test/blackbox-tests/test-cases/embed-jbuild.t/run.t
deleted file mode 100644
index 0fd806629c9..00000000000
--- a/test/blackbox-tests/test-cases/embed-jbuild.t/run.t
+++ /dev/null
@@ -1,29 +0,0 @@
-Generating a version.ml from a jbuild/dune project should work either with the
-immediate project, or as part of an embedded build in a subdirectory.
-
-  $ (cd a-dune-proj && dune build version.ml --root=.)
-
-Now lets try with a jbuild project in the subdirectory:
-
-  $ (cd a-jbuild-proj && dune build version.ml --root=.)
-  File "jbuild", line 1, characters 0-0:
-  Error: jbuild files are no longer supported, please convert this file to a
-  dune file instead.
-  Note: You can use "dune upgrade" to convert your project to dune.
-  [1]
-
-Now lets try it from the current directory:
-
-  $ dune build a-dune-proj/version.ml --root=.
-  File "a-jbuild-proj/jbuild", line 1, characters 0-0:
-  Error: jbuild files are no longer supported, please convert this file to a
-  dune file instead.
-  Note: You can use "dune upgrade" to convert your project to dune.
-  [1]
-  $ dune build a-jbuild-proj/version.ml --root=.
-  File "a-jbuild-proj/jbuild", line 1, characters 0-0:
-  Error: jbuild files are no longer supported, please convert this file to a
-  dune file instead.
-  Note: You can use "dune upgrade" to convert your project to dune.
-  [1]
-
diff --git a/test/blackbox-tests/test-cases/fallback-dune.t/jbuild/jbuild b/test/blackbox-tests/test-cases/fallback-dune.t/jbuild/jbuild
deleted file mode 100644
index 9792612aa71..00000000000
--- a/test/blackbox-tests/test-cases/fallback-dune.t/jbuild/jbuild
+++ /dev/null
@@ -1,5 +0,0 @@
-
-(rule
- ((fallback)
-  (targets (foo.txt))
-  (action (with-stdout-to foo.txt (echo "testing")))))
diff --git a/test/blackbox-tests/test-cases/syntax-versioning.t/run.t b/test/blackbox-tests/test-cases/syntax-versioning.t/run.t
index e5d22582099..3fa138f55b3 100644
--- a/test/blackbox-tests/test-cases/syntax-versioning.t/run.t
+++ b/test/blackbox-tests/test-cases/syntax-versioning.t/run.t
@@ -9,13 +9,10 @@
   [1]
   $ rm -f dune
 
-  $ echo '(jbuild_version 1)' > jbuild
+Since 3.0.0, jbuild files are plain ignored:
+
+  $ echo 'random stuff' > jbuild
   $ dune build
-  File "jbuild", line 1, characters 0-0:
-  Error: jbuild files are no longer supported, please convert this file to a
-  dune file instead.
-  Note: You can use "dune upgrade" to convert your project to dune.
-  [1]
   $ rm -f jbuild
 
   $ echo '(executable (name x) (link_executables false))' > dune
diff --git a/test/blackbox-tests/test-cases/upgrader.t/jbuild b/test/blackbox-tests/test-cases/upgrader.t/jbuild
deleted file mode 100644
index 54d32c3dfb7..00000000000
--- a/test/blackbox-tests/test-cases/upgrader.t/jbuild
+++ /dev/null
@@ -1,20 +0,0 @@
-#|old style
-block comment
-|#
-
-(rule
- ((deps (x y z)) ; abc
-  (targets (z))
-  ; def
-  (action (with-stdout-to z (run echo ${<})))
-  (fallback)))
-
-; other
-; comment
-
-(rule (copy x y))
-
-#; (sexp
-    comment)
-
-(include jbuild.inc)
diff --git a/test/blackbox-tests/test-cases/upgrader.t/jbuild.inc b/test/blackbox-tests/test-cases/upgrader.t/jbuild.inc
deleted file mode 100644
index a971a523c26..00000000000
--- a/test/blackbox-tests/test-cases/upgrader.t/jbuild.inc
+++ /dev/null
@@ -1,4 +0,0 @@
-(rule
- ((deps (a))
-  (targets (b))
-  (action (copy ${<} ${@}))))
diff --git a/test/blackbox-tests/test-cases/upgrader.t/run.t b/test/blackbox-tests/test-cases/upgrader.t/run.t
index 1c6285ffd56..448deb69efd 100644
--- a/test/blackbox-tests/test-cases/upgrader.t/run.t
+++ b/test/blackbox-tests/test-cases/upgrader.t/run.t
@@ -65,32 +65,13 @@
   > (using fmt 1.2 (enabled_for reason))
   > EOF
 
-  $ cat > foo.opam <<EOF
-  > build: [
-  >   ["jbuilder" "subst" "-p" name]
-  >   ["jbuilder" "build"]
-  > ]
-  > depends: [
-  >   "jbuilder" {build & >= "1.0+beta42"}
-  > ]
-  > EOF
-
   $ dune upgrade
-  Project in dir . will be upgraded to dune v1.
-  Creating dune-project...
   Project in dir partv2/partv1 will be upgraded to dune v2.
   Project in dir partv2/partv1bis will be upgraded to dune v2.
   Upgrading partv2/partv1bis/dune-project...
   Upgrading partv2/partv1/dune.inc...
   Upgrading partv2/partv1/dune...
   Upgrading partv2/partv1/dune-project...
-  Upgrading foo.opam...
-  Upgrading jbuild.inc to dune.inc...
-  Upgrading jbuild to dune...
-  Project in dir . will be upgraded to dune v2.
-  Upgrading dune.inc...
-  Upgrading dune...
-  Upgrading dune-project...
   
   Some projects were upgraded to dune v2. Some breaking changes may not
   have been treated automatically. Here is a list of things you should check
@@ -126,53 +107,6 @@
   - `self_build_stubs_archive` was deleted in version 2.0 of the dune
   language. Use the (foreign_archives ...) field instead.
 
-  $ cat dune
-  ;old style
-  ;block comment
-  ;
-  
-  (rule
-   (deps
-    (:< x)
-    y
-    z)
-   ; abc
-   (targets z)
-   ; def
-   (action
-    (with-stdout-to
-     z
-     (run echo %{<})))
-   (mode fallback))
-  
-  ; other
-  ; comment
-  
-  (rule
-   (copy x y))
-  
-  ;(sexp
-  ;    comment)
-  
-  (include dune.inc)
-
-  $ cat dune.inc
-  (rule
-   (deps
-    (:< a))
-   (targets b)
-   (action
-    (copy %{<} %{targets})))
-
-  $ cat foo.opam
-  build: [
-    ["dune" "subst"]
-    ["dune" "build" "-p" name "-j" jobs]
-  ]
-  depends: [
-    "dune" {build & >= "1.0"}
-  ]
-
 v1 -> v2
 
   $ cat partv2/partv1/dune-project
diff --git a/test/expect-tests/dune_lang/dune b/test/expect-tests/dune_lang/dune
index 0cb14b7d519..124bd5622cc 100644
--- a/test/expect-tests/dune_lang/dune
+++ b/test/expect-tests/dune_lang/dune
@@ -5,7 +5,6 @@
   dune_tests_common
   stdune
   dune_lang
-  jbuild_support
   ;; This is because of the (implicit_transitive_deps false)
   ;; in dune-project
   ppx_expect.config
diff --git a/test/expect-tests/dune_lang/sexp_tests.ml b/test/expect-tests/dune_lang/sexp_tests.ml
index 80739bd915c..f89e35386b9 100644
--- a/test/expect-tests/dune_lang/sexp_tests.ml
+++ b/test/expect-tests/dune_lang/sexp_tests.ml
@@ -45,202 +45,154 @@ let%expect_test _ =
 [ 1; 2 ]
 |}]
 
-type 'res parse_result_diff =
-  { jbuild : ('res, string) result
-  ; dune : ('res, string) result
-  }
-
-let dyn_of_parse_result_diff f { jbuild; dune } =
-  let open Dyn.Encoder in
-  record
-    [ ("jbuild", Result.to_dyn f string jbuild)
-    ; ("dune", Result.to_dyn f string dune)
-    ]
-
-type 'res parse_result =
-  | Same of ('res, string) result
-  | Different of 'res parse_result_diff
-
-let dyn_of_parse_result f =
-  let open Dyn.Encoder in
-  function
-  | Same r -> constr "Same" [ Result.to_dyn f string r ]
-  | Different r -> constr "Different" [ dyn_of_parse_result_diff f r ]
-
 let string_of_user_error (msg : User_message.t) =
   Format.asprintf "%a" Pp.to_fmt (User_message.pp { msg with loc = None })
   |> String.drop_prefix ~prefix:"Error: "
   |> Option.value_exn |> String.trim
 
 let parse s =
-  let f ~lexer =
+  let res =
     try
       Ok
-        (Dune_lang.Parser.parse_string ~fname:"" ~mode:Many ~lexer s
+        (Dune_lang.Parser.parse_string ~fname:"" ~mode:Many s
         |> List.map ~f:Dune_lang.Ast.remove_locs)
     with
     | User_error.E msg -> Error (string_of_user_error msg)
     | e -> Error (Printexc.to_string e)
   in
-  let jbuild = f ~lexer:Jbuild_support.Lexer.token in
-  let dune = f ~lexer:Dune_lang.Lexer.token in
-  let res =
-    if jbuild <> dune then
-      Different { jbuild; dune }
-    else
-      Same jbuild
-  in
-  dyn_of_parse_result (Dyn.Encoder.list Dune_lang.to_dyn) res |> print_dyn
+  print_dyn
+    (Result.to_dyn (Dyn.Encoder.list Dune_lang.to_dyn) Dyn.Encoder.string res)
 
 let%expect_test _ =
   parse {| # ## x##y x||y a#b|c#d copy# |};
   [%expect {|
-Same Ok [ "#"; "##"; "x##y"; "x||y"; "a#b|c#d"; "copy#" ]
+Ok [ "#"; "##"; "x##y"; "x||y"; "a#b|c#d"; "copy#" ]
 |}]
 
 let%expect_test _ =
   parse {|x #| comment |# y|};
-  [%expect
-    {|
-Different
-  { jbuild = Ok [ "x"; "y" ]; dune = Ok [ "x"; "#|"; "comment"; "|#"; "y" ] }
+  [%expect {|
+Ok [ "x"; "#|"; "comment"; "|#"; "y" ]
 |}]
 
 let%expect_test _ =
   parse {|x#|y|};
-  [%expect
-    {|
-Different
-  { jbuild = Error "jbuild atoms cannot contain #|"; dune = Ok [ "x#|y" ] }
+  [%expect {|
+Ok [ "x#|y" ]
 |}]
 
 let%expect_test _ =
   parse {|x|#y|};
-  [%expect
-    {|
-Different
-  { jbuild = Error "jbuild atoms cannot contain |#"; dune = Ok [ "x|#y" ] }
+  [%expect {|
+Ok [ "x|#y" ]
 |}]
 
 let%expect_test _ =
   parse {|"\a"|};
-  [%expect
-    {|
-Different { jbuild = Ok [ "\\a" ]; dune = Error "unknown escape sequence" }
+  [%expect {|
+Error "unknown escape sequence"
 |}]
 
 let%expect_test _ =
   parse {|"\%{x}"|};
   [%expect {|
-Different { jbuild = Ok [ "\\%{x}" ]; dune = Ok [ "%{x}" ] }
+Ok [ "%{x}" ]
 |}]
 
 let%expect_test _ =
   parse {|"$foo"|};
   [%expect {|
-Same Ok [ "$foo" ]
+Ok [ "$foo" ]
 |}]
 
 let%expect_test _ =
   parse {|"%foo"|};
   [%expect {|
-Same Ok [ "%foo" ]
+Ok [ "%foo" ]
 |}]
 
 let%expect_test _ =
   parse {|"bar%foo"|};
   [%expect {|
-Same Ok [ "bar%foo" ]
+Ok [ "bar%foo" ]
 |}]
 
 let%expect_test _ =
   parse {|"bar$foo"|};
   [%expect {|
-Same Ok [ "bar$foo" ]
+Ok [ "bar$foo" ]
 |}]
 
 let%expect_test _ =
   parse {|"%bar$foo%"|};
   [%expect {|
-Same Ok [ "%bar$foo%" ]
+Ok [ "%bar$foo%" ]
 |}]
 
 let%expect_test _ =
   parse {|"$bar%foo%"|};
   [%expect {|
-Same Ok [ "$bar%foo%" ]
+Ok [ "$bar%foo%" ]
 |}]
 
 let%expect_test _ =
   parse {|\${foo}|};
   [%expect {|
-Same Ok [ "\\${foo}" ]
+Ok [ "\\${foo}" ]
 |}]
 
 let%expect_test _ =
   parse {|\%{foo}|};
-  [%expect
-    {|
-Different { jbuild = Ok [ "\\%{foo}" ]; dune = Ok [ template "\\%{foo}" ] }
+  [%expect {|
+Ok [ template "\\%{foo}" ]
 |}]
 
 let%expect_test _ =
   parse {|\$bar%foo%|};
   [%expect {|
-Same Ok [ "\\$bar%foo%" ]
+Ok [ "\\$bar%foo%" ]
 |}]
 
 let%expect_test _ =
   parse {|\$bar\%foo%|};
   [%expect {|
-Same Ok [ "\\$bar\\%foo%" ]
+Ok [ "\\$bar\\%foo%" ]
 |}]
 
 let%expect_test _ =
   parse {|\$bar\%foo%{bar}|};
-  [%expect
-    {|
-Different
-  { jbuild = Ok [ "\\$bar\\%foo%{bar}" ]
-  ; dune = Ok [ template "\\$bar\\%foo%{bar}" ]
-  }
+  [%expect {|
+Ok [ template "\\$bar\\%foo%{bar}" ]
 |}]
 
 let%expect_test _ =
   parse {|"bar%{foo}"|};
-  [%expect
-    {|
-Different
-  { jbuild = Ok [ "bar%{foo}" ]; dune = Ok [ template "\"bar%{foo}\"" ] }
+  [%expect {|
+Ok [ template "\"bar%{foo}\"" ]
 |}]
 
 let%expect_test _ =
   parse {|"bar\%{foo}"|};
-  [%expect
-    {|
-Different { jbuild = Ok [ "bar\\%{foo}" ]; dune = Ok [ "bar%{foo}" ] }
+  [%expect {|
+Ok [ "bar%{foo}" ]
 |}]
 
 let%expect_test _ =
   parse {|bar%{foo}|};
-  [%expect
-    {|
-Different { jbuild = Ok [ "bar%{foo}" ]; dune = Ok [ template "bar%{foo}" ] }
+  [%expect {|
+Ok [ template "bar%{foo}" ]
 |}]
 
 let%expect_test _ =
   parse {|"bar%{foo}"|};
-  [%expect
-    {|
-Different
-  { jbuild = Ok [ "bar%{foo}" ]; dune = Ok [ template "\"bar%{foo}\"" ] }
+  [%expect {|
+Ok [ template "\"bar%{foo}\"" ]
 |}]
 
 let%expect_test _ =
   parse {|"bar\%foo"|};
-  [%expect
-    {|
-Different { jbuild = Ok [ "bar\\%foo" ]; dune = Ok [ "bar%foo" ] }
+  [%expect {|
+Ok [ "bar%foo" ]
 |}]
 
 (* Printing tests *)
@@ -295,13 +247,7 @@ let test syntax sexp =
     , let s =
         Format.asprintf "%a" (fun ppf x -> Pp.to_fmt ppf (Dune_lang.pp x)) sexp
       in
-      match
-        Dune_lang.Parser.parse_string s ~mode:Single ~fname:""
-          ~lexer:
-            (match syntax with
-            | Jbuild -> Jbuild_support.Lexer.token
-            | Dune -> Dune_lang.Lexer.token)
-      with
+      match Dune_lang.Parser.parse_string s ~mode:Single ~fname:"" with
       | sexp' ->
         let sexp' = Dune_lang.Ast.remove_locs sexp' in
         if sexp = sexp' then
@@ -401,22 +347,3 @@ comment)
 block
 comment|#
 |}
-
-let%expect_test _ =
-  Dune_lang.Parser.parse ~lexer:Jbuild_support.Lexer.token ~mode:Cst
-    (Lexing.from_string jbuild_file)
-  |> List.map
-       ~f:(Dune_lang.Cst.fetch_legacy_comments ~file_contents:jbuild_file)
-  |> Dyn.Encoder.list Dune_lang.Cst.to_dyn
-  |> print_dyn;
-  [%expect
-    {|
-[ Atom A "hello"
-; Comment Lines [ " comment" ]
-; Atom A "world"
-; Comment Lines [ " multiline"; " comment" ]
-; List [ Atom A "x"; Comment Lines [ " comment inside list" ]; Atom A "y" ]
-; Comment Lines [ "(sexp"; "comment)" ]
-; Comment Lines [ "old style"; "block"; "comment" ]
-]
-|}]
diff --git a/test/unit-tests/dune b/test/unit-tests/dune
index bc5e636851a..1dec6a89221 100644
--- a/test/unit-tests/dune
+++ b/test/unit-tests/dune
@@ -1,7 +1,7 @@
 (executable
  (name sexp_tests)
  (modules sexp_tests)
- (libraries stdune dune_lang jbuild_support))
+ (libraries stdune dune_lang))
 
 (rule
  (alias runtest)
diff --git a/test/unit-tests/sexp_tests.ml b/test/unit-tests/sexp_tests.ml
index b1169072804..d3fd3810553 100644
--- a/test/unit-tests/sexp_tests.ml
+++ b/test/unit-tests/sexp_tests.ml
@@ -3,63 +3,49 @@ open! Stdune
 let () = Printexc.record_backtrace true
 
 (* Test that all strings of length <= 3 such that [Dune_lang.Atom.is_valid s]
-   are recignized as atoms by the parser *)
+   are recognized as atoms by the parser *)
 
 type syntax =
   | Dune
   | Jbuild
 
-let string_of_syntax = function
-  | Dune -> "dune"
-  | Jbuild -> "jbuild"
-
 let () =
-  [ (Dune, Dune_lang.Lexer.token, fun s -> Dune_lang.Atom.is_valid s)
-  ; (Jbuild, Jbuild_support.Lexer.token, fun s -> Jbuild_support.Atom.is_valid s)
-  ]
-  |> List.iter ~f:(fun (syntax, lexer, validator) ->
-         for len = 0 to 3 do
-           let s = Bytes.create len in
-           for i = 0 to (1 lsl (len * 8)) - 1 do
-             if len > 0 then Bytes.set s 0 (Char.chr (i land 0xff));
-             if len > 1 then Bytes.set s 1 (Char.chr ((i lsr 4) land 0xff));
-             if len > 2 then Bytes.set s 2 (Char.chr ((i lsr 8) land 0xff));
-             let s = Bytes.unsafe_to_string s in
-             let parser_recognizes_as_atom =
-               match
-                 Dune_lang.Parser.parse_string ~lexer ~fname:"" ~mode:Single s
-               with
-               | exception _ -> false
-               | Atom (_, A s') -> s = s'
-               | _ -> false
-             in
-             let printed_as_atom =
-               match Dune_lang.atom_or_quoted_string s with
-               | Atom _ -> true
-               | _ -> false
-             in
-             let valid_dune_atom = validator s in
-             if valid_dune_atom <> parser_recognizes_as_atom then (
-               Printf.eprintf
-                 "Dune_lang.Atom.is_valid error:\n\
-                  - syntax = %s\n\
-                  - s = %S\n\
-                  - Dune_lang.Atom.is_valid s = %B\n\
-                  - parser_recognizes_as_atom = %B\n"
-                 (string_of_syntax syntax) s valid_dune_atom
-                 parser_recognizes_as_atom;
-               exit 1
-             );
-             if printed_as_atom && not parser_recognizes_as_atom then (
-               Printf.eprintf
-                 "Dune_lang.Atom.atom_or_quoted_string error:\n\
-                  - syntax = %s\n\
-                  - s = %S\n\
-                  - printed_as_atom = %B\n\
-                  - parser_recognizes_as_atom = %B\n"
-                 (string_of_syntax syntax) s printed_as_atom
-                 parser_recognizes_as_atom;
-               exit 1
-             )
-           done
-         done)
+  for len = 0 to 3 do
+    let s = Bytes.create len in
+    for i = 0 to (1 lsl (len * 8)) - 1 do
+      if len > 0 then Bytes.set s 0 (Char.chr (i land 0xff));
+      if len > 1 then Bytes.set s 1 (Char.chr ((i lsr 4) land 0xff));
+      if len > 2 then Bytes.set s 2 (Char.chr ((i lsr 8) land 0xff));
+      let s = Bytes.unsafe_to_string s in
+      let parser_recognizes_as_atom =
+        match Dune_lang.Parser.parse_string ~fname:"" ~mode:Single s with
+        | exception _ -> false
+        | Atom (_, A s') -> s = s'
+        | _ -> false
+      in
+      let printed_as_atom =
+        match Dune_lang.atom_or_quoted_string s with
+        | Atom _ -> true
+        | _ -> false
+      in
+      let valid_dune_atom = Dune_lang.Atom.is_valid s in
+      if valid_dune_atom <> parser_recognizes_as_atom then (
+        Printf.eprintf
+          "Dune_lang.Atom.is_valid error:\n\
+           - s = %S\n\
+           - Dune_lang.Atom.is_valid s = %B\n\
+           - parser_recognizes_as_atom = %B\n"
+          s valid_dune_atom parser_recognizes_as_atom;
+        exit 1
+      );
+      if printed_as_atom && not parser_recognizes_as_atom then (
+        Printf.eprintf
+          "Dune_lang.Atom.atom_or_quoted_string error:\n\
+           - s = %S\n\
+           - printed_as_atom = %B\n\
+           - parser_recognizes_as_atom = %B\n"
+          s printed_as_atom parser_recognizes_as_atom;
+        exit 1
+      )
+    done
+  done