Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ruby on Rails script console

I wasn't able to run ./script/console previously, and it used to throw an error since my script console file had included #!/usr/bin/env ruby19. After doing hit and trial I fixed this error by replacing #!/usr/bin/env ruby19 with #!/usr/bin/env ruby.

What does the above line do?

Versions:

  • Ruby: 1.9.2-p180
  • Ruby on Rails: 2.3.5
like image 817
ashisrai_ Avatar asked Jun 01 '26 13:06

ashisrai_


1 Answers

The #! (hash bang) in the first line of a text file tells the program loader in most *nix systems to invoke the program that is specified next (in this case, /usr/bin/env) with any params supplied (in this case, ruby).

/usr/bin/env is just a portable way of looking in your environment for program named in the first argument. Here it is the Ruby interpreter. If the Ruby interpreter is in your PATH, env will find it and run it using the rest of the file as input.

You probably didn't have a program named ruby19 in your PATH, so you'd get the error. You do have a program named ruby, so that works.

like image 200
Fred Avatar answered Jun 03 '26 04:06

Fred



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!