Skip to content
Browse files

Really fix the weird uninstall problem

I've finally nailed down issue #348 (and #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 #362
  • Loading branch information...
1 parent ff1c080 commit c1296fd7d38fa08856e70ceee2389c7975494d94 @samoht samoht committed Jan 6, 2013
Showing with 7 additions and 3 deletions.
  1. +6 −2 src/client/
  2. +1 −1 src/core/
8 src/client/
@@ -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
OpamGlobals.msg "%s\n" (string_of_commands remove);
~add_to_path:[OpamPath.Switch.bin t.root t.switch]
- p_build
+ exec_dir
with _ ->
2 src/core/
@@ -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 () ->

0 comments on commit c1296fd

Please sign in to comment.
Something went wrong with that request. Please try again.