remove trailing slash from dir, that prevents passing as arg (this is a  workaround for a bug)