In the case of parallel gem installation, this could be called from multiple threads or child processes. This isn't thread-safe, and in the case of child processes, it won't work at all. Try running `bundle install -j 2` and see what happens: you might get incorrect counts on some runs.