# Simple, simple stuff

**URL:** <https://rubytalk.org/t/simple-simple-stuff/68887>\
**Category:** ruby-talk\
**Created:** [17 December 2013 17:12 UTC](https://rubytalk.org/t/simple-simple-stuff/68887 "2013-12-17T17:12:28Z")\
**Posts on this page:** 12\
**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:** [17 December 2013 17:12 UTC](https://rubytalk.org/t/simple-simple-stuff/68887/1 "2013-12-17T17:12:28Z")

</div>

Hello,  
I just rebuilt my Mac, with Ruby. I'm getting these what I think are  
very primitive errors when I try to run one of my scripts locally.

pb4072imac:~ peterbailey$ checkorca dy3242g1  
/scripts/checkorca.rb: line 2: require: command not found  
/scripts/checkorca.rb: line 4: require: command not found  
/scripts/checkorca.rb: line 6: orcafile: command not found  
host: couldn't get address for '[http://ps2000-graphics-prod.bna.com](http://ps2000-graphics-prod.bna.com)':  
not found  
/scripts/checkorca.rb: line 10: clnt: command not found  
/scripts/checkorca.rb: line 11: syntax error near unexpected token  
`nil,'  
/scripts/checkorca.rb: line 11: `clnt.set\_auth(nil, 'production',  
'prod')'

What is it complaining about "require?" Yeh, I've got "require" there at  
the top. But, I need it there.  
And, why can't it find the address of that URL?

Thanks,  
Peter

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

---

<div class="post-metadata">

**Author:** ![Jesus\_Gabriel\_y\_Gala](https://avatars.discourse-cdn.com/v4/letter/j/96bed5/32.png) [@Jesus\_Gabriel\_y\_Gala](https://rubytalk.org/u/Jesus_Gabriel_y_Gala)\
**Post date:** [17 December 2013 17:16 UTC](https://rubytalk.org/t/simple-simple-stuff/68887/2 "2013-12-17T17:16:30Z")

</div>

Hi,

I don't work with a Mac, so take this with a grain of salt: it looks  
like instead of running the script with the Ruby interpreter you are  
running it as if it were a shell script, hence all the "command not  
found" errors, cause the shell can't find those commands. Do you have  
an appropriate shebang line (not sure how that would look like in a  
Mac):

something like:

#!/bin/env ruby

Otherwise you could try calling ruby directly:

$ ruby checkorca.rb dy3242g1

Jesus.

> **···**
>
> On Tue, Dec 17, 2013 at 6:12 PM, Peter Bailey \<lists@ruby-forum.com\> wrote:
> 
> > Hello,  
> > I just rebuilt my Mac, with Ruby. I'm getting these what I think are  
> > very primitive errors when I try to run one of my scripts locally.
> > 
> > pb4072imac:~ peterbailey$ checkorca dy3242g1  
> > /scripts/checkorca.rb: line 2: require: command not found  
> > /scripts/checkorca.rb: line 4: require: command not found  
> > /scripts/checkorca.rb: line 6: orcafile: command not found  
> > host: couldn't get address for '[http://ps2000-graphics-prod.bna.com](http://ps2000-graphics-prod.bna.com)':  
> > not found  
> > /scripts/checkorca.rb: line 10: clnt: command not found  
> > /scripts/checkorca.rb: line 11: syntax error near unexpected token  
> > `nil,'  
> > /scripts/checkorca.rb: line 11: `clnt.set\_auth(nil, 'production',  
> > 'prod')'
> > 
> > What is it complaining about "require?" Yeh, I've got "require" there at  
> > the top. But, I need it there.  
> > And, why can't it find the address of that URL?

---

<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:** [17 December 2013 19:23 UTC](https://rubytalk.org/t/simple-simple-stuff/68887/3 "2013-12-17T19:23:10Z")

</div>

Do you need the 'bang' - ! - in your shebang?

#!/ vs. #/

(I use Windows.)

> **···**
>
> --  
> 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:** [17 December 2013 17:22 UTC](https://rubytalk.org/t/simple-simple-stuff/68887/4 "2013-12-17T17:22:53Z")

</div>

"Jesús Gabriel y Galán" \<jgabrielygalan@gmail.com\> wrote in post  
#1130870:

> **···**
>
> > On Tue, Dec 17, 2013 at 6:12 PM, Peter Bailey \<lists@ruby-forum.com\> \> wrote:
> > 
> > > /scripts/checkorca.rb: line 10: clnt: command not found  
> > > /scripts/checkorca.rb: line 11: syntax error near unexpected token  
> > > `nil,'  
> > > /scripts/checkorca.rb: line 11: `clnt.set\_auth(nil, 'production',  
> > > 'prod')'
> > > 
> > > What is it complaining about "require?" Yeh, I've got "require" there at  
> > > the top. But, I need it there.  
> > > And, why can't it find the address of that URL?
> > 
> > Hi,
> > 
> > I don't work with a Mac, so take this with a grain of salt: it looks  
> > like instead of running the script with the Ruby interpreter you are  
> > running it as if it were a shell script, hence all the "command not  
> > found" errors, cause the shell can't find those commands. Do you have  
> > an appropriate shebang line (not sure how that would look like in a  
> > Mac):
> > 
> > something like:
> > 
> > #!/bin/env ruby
> > 
> > Otherwise you could try calling ruby directly:
> > 
> > $ ruby checkorca.rb dy3242g1
> > 
> > Jesus.
> 
> Thanks, Jesus. I checked my script and I do have the shebang there.  
> Thanks, anyway.
> 
> --  
> 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:** [17 December 2013 20:22 UTC](https://rubytalk.org/t/simple-simple-stuff/68887/5 "2013-12-17T20:22:29Z")

</div>

Jacob V. wrote in post #1130886:

> Do you need the 'bang' - ! - in your shebang?
> 
> #!/ vs. #/
> 
> (I use Windows.)

I tried it with the screamer (!), but, I still get the same results.

If I run the script like this in my Mac shell, I'm alright.

&nbsp;&nbsp;ruby checkorca.rb dy3242g1

Normally, I run it like this:

&nbsp;&nbsp;&nbsp;checkorca dy3242g1

because, I have a simple script in my scripts directory called  
"checkorca" that simply calls out the Ruby script.

If I run this, it doesn't run either.

&nbsp;&nbsp;checkorca.rb dy3242g1

It's like there's some disconnect with Ruby itself, or, at least, the  
Ruby version I'm running. I used rbenv to install my Ruby.

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

---

<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:** [17 December 2013 18:44 UTC](https://rubytalk.org/t/simple-simple-stuff/68887/6 "2013-12-17T18:44:55Z")

</div>

It might help if you pasted the script.

> **···**
>
> On Tue, Dec 17, 2013 at 11:22 AM, Peter Bailey \<lists@ruby-forum.com\> wrote:
> 
> > "Jesús Gabriel y Galán" \<jgabrielygalan@gmail.com\> wrote in post  
> > #1130870:  
> > \> On Tue, Dec 17, 2013 at 6:12 PM, Peter Bailey \<lists@ruby-forum.com\> \> \> wrote:  
> > \>\> /scripts/checkorca.rb: line 10: clnt: command not found  
> > \>\> /scripts/checkorca.rb: line 11: syntax error near unexpected token  
> > \>\> `nil,'  
> > \>\> /scripts/checkorca.rb: line 11: `clnt.set\_auth(nil, 'production',  
> > \>\> 'prod')'  
> > \>\>  
> > \>\> What is it complaining about "require?" Yeh, I've got "require" there at  
> > \>\> the top. But, I need it there.  
> > \>\> And, why can't it find the address of that URL?  
> > \>  
> > \> Hi,  
> > \>  
> > \> I don't work with a Mac, so take this with a grain of salt: it looks  
> > \> like instead of running the script with the Ruby interpreter you are  
> > \> running it as if it were a shell script, hence all the "command not  
> > \> found" errors, cause the shell can't find those commands. Do you have  
> > \> an appropriate shebang line (not sure how that would look like in a  
> > \> Mac):  
> > \>  
> > \> something like:  
> > \>  
> > \> #!/bin/env ruby  
> > \>  
> > \> Otherwise you could try calling ruby directly:  
> > \>  
> > \> $ ruby checkorca.rb dy3242g1  
> > \>  
> > \> Jesus.
> > 
> > Thanks, Jesus. I checked my script and I do have the shebang there.  
> > Thanks, anyway.
> > 
> > --  
> > 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:** [17 December 2013 18:58 UTC](https://rubytalk.org/t/simple-simple-stuff/68887/7 "2013-12-17T18:58:23Z")

</div>

tamouse m. wrote in post #1130882:

> > \>\> What is it complaining about "require?" Yeh, I've got "require" there at  
> > \> Mac):
> > 
> > Thanks, Jesus. I checked my script and I do have the shebang there.  
> > Thanks, anyway.
> > 
> > --  
> > Posted via [http://www.ruby-forum.com/\](http://www.ruby-forum.com/%5C).
> 
> It might help if you pasted the script.

Uh, it's pretty big. But, here it is. Thanks.

#/Users/peterbailey/.rbenv/shims/ruby  
require 'rubygems'  
#noinspection RubyResolve  
require 'httpclient'

orcafile = ARGV[0]

host = '[http://ps2000-graphics-prod.bna.com](http://ps2000-graphics-prod.bna.com)'  
#noinspection RubyResolve  
clnt = HTTPClient.new  
clnt.set\_auth(nil, 'production', 'prod')

#Find PNG on Orca  
format = 'png'  
url = URI.parse("#{host}/images/view/#{format}/#{orcafile}")  
pngfile = orcafile + '.png'  
&nbsp;&nbsp;response = clnt.head(url)  
#noinspection RubyResolve  
if HTTP::Status.successful?(response.status)  
&nbsp;&nbsp;&nbsp;&nbsp;puts "#{pngfile} is on Orca.\n"  
&nbsp;&nbsp;else  
&nbsp;&nbsp;&nbsp;&nbsp;puts "#{pngfile} is NOT on Orca.\n"  
&nbsp;&nbsp;end

#Find PDF on Orca  
format = 'pdf'  
url = URI.parse("#{host}/images/view/#{format}/#{orcafile}")  
pdffile = orcafile + '.pdf'  
&nbsp;&nbsp;response = clnt.head(url)  
#noinspection RubyResolve  
if HTTP::Status.successful?(response.status)  
&nbsp;&nbsp;&nbsp;&nbsp;puts "#{pdffile} is on Orca.\n"  
&nbsp;&nbsp;else  
&nbsp;&nbsp;&nbsp;&nbsp;puts "#{pdffile} is NOT on Orca.\n"  
&nbsp;&nbsp;end

#Find TIFF on Orca  
format = 'tiff'  
url = URI.parse("#{host}/images/view/#{format}/#{orcafile}")  
tifffile = orcafile + '.tif'  
&nbsp;&nbsp;response = clnt.head(url)  
#noinspection RubyResolve  
if HTTP::Status.successful?(response.status)  
&nbsp;&nbsp;&nbsp;&nbsp;puts "#{tifffile} is on Orca.\n"  
&nbsp;&nbsp;else  
&nbsp;&nbsp;&nbsp;&nbsp;puts "#{tifffile} is NOT on Orca.\n"  
&nbsp;&nbsp;end

#Find GIF on Orca  
format = 'gif'  
url = URI.parse("#{host}/images/view/#{format}/#{orcafile}")  
giffile = orcafile + '.gif'  
&nbsp;&nbsp;response = clnt.head(url)  
#noinspection RubyResolve  
if HTTP::Status.successful?(response.status)  
&nbsp;&nbsp;&nbsp;&nbsp;puts "#{giffile} is on Orca.\n"  
&nbsp;&nbsp;else  
&nbsp;&nbsp;&nbsp;&nbsp;puts "#{giffile} is NOT on Orca.\n"  
&nbsp;&nbsp;end

#Find EPS on Orca  
format = 'eps'  
url = URI.parse("#{host}/images/view/#{format}/#{orcafile}")  
epsfile = orcafile + '.eps'  
&nbsp;&nbsp;response = clnt.head(url)  
#noinspection RubyResolve  
if HTTP::Status.successful?(response.status)  
&nbsp;&nbsp;&nbsp;&nbsp;puts "#{epsfile} is on Orca.\n"  
&nbsp;&nbsp;else  
&nbsp;&nbsp;&nbsp;&nbsp;puts "#{epsfile} is NOT on Orca.\n"  
&nbsp;&nbsp;end

puts "\n"

#PS2000 Files  
orcafile = File.basename(orcafile, '.\*')

if orcafile.match(/^ehs-/)  
&nbsp;&nbsp;exit  
end

if File.exist?("/volumes/graphics/artrefpdf\_color/master/#{orcafile}")  
&nbsp;&nbsp;filetime =  
File.stat("/volumes/graphics/artrefpdf\_color/master/#{orcafile}").mtime  
&nbsp;&nbsp;filedirectory = '/volumes/graphics/artrefpdf\_color/master/'  
&nbsp;&nbsp;filetime = filetime.to\_s.gsub(/ -0[0-9]00/, '')  
&nbsp;&nbsp;puts "#{orcafile} is in the Color PS2k image library at:  
&nbsp;&nbsp;DIRECTORY #{filedirectory}\n DATED #{filetime}\n"  
end

> **···**
>
> > On Tue, Dec 17, 2013 at 11:22 AM, Peter Bailey \<lists@ruby-forum.com\> \> wrote:
> 
> #  
> #  
> if File.exist?("/volumes/graphics/images\_9/master/#{orcafile}")  
> &nbsp;&nbsp;filetime =  
> File.stat("/volumes/graphics/images\_9/master/#{orcafile}").mtime  
> &nbsp;&nbsp;filedirectory = '/volumes/graphics/images\_9/master/'  
> &nbsp;&nbsp;filetime = filetime.to\_s.gsub(/ -0[0-9]00/, '')  
> &nbsp;&nbsp;#noinspection RubyResolve,RubyResolve,RubyResolve  
> &nbsp;&nbsp;puts "#{orcafile} is in the regular PS2K image library at:  
> &nbsp;&nbsp;DIRECTORY #{filedirectory}\n DATED #{filetime}."  
> elsif File.exist?("/volumes/graphics/images\_8/master/#{orcafile}")  
> &nbsp;&nbsp;filetime =  
> File.stat("/volumes/graphics/images\_8/master/#{orcafile}").mtime  
> &nbsp;&nbsp;filedirectory = '/volumes/graphics/images\_8/master/'  
> &nbsp;&nbsp;filetime = filetime.to\_s.gsub(/ -0[0-9]00/, '')  
> &nbsp;&nbsp;puts "#{orcafile} is in the regular PS2K image library at:  
> DIRECTORY #{filedirectory}\n DATED #{filetime}\n"  
> elsif File.exist?("/volumes/graphics/images\_7/master/#{orcafile}")  
> &nbsp;&nbsp;filetime =  
> File.stat("/volumes/graphics/images\_7/master/#{orcafile}").mtime  
> &nbsp;&nbsp;filedirectory = '/volumes/graphics/images\_7/master/'  
> &nbsp;&nbsp;filetime = filetime.to\_s.gsub(/ -0[0-9]00/, '')  
> &nbsp;&nbsp;puts "#{orcafile} is in the regular PS2K image library at:  
> &nbsp;&nbsp;DIRECTORY #{filedirectory}\n DATED #{filetime}\n"  
> elsif File.exist?("/volumes/graphics/images\_6/master/#{orcafile}")  
> &nbsp;&nbsp;filetime =  
> File.stat("/volumes/graphics/images\_6/master/#{orcafile}").mtime  
> &nbsp;&nbsp;filedirectory = '/volumes/graphics/images\_6/master/'  
> &nbsp;&nbsp;filetime = filetime.to\_s.gsub(/ -0[0-9]00/, '')  
> &nbsp;&nbsp;puts "#{orcafile} is in the regular PS2K image library at:  
> &nbsp;&nbsp;DIRECTORY #{filedirectory}\n DATED #{filetime}\n"  
> elsif File.exist?("/volumes/graphics/images\_5/master/#{orcafile}")  
> &nbsp;&nbsp;filetime =  
> File.stat("/volumes/graphics/images\_5/master/#{orcafile}").mtime  
> &nbsp;&nbsp;filedirectory = '/volumes/graphics/images\_5/master/'  
> &nbsp;&nbsp;filetime = filetime.to\_s.gsub(/ -0[0-9]00/, '')  
> &nbsp;&nbsp;puts "#{orcafile} is in the regular PS2K image library at:  
> &nbsp;&nbsp;DIRECTORY #{filedirectory}\n DATED #{filetime}\n"  
> elsif File.exist?("/volumes/graphics/images\_4/master/#{orcafile}")  
> &nbsp;&nbsp;filetime =  
> File.stat("/volumes/graphics/images\_4/master/#{orcafile}").mtime  
> &nbsp;&nbsp;filedirectory = '/volumes/graphics/images\_4/master/'  
> &nbsp;&nbsp;filetime = filetime.to\_s.gsub(/ -0[0-9]00/, '')  
> &nbsp;&nbsp;puts "#{orcafile} is in the regular PS2K image library at:  
> &nbsp;&nbsp;DIRECTORY #{filedirectory}\n DATED #{filetime}\n"  
> elsif File.exist?("/volumes/graphics/images\_3/master/#{orcafile}")  
> &nbsp;&nbsp;filetime =  
> File.stat("/volumes/graphics/images\_3/master/#{orcafile}").mtime  
> &nbsp;&nbsp;filedirectory = '/volumes/graphics/images\_3/master/'  
> &nbsp;&nbsp;filetime = filetime.to\_s.gsub(/ -0[0-9]00/, '')  
> &nbsp;&nbsp;puts "#{orcafile} is in the regular PS2K image library at:  
> &nbsp;&nbsp;DIRECTORY #{filedirectory}\n DATED #{filetime}\n"  
> elsif File.exist?("/volumes/graphics/images\_2/master/#{orcafile}")  
> &nbsp;&nbsp;filetime =  
> File.stat("/volumes/graphics/images\_2/master/#{orcafile}").mtime  
> &nbsp;&nbsp;filedirectory = '/volumes/graphics/images\_2/master/'  
> &nbsp;&nbsp;filetime = filetime.to\_s.gsub(/ -0[0-9]00/, '')  
> &nbsp;&nbsp;puts "#{orcafile} is in the regular PS2K image library at:  
> &nbsp;&nbsp;DIRECTORY #{filedirectory}\n DATED #{filetime}\n"  
> elsif File.exist?("/volumes/graphics/images\_1/master/#{orcafile}")  
> &nbsp;&nbsp;filetime =  
> File.stat("/volumes/graphics/images\_1/master/#{orcafile}").mtime  
> &nbsp;&nbsp;filedirectory = '/volumes/graphics/images\_1/master/'  
> &nbsp;&nbsp;filetime = filetime.to\_s.gsub(/ -0[0-9]00/, '')  
> &nbsp;&nbsp;puts "#{orcafile} is in the regular PS2K image library at:  
> &nbsp;&nbsp;DIRECTORY #{filedirectory}\n DATED #{filetime}\n"  
> else  
> &nbsp;&nbsp;puts "The file is not in the ps2000 image library. It's probably for a  
> web-only service."  
> end
> 
> --  
> Posted via [http://www.ruby-forum.com/\](http://www.ruby-forum.com/%5C).

---

<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:** [18 December 2013 06:05 UTC](https://rubytalk.org/t/simple-simple-stuff/68887/8 "2013-12-18T06:05:23Z")

</div>

> tamouse m. wrote in post #1130882:  
> \>  
> \>\> \>\> What is it complaining about "require?" Yeh, I've got "require"  
> there at  
> \>\> \> Mac):  
> \>\>  
> \>\>  
> \>\> Thanks, Jesus. I checked my script and I do have the shebang there.  
> \>\> Thanks, anyway.  
> \>\>  
> \>\> --  
> \>\> Posted via [http://www.ruby-forum.com/\](http://www.ruby-forum.com/%5C).  
> \>\>  
> \>  
> \> It might help if you pasted the script.
> 
> Uh, it's pretty big. But, here it is. Thanks.

Thanks -- it's not \*that\* long, but I guess I could have asked for the head  
of the file instead... :))

> #/Users/peterbailey/.rbenv/shims/ruby

It should be:

#!/Users/peterbailey/.rbenv/shims/ruby

if you actually do have a shim for ruby at that exact path. Type that at  
the Terminal prompt to see.

This is what I use to start scripts:

#!/usr/bin/env ruby

and it picks up which ruby to run based upon the user's environment, which  
defaults to the system ruby.

> **···**
>
> On Tue, Dec 17, 2013 at 12:58 PM, Peter Bailey \<lists@ruby-forum.com\> wrote:
> 
> > \> On Tue, Dec 17, 2013 at 11:22 AM, Peter Bailey \<lists@ruby-forum.com\> \> \> wrote:

---

<div class="post-metadata">

**Author:** ![Hansem1](https://avatars.discourse-cdn.com/v4/letter/h/2bfe46/32.png) [@Hansem1](https://rubytalk.org/u/Hansem1)\
**Post date:** [18 December 2013 11:47 UTC](https://rubytalk.org/t/simple-simple-stuff/68887/9 "2013-12-18T11:47:01Z")

</div>

Are you pointing to the ruby directory or the executable, you need to  
point to the ruby executable?  
Should it maybe be:  
#!/Users/peterbailey/.rbenv/shims/ruby/bin/ruby

> From: tamouse pontiki \<tamouse.lists@gmail.com\>  
> To: ruby-talk ML \<ruby-talk@ruby-lang.org\>  
> Date: 12/18/2013 01:06 AM  
> Subject: Re: simple, simple stuff  
> Sent by: "ruby-talk" \<ruby-talk-bounces@ruby-lang.org\>
> 
> tamouse m. wrote in post #1130882:
> 
> > > \>\> What is it complaining about "require?" Yeh, I've got "require"

there at

> > > \> Mac):
> > > 
> > > Thanks, Jesus. I checked my script and I do have the shebang there.  
> > > Thanks, anyway.
> > > 
> > > --  
> > > Posted via [http://www.ruby-forum.com/\](http://www.ruby-forum.com/%5C).
> > 
> > It might help if you pasted the script.
> 
> Uh, it's pretty big. But, here it is. Thanks.
> 
> Thanks -- it's not \*that\* long, but I guess I could have asked for the

head of the file instead... :))

> #/Users/peterbailey/.rbenv/shims/ruby
> 
> It should be:
> 
> #!/Users/peterbailey/.rbenv/shims/ruby
> 
> if you actually do have a shim for ruby at that exact path. Type that at

the Terminal prompt to see.

> This is what I use to start scripts:
> 
> #!/usr/bin/env ruby
> 
> and it picks up which ruby to run based upon the user's environment,

which defaults to the system ruby.

> **···**
>
> > On Tue, Dec 17, 2013 at 12:58 PM, Peter Bailey \<lists@ruby-forum.com\> wrote:
> > 
> > > On Tue, Dec 17, 2013 at 11:22 AM, Peter Bailey \<lists@ruby-forum.com\> \>\> wrote:

---

<div class="post-metadata">

**Author:** ![Mike\_Stok1](https://yyz1.discourse-cdn.com/flex029/user_avatar/rubytalk.org/mike_stok1/32/2065_2.png) [@Mike\_Stok1](https://rubytalk.org/u/Mike_Stok1)\
**Post date:** [18 December 2013 12:30 UTC](https://rubytalk.org/t/simple-simple-stuff/68887/10 "2013-12-18T12:30:24Z")

</div>

> tamouse m. wrote in post #1130882:  
> \>  
> \>\> \>\> What is it complaining about "require?" Yeh, I've got "require" there at  
> \>\> \> Mac):  
> \>\>  
> \>\>  
> \>\> Thanks, Jesus. I checked my script and I do have the shebang there.  
> \>\> Thanks, anyway.  
> \>\>  
> \>\> --  
> \>\> Posted via [http://www.ruby-forum.com/\](http://www.ruby-forum.com/%5C).  
> \>\>  
> \>  
> \> It might help if you pasted the script.
> 
> Uh, it's pretty big. But, here it is. Thanks.
> 
> Thanks -- it's not \*that\* long, but I guess I could have asked for the head of the file instead... :))
> 
> #/Users/peterbailey/.rbenv/shims/ruby
> 
> It should be:
> 
> #!/Users/peterbailey/.rbenv/shims/ruby
> 
> if you actually do have a shim for ruby at that exact path. Type that at the Terminal prompt to see.

One way to determine which ruby a particular shell will pick up is to use the which command, for example:

ratdog:~ mike$ which ruby  
/Users/mike/.rbenv/shims/ruby

Is that the same as the interpreter specified in the #! line?

To see if the interpreter in your #! line exists, you can check by using ls, for example on my system I would do:

ratdog:~ mike$ ls -l /Users/mike/.rbenv/shims/ruby  
-rwxr-xr-x 7 mike 501 408 28 Oct 13:18 /Users/mike/.rbenv/shims/ruby

If it does exist then I would check that the script is executable, and that there are no invisible characters at the end of the #! line (usually this happens when a file comes from windows to a unix-like environment and what looks like ruby at the end of the line is really ruby\r)

One way to "repair" this might be to use

which ruby

then delete the top line of the file, enter #!, and then copy and paste the output of which ruby into the file.

In general I prefer #!/usr/bin/env ruby to hard coding a path because it lets me switch between rbenv and rvm and not have to update all my scripts — having the .rbenv/shims in there explicitly couples your script to the detail of how you currently install ruby.

Hope this helps,

Mike

> **···**
>
> On Dec 18, 2013, at 1:05 AM, tamouse pontiki \<tamouse.lists@gmail.com\> wrote:
> 
> > On Tue, Dec 17, 2013 at 12:58 PM, Peter Bailey \<lists@ruby-forum.com\> wrote:  
> > \> On Tue, Dec 17, 2013 at 11:22 AM, Peter Bailey \<lists@ruby-forum.com\> \> \> wrote:
> 
> > This is what I use to start scripts:
> > 
> > #!/usr/bin/env ruby
> > 
> > and it picks up which ruby to run based upon the user's environment, which defaults to the system ruby.
> 
> --
> 
> Mike Stok \<mike@stok.ca\>  
> [http://www.stok.ca/~mike/](http://www.stok.ca/~mike/)
> 
> The "`Stok' disclaimers" apply.

---

<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:** [19 December 2013 14:41 UTC](https://rubytalk.org/t/simple-simple-stuff/68887/11 "2013-12-19T14:41:14Z")

</div>

unknown wrote in post #1130962:

> Are you pointing to the ruby directory or the executable, you need to  
> point to the ruby executable?  
> Should it maybe be:  
> #!/Users/peterbailey/.rbenv/shims/ruby/bin/ruby
> 
> > From: tamouse pontiki \<tamouse.lists@gmail.com\>  
> > To: ruby-talk ML \<ruby-talk@ruby-lang.org\>  
> > Date: 12/18/2013 01:06 AM  
> > Subject: Re: simple, simple stuff  
> > Sent by: "ruby-talk" \<ruby-talk-bounces@ruby-lang.org\>
> > 
> > tamouse m. wrote in post #1130882:
> > 
> > > > \>\> What is it complaining about "require?" Yeh, I've got "require"
> 
> there at
> 
> > > It might help if you pasted the script.
> > 
> > Uh, it's pretty big. But, here it is. Thanks.
> > 
> > Thanks -- it's not \*that\* long, but I guess I could have asked for the
> 
> head of the file instead... :))
> 
> > #/Users/peterbailey/.rbenv/shims/ruby
> > 
> > It should be:
> > 
> > #!/Users/peterbailey/.rbenv/shims/ruby
> > 
> > if you actually do have a shim for ruby at that exact path. Type that at
> 
> the Terminal prompt to see.
> 
> > This is what I use to start scripts:
> > 
> > #!/usr/bin/env ruby
> > 
> > and it picks up which ruby to run based upon the user's environment,
> 
> which defaults to the system ruby.

My shebank looks just like you suggest:  
#!/Users/peterbailey/.rbenv/shims/ruby

If I were to use "#!/usr/bin/env ruby, would that still let me use the  
latest Ruby that's in /users/peterbailey/.rbenv/shims/ruby ??

If so, then, yeh, I'll do that.

Thanks!

> **···**
>
> > > On Tue, Dec 17, 2013 at 12:58 PM, Peter Bailey \<lists@ruby-forum.com\> \> wrote:
> > > 
> > > > On Tue, Dec 17, 2013 at 11:22 AM, Peter Bailey \<lists@ruby-forum.com\> \>\>\> wrote:
> 
> --  
> Posted via [http://www.ruby-forum.com/\](http://www.ruby-forum.com/%5C).

---

<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:** [21 December 2013 04:01 UTC](https://rubytalk.org/t/simple-simple-stuff/68887/12 "2013-12-21T04:01:00Z")

</div>

If what you have for your shebang matches exactly what you get when you  
type `which ruby` at the command line, that should work. If you want to try  
out the other, you can also type that exactly at the command line.

This is mine:

$ which ruby  
/opt/rubies/ruby-2.0.0-p247/bin/ruby

$ /opt/rubies/ruby-2.0.0-p247/bin/ruby --version  
ruby 2.0.0p247 (2013-06-27 revision 41674) [x86\_64-darwin12.5.0]

$ /usr/bin/env ruby --version  
ruby 2.0.0p247 (2013-06-27 revision 41674) [x86\_64-darwin12.5.0]  
I happen to be using chruby, but rbenv and rvm will work the same if it is  
set up correctly, as will the system ruby. Chruby sets and exports the  
following into the shell environment (which is what /usr/bin/env picks up  
for the shebang command):

GEM\_HOME=/Users/tamara/.gem/ruby/2.0.0  
GEM\_PATH=/Users/tamara/.gem/ruby/2.0.0:/opt/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0  
GEM\_ROOT=/opt/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0  
RUBYOPT=  
RUBY\_ENGINE=ruby  
RUBY\_ROOT=/opt/rubies/ruby-2.0.0-p247  
RUBY\_VERSION=2.0.0  
You should be able to find the same env vars with settings appropriate to  
your setup.

> **···**
>
> On Thu, Dec 19, 2013 at 8:41 AM, Peter Bailey \<lists@ruby-forum.com\> wrote:
> 
> > My shebank looks just like you suggest:  
> > #!/Users/peterbailey/.rbenv/shims/ruby
> > 
> > If I were to use "#!/usr/bin/env ruby, would that still let me use the  
> > latest Ruby that's in /users/peterbailey/.rbenv/shims/ruby ??
> > 
> > If so, then, yeh, I'll do that.
> > 
> > Thanks!
