From 54c966383bf412897c025e4de2e8ae3f7fea980a Mon Sep 17 00:00:00 2001 From: Raja Boujbel Date: Wed, 27 Jan 2021 16:19:13 +0100 Subject: [PATCH 1/3] Use opam var/env/exec instead of opam config x --- emacs/emacs.ml | 4 ++-- ousMisc.ml | 2 +- ousMisc.mli | 2 +- sublime/files/ocp-index/sublime_ocp_index.py | 2 +- test/ubuntu/Dockerfile | 2 +- vim/vim.ml | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/emacs/emacs.ml b/emacs/emacs.ml index 39d6e07..ac09a7b 100644 --- a/emacs/emacs.ml +++ b/emacs/emacs.ml @@ -152,7 +152,7 @@ let base_setup = (split-string (opam-shell-command-to-string "opam switch list -s --safe") "\n") nil t nil nil default)))) (let* ((switch-arg (if (= 0 (length switch)) "" (concat "--switch " switch))) - (command (concat "opam config env --safe --sexp " switch-arg)) + (command (concat "opam env --safe --sexp " switch-arg)) (env (opam-shell-command-to-string command))) (when (and env (not (string= env ""))) (dolist (var (car (read-from-string env))) @@ -163,7 +163,7 @@ let base_setup = (opam-update-env nil) (defvar opam-share - (let ((reply (opam-shell-command-to-string "opam config var share --safe"))) + (let ((reply (opam-shell-command-to-string "opam var share --safe"))) (when reply (substring reply 0 -1)))) (add-to-list 'load-path (concat opam-share "/emacs/site-lisp")) diff --git a/ousMisc.ml b/ousMisc.ml index ad2607c..6999085 100644 --- a/ousMisc.ml +++ b/ousMisc.ml @@ -53,7 +53,7 @@ let lines_to_file ?(remove_if_empty=false) lines f = close_out oc let opam_var v = - let cmd = Printf.sprintf "opam config var %s" v in + let cmd = Printf.sprintf "opam var %s" v in match lines_of_command cmd with | [value] -> value | _ -> failwith (Printf.sprintf "Bad answer from '%s'" cmd) diff --git a/ousMisc.mli b/ousMisc.mli index 2a82fcb..1e5642b 100644 --- a/ousMisc.mli +++ b/ousMisc.mli @@ -31,7 +31,7 @@ val lines_of_command: string -> lines (** Writes a list of lines to a file. [remove_if_empty] defaults to false. *) val lines_to_file: ?remove_if_empty:bool -> lines -> string -> unit -(** Query OPAM for a variable (see 'opam config list') *) +(** Query OPAM for a variable (see 'OPAMCLI=2.0 opam config list' or 'opam var --cli 2.1') *) val opam_var: string -> string (** The current user's home directory (as given by environment variable HOME) *) diff --git a/sublime/files/ocp-index/sublime_ocp_index.py b/sublime/files/ocp-index/sublime_ocp_index.py index bf4c63c..66fc399 100644 --- a/sublime/files/ocp-index/sublime_ocp_index.py +++ b/sublime/files/ocp-index/sublime_ocp_index.py @@ -33,7 +33,7 @@ class SublimeOCPIndex(): def run_ocp(self, command, includes, module, query, context, moreArgs, settings): bin_path = which('ocp-index') if bin_path is None: - opam_process = subprocess.Popen('opam config var bin', stdout=subprocess.PIPE, shell=True) + opam_process = subprocess.Popen('opam var bin', stdout=subprocess.PIPE, shell=True) bin_path = opam_process.stdout.read().decode('utf-8').rstrip() + '/ocp-index' args = [bin_path, command] diff --git a/test/ubuntu/Dockerfile b/test/ubuntu/Dockerfile index 8d21bb5..1a852f9 100644 --- a/test/ubuntu/Dockerfile +++ b/test/ubuntu/Dockerfile @@ -35,4 +35,4 @@ ENV OPAMVERBOSE 1 ENV OCAMLRUNPARAM b RUN opam pin add user-setup ous/ RUN opam user-setup install -RUN cd ous && opam config exec -- make +RUN cd ous && opam exec -- make diff --git a/vim/vim.ml b/vim/vim.ml index 032b109..bdd2f52 100644 --- a/vim/vim.ml +++ b/vim/vim.ml @@ -127,7 +127,7 @@ inoremap u let base_setup = [ dotvimrc, Text (lines_of_string {vim| -let s:opam_share_dir = system("opam config var share") +let s:opam_share_dir = system("opam var share") let s:opam_share_dir = substitute(s:opam_share_dir, '[\r\n]*$', '', '') let s:opam_configuration = {} From 926688364e4570c5de2b8b0c69b1f55225f712d6 Mon Sep 17 00:00:00 2001 From: Kate Date: Wed, 4 Sep 2024 16:00:00 +0100 Subject: [PATCH 2/3] Upgrade the opam file to the opam 2.0 format --- opam | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/opam b/opam index 082637a..01b4c55 100644 --- a/opam +++ b/opam @@ -1,4 +1,4 @@ -opam-version: "1.2" +opam-version: "2.0" name: "user-setup" version: "0.7" maintainer: "Louis Gesbert " @@ -6,17 +6,18 @@ authors: "Louis Gesbert " homepage: "https://github.com/OCamlPro/opam-user-setup" bug-reports: "https://github.com/OCamlPro/opam-user-setup/issues" license: "ISC" -dev-repo: "https://github.com/OCamlPro/opam-user-setup.git" +dev-repo: "git+https://github.com/OCamlPro/opam-user-setup.git" build: [make] depends: [ + "ocaml" {>= "3.12.1"} "ocamlfind" {build} "cmdliner" "re" ] depopts: ["tuareg" "merlin" "ocp-indent" "ocp-index"] -available: [ocaml-version >= "3.12.1"] post-messages: [ "To setup or update your editors, run 'opam user-setup install'." {success} ] -tags: [ "org:ocamlpro" "flags:plugin" ] +tags: [ "org:ocamlpro" ] +flags: plugin From bca56e72d1f97d45016591abb565dac572dee780 Mon Sep 17 00:00:00 2001 From: Kate Date: Wed, 4 Sep 2024 16:00:53 +0100 Subject: [PATCH 3/3] Require opam >= 2.1 to install opam-user-setup --- opam | 1 + 1 file changed, 1 insertion(+) diff --git a/opam b/opam index 01b4c55..93887e9 100644 --- a/opam +++ b/opam @@ -15,6 +15,7 @@ depends: [ "re" ] depopts: ["tuareg" "merlin" "ocp-indent" "ocp-index"] +available: opam-version >= "2.1" post-messages: [ "To setup or update your editors, run 'opam user-setup install'." {success}