You might need to set GEM_HOME
for the cleanup to work. You can check what paths exist for gemfiles by running:
gem env
Take note of the GEM PATHS section.
In my case, for example, with gems installed in my user home:
export GEM_HOME="~/.gem/ruby/2.4.0"
gem cleanup