From: deepak Date: 2010-12-23T14:50:21+09:00 Subject: Re: debug flag being ignored hi, what does this output: require 'rbconfig' puts "topdir #{RbConfig::CONFIG['topdir']}" puts "RUBY_DESCRIPTION: #{RUBY_DESCRIPTION}" in both the cases, 1) ruby without the shebang 2) ./script.rb with the shebang after chmodding it also do you have multiple versions of ruby on your system. one managed by RVM and a system installed one on your path? cheers, deepak On Dec 21, 8:05 pm, Kedar Mhaswade wrote: > rickhg12hs wrote in post #131750: > > >> I'm trying to run 'ruby -d foo.rb' and the d is either ignored or I don't > >> understand how it works.  The code just runs as if there is no -d option. > > > "-d" sets $DEBUG to true. > > > Does your code execute something when $DEBUG is true? > > > For example: > > > puts "Important intermediate value: #{my_critical_var}" if $DEBUG > > I was going nuts over this. > This file: > #!/usr/bin/env ruby > puts $DEBUG > > prints false with or without ruby -d (e.g. ruby -d foo.rb) > > So, the shebang line comes in the way in an unpredictable manner. The > workaround is to have export RUBYOPT=-d $RUBYOPT if you wanted shebang > line (and the easier invocation like: ./foo.rb after chmoding it). > > If you are giving your file to the interpreter directly like: ruby > foo.rb (*and* you don't have shebang line in the file), then ruby -d > works as expected. > > Bottom line: For such a simple thing, shebang line complicates life > (unnecessarily) at least on Linux :( > > -- > Posted viahttp://www.ruby-forum.com/.