3

How can I always run Ruby scripts with warnings turned on by default, by modifying my Unix or Windows environment variables?

Ideally this should work even when I'm running a script indirectly such as through Rake, not just when I'm running it directly.

Based on a comment in this answer.

Community
  • 1
  • 1
Andrew Grimm
  • 78,473
  • 57
  • 200
  • 338

1 Answers1

11

The RUBYOPT environment variable defines default options like warnings, etc.

Unix/OS X/etc:

export RUBYOPT=-w

You can put this in your startup script in Unix so it's set for new shells.

Windows:

set RUBYOPT=-w

Use the system properties dialog to set it for new shells/command windows.

Dave Newton
  • 158,873
  • 26
  • 254
  • 302