Julian Wigley said almost 6 years ago on Ruby on Rails 5.1.0 Changes and New Features :

I get an error when I used that ...

The source must be an absolute URI. For example: (ArgumentError) source 'https://rubygems.org'

Ended up with

ruby -rbundler/inline -e "gemfile(true) do; source 'https://rubygems.org/'; gem 'rails', '5.1.0.beta1'; end"

There seems to be a a rubygems issue with installing pre release versions of gems