From: Mike Stok Date: 2013-06-23T07:56:19+09:00 Subject: Re: Load error - Std lib class Dir On 2013-06-22, at 1:19 PM, Love U Ruby wrote: > Mike Stok wrote in post #1113281: > > >> The #! line (shebang line) specifies which interpreter to use. So a >> script starting with >> >> #!/usr/bin/ruby >> >> would always use the /usr/bin/ruby interpreter to run the script. > > Good explanation.. > > So suppose I am having Ruby 1.9.3-p374, Ruby2.0.0-p0 are installed. Now > is the line `#!/usr/bin/ruby` would also be able to the desired version > as I want ? If no then how can I run the same script with different > version of Ruby(s)? > > Thanks as always!! > Using rbenv: ratdog:tmp mike$ ls -l try.rb -rwxr-xr-x 1 mike mike 71 22 Jun 14:02 try.rb ratdog:tmp mike$ cat try.rb #!/usr/bin/env ruby puts "I'm running under #{RUBY_VERSION}" __END__ ratdog:tmp mike$ rbenv version 2.0.0-p195 (set by /Users/mike/.rbenv/version) ratdog:tmp mike$ ./try.rb I'm running under 2.0.0 ratdog:tmp mike$ rbenv shell 1.9.3-p429 ratdog:tmp mike$ rbenv version 1.9.3-p429 (set by RBENV_VERSION environment variable) ratdog:tmp mike$ ./try.rb I'm running under 1.9.3 So the same script runs under different interpreters depending on which version I have set to execute using rbenv. Hope this helps, Mike -- Mike Stok http://www.stok.ca/~mike/ The "`Stok' disclaimers" apply.