You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When developing Overcommit locally, if you ran `overcommit --run` you
would encounter an issue where you would see a bunch of warnings
displayed related to already-initialized constants, e.g.
.../projects/overcommit/lib/overcommit/constants.rb:6:
warning: already initialized constant Overcommit::HOME
.../.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/overcommit-0.39.1/lib/overcommit/constants.rb:5:
warning: previous definition of HOME was here
This was ultimately caused by the fact that in the Gem specification
(`overcommit.gemspec`) we were modifying the `$LOAD_PATH` to include the
local repository's `lib` directory. This is problematic because if the
user had run `gem install overcommit` previously, that version of
Overcommit would already be in the `$LOAD_PATH`, e.g.
> $LOAD_PATH.grep(/overcommit/)
.../.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/overcommit-0.39.1/lib
.../projects/overcommit/lib
Notice that the local development directory under `projects` comes
_after_ the version of Overcommit installed via `gem install ...`.
A simple workaround is to not modify the `$LOAD_PATH` and to use
`require_relative` instead, thus loading the constants directly when
initializing the Gem specification.
0 commit comments