In order to test locally a Gemfile, define local path for the gems to avoid attempting to write to system-wide folders:

bundle config set --local path '/home/username/.gem'
bundle install