Skip to content

Commit

Permalink
Really fix the weird uninstall problem
Browse files Browse the repository at this point in the history
I've finally nailed down issue ocaml#348 (and ocaml#362). The issue was indeed caused by da0d7de:
* This commit is implementing an useful optimization: in case the remove command is 'ocamlfind remove XXX' only, then OPAM don't create ~/.opam/<switch>/build/<pkg> anymore. Which means increased uninstall time.
* However, the uninstall command was still run in ~/.opam/<switch>/build/<pkg>. If that directory does not exists, the command was just dropped silently.
* OPAM automatically removes ~/.opam/<switch>/lib/<pkg>, so when the package was not using C bindings (with stub files in ~/.opam/<switch>/lib/stublibs) the bug was hidden
* Using OPAM with OPAMKEEPBUILDIR=1 (which means that the build dir wasn't removed during upgrades) hides the bug

So now I've fixed the bug:
* when we do an exec in a given dir, OPAM fails if the dir doesn't exist
* on uninstall, if the build dir is not there run the uninstall command at the OPAM root

This should fix ocaml#362
  • Loading branch information
samoht committed Jan 6, 2013
1 parent ff1c080 commit c1296fd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions src/client/opamSolution.ml
Original file line number Diff line number Diff line change
Expand Up @@ -256,14 +256,18 @@ let proceed_to_delete ~rm_build t nv =
&& OpamState.mem_repository t nv
&& not (List.for_all use_ocamlfind remove) then (
try extract_package t nv
with _ -> OpamFilename.mkdir p_build;
with _ -> ()
);
let exec_dir =
if OpamFilename.exists_dir p_build
then p_build
else t.root in
try
OpamGlobals.msg "%s\n" (string_of_commands remove);
OpamFilename.exec
~add_to_env:env.add_to_env
~add_to_path:[OpamPath.Switch.bin t.root t.switch]
p_build
exec_dir
remove
with _ ->
();
Expand Down
2 changes: 1 addition & 1 deletion src/core/opamFilename.ml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ let in_dir dirname fn =
OpamGlobals.error_and_exit "%s does not exist!" dirname

let exec dirname ?(add_to_env=[]) ?(add_to_path=[]) cmds =
OpamSystem.in_dir (Dir.to_string dirname)
in_dir dirname
(fun () ->
OpamSystem.commands
~add_to_env
Expand Down

0 comments on commit c1296fd

Please sign in to comment.