Ruby Magic Comments

There are two special ways to setup Ruby settings at the very top of a file.

Shebang

An interpreter directive mostly used on CLI programs, and scripts.

#!/usr/bin/env ruby -E UTF-8:UTF-8 --enable-frozen-string-literal

Option comments

These are expected at the very top of a file.

# -*- coding: utf-8 -*-
# -*- frozen_string_literal: true -*-

Find out more about ruby encodings.