# How to ignore warning

**URL:** <https://www.ruby-forum.com/t/how-to-ignore-warning/116918>\
**Category:** Ruby\
**Created:** [October 11, 2007, 5:08am UTC](https://www.ruby-forum.com/t/how-to-ignore-warning/116918 "2007-10-11T05:08:31Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![mokkai](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/c2a13f/32.png) [@mokkai](https://www.ruby-forum.com/u/mokkai)\
**Post date:** [October 11, 2007, 5:08am UTC](https://www.ruby-forum.com/t/how-to-ignore-warning/116918/1 "2007-10-11T05:08:31Z")

</div>

how to ignore warning messages in ruby (when executing ruby code)

---

<div class="post-metadata">

**Author:** ![mokkai](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/c2a13f/32.png) [@mokkai](https://www.ruby-forum.com/u/mokkai)\
**Post date:** [October 11, 2007, 5:28am UTC](https://www.ruby-forum.com/t/how-to-ignore-warning/116918/2 "2007-10-11T05:28:17Z")

</div>

Quoth Pokkai D.:

> how to ignore warning messages in ruby (when executing ruby code)

Close your eyes and tap your heels thrice.  
No, really, ignoring things is as easy as not looking at them. (In all  
likelihood you should fix your code to not have warnings instead.)

Regards,

---

<div class="post-metadata">

**Author:** ![mokkai](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/c2a13f/32.png) [@mokkai](https://www.ruby-forum.com/u/mokkai)\
**Post date:** [October 11, 2007, 5:49am UTC](https://www.ruby-forum.com/t/how-to-ignore-warning/116918/3 "2007-10-11T05:49:22Z")

</div>

On 11 Oct 2007, at 12:26, Konrad M. wrote:

> Quoth Pokkai D.:
> 
> > how to ignore warning messages in ruby (when executing ruby code)
> 
> Close your eyes and tap your heels thrice.  
> No, really, ignoring things is as easy as not looking at them. (In all  
> likelihood you should fix your code to not have warnings instead.)

I agree with Konrad that you should probably fix warnings rather than  
ignore, but -W is the command line flag you want. -W1 is standard, -  
W2 is verbose, -W0 is no warnings whatsoever.

Alex G.

Bioinformatics Center  
Kyoto University

---

<div class="post-metadata">

**Author:** ![mokkai](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/c2a13f/32.png) [@mokkai](https://www.ruby-forum.com/u/mokkai)\
**Post date:** [October 11, 2007, 6:28am UTC](https://www.ruby-forum.com/t/how-to-ignore-warning/116918/4 "2007-10-11T06:28:58Z")

</div>

Alex G. wrote:

> I agree with Konrad that you should probably fix warnings rather than  
> ignore, but -W is the command line flag you want. -W1 is standard, -  
> W2 is verbose, -W0 is no warnings whatsoever.
> 
> Alex G.
> 
> Bioinformatics Center  
> Kyoto University

thank you Alex

---

<div class="post-metadata">

**Author:** ![mokkai](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/c2a13f/32.png) [@mokkai](https://www.ruby-forum.com/u/mokkai)\
**Post date:** [October 11, 2007, 12:25pm UTC](https://www.ruby-forum.com/t/how-to-ignore-warning/116918/5 "2007-10-11T12:25:54Z")

</div>

Hi,

Am Donnerstag, 11. Okt 2007, 12:48:22 +0900 schrieb Alex G.:

> -W1 is standard, -W2 is  
> verbose, -W0 is no warnings whatsoever.

Or set one of the variables $-v, $-w, $VERBOSE to ‘nil’.

Option $-v  
-W0 nil  
-W1 false  
-W2 true

Bertram

---

<div class="post-metadata">

**Author:** ![mokkai](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/c2a13f/32.png) [@mokkai](https://www.ruby-forum.com/u/mokkai)\
**Post date:** [October 11, 2007, 12:22pm UTC](https://www.ruby-forum.com/t/how-to-ignore-warning/116918/6 "2007-10-11T12:22:28Z")

</div>

Alex G. wrote:

> -W is the command line flag you want. -W1 is standard, -  
> W2 is verbose, -W0 is no warnings whatsoever.

Is there a possibility to ignore warnings dynamically? - I mean,  
sometimes it’s helpful to redefine constants, which will always produce  
a warning. I want to suppress warnings for these lines only.

Wolfgang NÃ¡dasi-Donner

---

<div class="post-metadata">

**Author:** ![mokkai](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/c2a13f/32.png) [@mokkai](https://www.ruby-forum.com/u/mokkai)\
**Post date:** [October 11, 2007, 2:55pm UTC](https://www.ruby-forum.com/t/how-to-ignore-warning/116918/7 "2007-10-11T14:55:21Z")

</div>

Bertram S. wrote:

> irb(main):001:0\> X = “x”  
> =\> “x”  
> irb(main):002:0\> class Object ; remove\_const :X ; end  
> =\> “x”  
> irb(main):003:0\> X  
> NameError: uninitialized constant X  
> from (irb):3  
> irb(main):004:0\> X = “y”  
> =\> “y”  
> irb(main):005:0\>

Well - it looks fine, because it’s no dirty trick.

Wolfgang NÃ¡dasi-Donner

---

<div class="post-metadata">

**Author:** ![mokkai](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/c2a13f/32.png) [@mokkai](https://www.ruby-forum.com/u/mokkai)\
**Post date:** [October 11, 2007, 1:52pm UTC](https://www.ruby-forum.com/t/how-to-ignore-warning/116918/8 "2007-10-11T13:52:22Z")

</div>

Hi,

Am Donnerstag, 11. Okt 2007, 19:22:31 +0900 schrieb Wolfgang  
Nádasi-Donner:

> Alex G. wrote:
> 
> > -W is the command line flag you want. -W1 is standard, -  
> > W2 is verbose, -W0 is no warnings whatsoever.
> 
> Is there a possibility to ignore warnings dynamically? - I mean,  
> sometimes it’s helpful to redefine constants, which will always produce  
> a warning. I want to suppress warnings for these lines only.

irb(main):001:0\> X = “x”  
=\> “x”  
irb(main):002:0\> class Object ; remove\_const :X ; end  
=\> “x”  
irb(main):003:0\> X  
NameError: uninitialized constant X  
from (irb):3  
irb(main):004:0\> X = “y”  
=\> “y”  
irb(main):005:0\>

Bertram

---

<div class="post-metadata">

**Author:** ![mokkai](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/c2a13f/32.png) [@mokkai](https://www.ruby-forum.com/u/mokkai)\
**Post date:** [October 11, 2007, 3:06pm UTC](https://www.ruby-forum.com/t/how-to-ignore-warning/116918/9 "2007-10-11T15:06:57Z")

</div>

On 10/10/07, Konrad M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Quoth Pokkai D.:
> 
> > how to ignore warning messages in ruby (when executing ruby code)
> 
> Close your eyes and tap your heels thrice.  
> No, really, ignoring things is as easy as not looking at them.

Or cover your head with your towel, rubyists should ALWAYS have their  
towel handy.

## And as the Hitchhiker’s Guide to Ruby explains this is also the best defense against being eaten by the ravenous bugblatter beast of Traal!

Rick DeNatale

My blog on Ruby  
[http://talklikeaduck.denhaven2.com/](http://talklikeaduck.denhaven2.com/)

---

<div class="post-metadata">

**Author:** ![mokkai](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/c2a13f/32.png) [@mokkai](https://www.ruby-forum.com/u/mokkai)\
**Post date:** [October 16, 2007, 2:08pm UTC](https://www.ruby-forum.com/t/how-to-ignore-warning/116918/10 "2007-10-16T14:08:42Z")

</div>

Bertram S. wrote:

> irb(main):001:0\> X = “x”  
> =\> “x”  
> irb(main):002:0\> class Object ; remove\_const :X ; end  
> =\> “x”  
> irb(main):003:0\> X  
> NameError: uninitialized constant X  
> from (irb):3  
> irb(main):004:0\> X = “y”  
> =\> “y”  
> irb(main):005:0\>

Yuck.

I’ve pushed for structured warnings in the past, but it has fallen on  
deaf ears.

See:

> **[OSDIR](https://osdir.com)**
>
> edit post Gaming How To Check If US iGaming Platform is Safe July 13, 2021 edit post Gaming What made

> **[OSDIR](https://osdir.com)**
>
> edit post Gaming How To Check If US iGaming Platform is Safe July 13, 2021 edit post Gaming What made

[http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/50105](http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/50105)

Regards,

Dan

---

<div class="post-metadata">

**Author:** ![mokkai](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/c2a13f/32.png) [@mokkai](https://www.ruby-forum.com/u/mokkai)\
**Post date:** [November 19, 2009, 10:37pm UTC](https://www.ruby-forum.com/t/how-to-ignore-warning/116918/11 "2009-11-19T22:37:35Z")

</div>

Konrad M. wrote:

> Quoth Pokkai D.:
> 
> > how to ignore warning messages in ruby (when executing ruby code)
> 
> Close your eyes and tap your heels thrice.  
> No, really, ignoring things is as easy as not looking at them. (In all  
> likelihood you should fix your code to not have warnings instead.)
> 
> Regards,

Ruby will spit out warnings for white space - with no coding errors,

and many programming languages output warnings for using anything but  
the most basic techniques

so weather you’re a novice or a seasoned veteran there are valid reasons  
to suppress warnings: after all, it does have W levels

---

<div class="post-metadata">

**Author:** ![mokkai](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/c2a13f/32.png) [@mokkai](https://www.ruby-forum.com/u/mokkai)\
**Post date:** [October 16, 2007, 2:57pm UTC](https://www.ruby-forum.com/t/how-to-ignore-warning/116918/12 "2007-10-16T14:57:53Z")

</div>

Rick Denatale wrote:

> Or cover your head with your towel, rubyists should ALWAYS have their  
> towel handy.
> 
> ## And as the Hitchhiker’s Guide to Ruby explains this is also the best defense against being eaten by the ravenous bugblatter beast of Traal!
> 
> Rick DeNatale
> 
> My blog on Ruby  
> [http://talklikeaduck.denhaven2.com/](http://talklikeaduck.denhaven2.com/)

likin’ it 🙂
