{"action":"opened","issue":{"url":"https://api.github.com/repos/rebar/rebar3/issues/107","labels_url":"https://api.github.com/repos/rebar/rebar3/issues/107/labels{/name}","comments_url":"https://api.github.com/repos/rebar/rebar3/issues/107/comments","events_url":"https://api.github.com/repos/rebar/rebar3/issues/107/events","html_url":"https://github.com/rebar/rebar3/issues/107","id":54972470,"number":107,"title":"Duplicate lock entries","user":{"login":"ferd","id":111141,"avatar_url":"https://avatars.githubusercontent.com/u/111141?v=3","gravatar_id":"","url":"https://api.github.com/users/ferd","html_url":"https://github.com/ferd","followers_url":"https://api.github.com/users/ferd/followers","following_url":"https://api.github.com/users/ferd/following{/other_user}","gists_url":"https://api.github.com/users/ferd/gists{/gist_id}","starred_url":"https://api.github.com/users/ferd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ferd/subscriptions","organizations_url":"https://api.github.com/users/ferd/orgs","repos_url":"https://api.github.com/users/ferd/repos","events_url":"https://api.github.com/users/ferd/events{/privacy}","received_events_url":"https://api.github.com/users/ferd/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/rebar/rebar3/labels/bug","name":"bug","color":"fc2929"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-01-21T03:14:26Z","updated_at":"2015-01-21T03:14:26Z","closed_at":null,"body":"Running `rebar3 do lock, lock` will leave duplicate lock entries in the lock file.\r\n\r\nI haven't tested it (because I'm working on something else and don't know where to add tests yet), but this patch should resolve it, in `rebar_prv_install_deps:maybe_lock`:\r\n\r\n```erlang\r\n\r\nmaybe_lock(Profile, AppInfo, Seen, State, Level) ->\r\n    Name = rebar_app_info:name(AppInfo),\r\n    case Profile of\r\n        default ->\r\n            case sets:is_element(Name, Seen) of\r\n                false ->\r\n                    AppName = rebar_app_info:name(AppInfo),\r\n                    Locks = rebar_state:lock(State),\r\n                    case lists:any(fun(App) -> rebar_app_info:name(AppInfo) =:= AppName end,Locks) of\r\n                        true ->  {sets:add_element(Name, Seen), State};\r\n                        false -> {sets:add_element(Name, Seen),\r\n                                  rebar_state:lock(State, rebar_app_info:dep_level(AppInfo, Level))}\r\n                    end;\r\n                true ->\r\n                    {Seen, State}\r\n            end;\r\n        _ ->\r\n            {Seen, State}\r\n    end.\r\n```"}}