Fix build script to copy dependencies into lib before building gems