Skip to content
understanding how to require Ruby 1.9
Find file
New pull request
Fetching latest commit...
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

Ruby Version Check

Is there any way for me to force a check for Ruby 1.9 in a file that I require so I get a good error message before the main file is parsed?

$ rvm use 1.9.2-head
Using ruby 1.9.2 head
$ ruby app.rb
with apple,butter,flour we can make a great pie
here is my app
$ rvm use 1.8.7
Using ruby 1.8.7 p249
$ ruby app.rb
app.rb:4: syntax error, unexpected tINTEGER, expecting tSTRING_CONTENT or tSTRING_DBEG or tSTRING_DVAR or tSTRING_END
make_pie apple:2, butter:1, flour:4

Here's a good blog post:

However the technique doesn't get a chance to work if there is a syntax error in the file in 1.8.x that works in 1.9

Something went wrong with that request. Please try again.