From: Richard Wilson Date: 2013-06-27T13:38:11+09:00 Subject: Re: #!/usr/bin/env: No such file or directory --047d7b86f6d25071c804e01b548c Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable as others suggested you can do the following: Link directly to your ruby executable: #!/usr/bin/ruby This line is called the shebang line, whenever your computer tries to read a script, this line tells the computer what program to run this script with. If you shebang to your ruby program directly, there is no issue. But if you share the code, or install ruby to a different directory later on, you have to change the line, some people might be using RVM, or have it installed in #!/usr/local/bin/ruby instead. So we use the ENV program to find the appropriate version of ruby in the PATH. #!/usr/bin/env ruby says use the ruby that is returned by the env program. this way ENV returns the ruby that is set for use in your systems path. This changes computer to computer, so it is the most standard way of writing the shebang line to make sure your code works on multiple machines. #!/usr/bin/env just dumps your entire environment. To see what I mean, type env in terminal and console. Then type env ruby and see what happens. Cheers, Richard On Wed, Jun 26, 2013 at 9:04 PM, Duong Quang Ha wro= te: > Hello, > > Shebang line should like "#! /usr/bin/env ruby" or "#! ruby VM i.e /usr/bin/ruby>". This line tell shell which program to > run. > > Regards, > > On Thu, Jun 27, 2013 at 10:58 AM, Todd Sterben > wrote: > > I am new to both linux and ruby. I am using Ubuntu and Ruby 1.9 > > > > When I do which ruby, I get /usr/bin/ruby > > When I do ruby -v I get ruby 1.9.3p0 (2011-10-30 revision 33570) > > [i686-linux] > > > > When I try to kick off a simple script > > > > =EF=BB=BF#!/usr/bin/env > > > > puts "Hello" > > > > I get > > > > ./test.rb: line 1: =EF=BB=BF#!/usr/bin/env: No such file or directory > > ./test.rb: line 4: puts: command not found > > > > > > Why? > > > > Thanks > > > > Todd > > > > -- > > Posted via http://www.ruby-forum.com/. > > > > -- > Duong Quang Ha (H=C3=A0 Quang D=C6=B0=C6=A1ng in Vietnamese) > blog.haqduong.com > > --=20 *Richard Wilson* Proteous Trading Group ph. - (604) 842 5318 Skype - r.crawfordwilson email - r.crawfordwilson@gmail.com =E2=80=9C*This email may contain confidential and/or privileged information= . If you are not the intended recipient or have received this email in error, please notify the sender immediately and destroy this email. Any unauthorized copying, disclosure or distribution of the information contained on this email is prohibited=E2=80=9D.* --047d7b86f6d25071c804e01b548c Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
as others suggested you can do the following:

Link = directly to your ruby executable:
#!/usr/bin/ruby

This line is called the shebang line, whenever your c= omputer tries to read a script, this line tells the computer what program t= o run this script with. If you shebang to your ruby program directly, there= is no issue. But if you share the code, or install ruby to a different dir= ectory later on, you have to change the line, some people might be using RV= M, or have it installed in #!/usr/local/bin/ruby instead. So we use the ENV= program to find the appropriate version of ruby in the PATH. #!/usr/bin/en= v ruby says use the ruby that is returned by the env program. this way ENV = returns the ruby that is set for use in your systems path. This changes com= puter to computer, so it is the most standard way of writing the shebang li= ne to make sure your code works on multiple machines. #!/usr/bin/env just d= umps your entire environment.

To see what I mean, type env in terminal an= d console. Then type env ruby and see what happens.

Cheers,

Richard


On Wed,= Jun 26, 2013 at 9:04 PM, Duong Quang Ha <quangduongha@gmail.com&= gt; wrote:
Hello,

Shebang line should like "#! /usr/bin/env ruby" or "#! <p= ath to your
ruby VM i.e /usr/bin/ruby>". This line tell shell which program to<= br> run.

Regards,

On Thu, Jun 27, 2013 at 10:58 AM, Todd Sterben <lists@ruby-forum.com> wrote:
> I am new to both linux and ruby. =C2=A0I am using Ubuntu and Ruby 1.9<= br> >
> When I do which ruby, I get /usr/bin/ruby
> When I do ruby -v I get ruby 1.9.3p0 (2011-10-30 revision 33570)
> [i686-linux]
>
> When I try to kick off a simple script
>
> =EF=BB=BF#!/usr/bin/env
>
> puts "Hello"
>
> I get
>
> ./test.rb: line 1: =EF=BB=BF#!/usr/bin/env: No such file or directory<= br> > ./test.rb: line 4: puts: command not found
>
>
> Why?
>
> Thanks
>
> Todd
>
> --
> Posted via ht= tp://www.ruby-forum.com/.



--
Duong Quang Ha (H=C3=A0 Quang D=C6=B0=C6=A1ng in Vietnamese)
blog.haqduong.com




--
Richard Wilson
Proteous Trading Group
ph. - (604) 842 5318
Skype - r.crawfordwilson

=E2=80=9C= This email may contain confidential and/or privileged informatio= n. If you are not the intended recipient or have received this email in err= or, please notify the sender immediately and destroy this email. Any unauth= orized copying, disclosure or distribution of the information contained on = this email is prohibited=E2=80=9D.
--047d7b86f6d25071c804e01b548c--