Ruby "Psych::BadAlias" / YAML Aliases Disabled in CI
Newer Psych (Ruby’s YAML library) loads YAML safely by default - it rejects aliases and arbitrary classes. Files or fixtures that rely on YAML anchors/aliases, or serialize objects, now raise unless you opt in.
What this error means
Loading a YAML file (a config, a fixture, a CI cache) fails with Psych::BadAlias "Unknown alias", or Psych::DisallowedClass "Tried to load unspecified class". The same YAML loaded on an older Ruby/Psych.
Psych::BadAlias: Unknown alias: default
from .../psych/visitors/to_ruby.rb:...
# or
Psych::DisallowedClass: Tried to load unspecified class: SymbolCommon causes
Aliases disabled by default in safe load
YAML.load (now safe_load under the hood) disables anchors/aliases unless aliases: true is passed. YAML using *alias references then raises Psych::BadAlias.
Non-permitted classes in the YAML
safe_load only allows a small set of core types. YAML that serializes Symbols, Dates, or custom objects raises Psych::DisallowedClass unless those classes are permitted.
How to fix it
Opt into aliases and permitted classes
Enable aliases and list the classes the file legitimately needs.
YAML.safe_load(File.read(path), aliases: true,
permitted_classes: [Symbol, Date, Time])
# trusted, non-user-supplied file only:
# YAML.unsafe_load(File.read(path))Or remove the aliases from the YAML
- For config you control, expand the anchored/aliased values inline so no alias is needed.
- Avoid serializing Symbols/objects into YAML that is loaded safely.
- Keep user-supplied YAML on safe_load with a minimal permitted set.
How to prevent it
- Load YAML with safe_load and explicit aliases/permitted_classes.
- Reserve unsafe_load for fully trusted, in-repo files.
- Avoid YAML anchors/aliases in files loaded safely.