# RUBYOPT -S RuntimeError

**URL:** <https://rubytalk.org/t/rubyopt-s-runtimeerror/68141>\
**Category:** ruby-talk\
**Created:** [4 July 2013 21:21 UTC](https://rubytalk.org/t/rubyopt-s-runtimeerror/68141 "2013-07-04T21:21:27Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![7stud2](https://avatars.discourse-cdn.com/v4/letter/7/9de053/32.png) [@7stud2](https://rubytalk.org/u/7stud2)\
**Post date:** [4 July 2013 21:21 UTC](https://rubytalk.org/t/rubyopt-s-runtimeerror/68141/1 "2013-07-04T21:21:27Z")

</div>

I'm confused.

On Windows7, Ruby 1.9.3

I do : ruby -S script.rb  
and it works correctly, and searches the PATH variable

However, if I do :  
set RUBYOPT=-S  
ruby script.rb  
=\>ruby: invalid switch in RUBYOPT: -S (RuntimeError)

What am I missing ?

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

---

<div class="post-metadata">

**Author:** ![7stud2](https://avatars.discourse-cdn.com/v4/letter/7/9de053/32.png) [@7stud2](https://rubytalk.org/u/7stud2)\
**Post date:** [4 July 2013 21:32 UTC](https://rubytalk.org/t/rubyopt-s-runtimeerror/68141/2 "2013-07-04T21:32:59Z")

</div>

Same behaviour on 1.8.6 on HPUX.

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

---

<div class="post-metadata">

**Author:** ![Tamara\_Temple1](https://avatars.discourse-cdn.com/v4/letter/t/5f9b8f/32.png) [@Tamara\_Temple1](https://rubytalk.org/u/Tamara_Temple1)\
**Post date:** [5 July 2013 00:57 UTC](https://rubytalk.org/t/rubyopt-s-runtimeerror/68141/3 "2013-07-05T00:57:16Z")

</div>

So, in ruby's man page, I see the following:

RUBYOPT Additional Ruby options.

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;e.g.  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;RUBYOPT="-w -Ke"

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Note that RUBYOPT can contain only -d, -E, -I, -K, -r, -T, -U, -v, -w, -W, --debug,  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;--disable-FEATURE and --enable-FEATURE.

It doesn't look as though RUBYOPT works with -S

> **···**
>
> On Jul 4, 2013, at 4:21 PM, Tadeusz Bochan \<lists@ruby-forum.com\> wrote:
> 
> > I'm confused.
> > 
> > On Windows7, Ruby 1.9.3
> > 
> > I do : ruby -S script.rb  
> > and it works correctly, and searches the PATH variable
> > 
> > However, if I do :  
> > set RUBYOPT=-S  
> > ruby script.rb  
> > =\>ruby: invalid switch in RUBYOPT: -S (RuntimeError)
> > 
> > What am I missing ?
> > 
> > --  
> > Posted via [http://www.ruby-forum.com/\](http://www.ruby-forum.com/%5C).

---

<div class="post-metadata">

**Author:** ![7stud2](https://avatars.discourse-cdn.com/v4/letter/7/9de053/32.png) [@7stud2](https://rubytalk.org/u/7stud2)\
**Post date:** [5 July 2013 13:42 UTC](https://rubytalk.org/t/rubyopt-s-runtimeerror/68141/4 "2013-07-05T13:42:12Z")

</div>

Thanks for that.  
I managed to find that reference when I googled for an updated version  
of the man pages. It was difficult to find unless you included "man  
page" in the search.

In the Programming Ruby book, it only says that option -S (among others)  
is not allowed if $SAFE \>= 1

I guess that it makes sense not to have -S in a variable.

Regards

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
