So it turns out that ARGV has global scope. This is completely fine 99% of the time, but when you’re trying to do something funky this can bite you in the ass. Here’s an example of what made me scratch my head. Script I want to run:

puts 'arguments passed in:'
ARGV.each do |arg|
  puts arg
end

puts "\\ndoing require\\n"

require 'arg_fucker'

puts 'arguments after require:'
ARGV.each do |arg|
  puts arg
end

… and here’s arg_fucker.rb:

ARGV.delete_at(0)

When I run this script, as you’d probably expect, the first element of ARGV gets deleted:

>ruby test_runner.rb a b c d
arguments passed in:
a
b
c
d

doing require
arguments after require:
b
c
d

This behavior is fine, unless you’re someone like me who is trying to make modules into runnable scripts where the first argument is the method to be run. And you’re including one module inside another. <shoots-self/>