try catch for loading gems

Try:

begin   require "lib" rescue LoadError   logger.error "lib gem must be installed" end

Another solution is to put all your installed gems in your vendor directory.