Error occurs when deploy to Github Release: You don't have write permissions for the /var/lib/gems/2.5.0 directory

It’s quite interesting that Linux ARM64 and AMD64 job in my .travis.yml does almost the same thing, but ARM64 always faces the problem about when it is about to install the tools to deploy to Github Release, while AMD64 is OK.

$ ruby -S gem install dpl
ERROR: While executing gem … (Gem::FilePermissionError)
You don’t have write permissions for the /var/lib/gems/2.5.0 directory.
The command “ruby -S gem install dpl” failed and exited with 1 during .

I have tried to make an attempt to add:

sudo: required
before_install: ‘sudo ruby -S gem install dpl’

to the ARM64 job, and it seems that the error can be avoid. However, when it continues to the deploy stage, ‘ruby -S gem install dpl’ will be executed automatically again by travis and this error occurs.

So in my opinion, this is due to the permission policy, but what can I do now? Will Travis CI fix this in the future?

Link of log: https://travis-ci.org/sinoxry/citest/jobs/609118160

I have found a similar issue:

Imprint