Rails on a Mac, so strange (to me) behavior

I have built Ruby from source, installed gems & rails on a MacBook
pro. I installed the source for a working Rails application in a
directory /rails_apps. I cd to the application directory under rails
apps and in the terminal I enter:

script/server

Terminal responds:
: No such file or directory

sudo script/server provides the same response
ls -la script/server returns:
-rwxr-xr-x 1 pogo admin 98 Nov 13 2006 script/server

I have all of 2 weeks experience on a Mac, which probably explains the
basic problem. Can someone advise?

Mark wrote:

I have built Ruby from source, installed gems & rails on a MacBook
pro. I installed the source for a working Rails application in a
directory /rails_apps. I cd to the application directory under rails
apps and in the terminal I enter:

script/server

Terminal responds:
: No such file or directory

sudo script/server provides the same response
ls -la script/server returns:
-rwxr-xr-x 1 pogo admin 98 Nov 13 2006 script/server

I have all of 2 weeks experience on a Mac, which probably explains the
basic problem. Can someone advise?

What does your path look like? (in terminal: printenv PATH). The ./
directory is not in their by default, so you would have to type
something like ./script/server. To save yourself the trouble of having
to do that each time, just add ./ to your path in your shell’s rc file:

In bash (and zsh, I believe):
export PATH=.:$PATH

In tcsh:
setenv PATH .:$PATH

I’ve run into problems installing on OS X from source too. I found it
much easier to install MAMP and Locomotive.

http://locomotive.raaum.org/
http://www.mamp.info/en/home/

MAMP launches Apache and MySQL and Locomotive launches Ruby on Rails.
Both reside in the Applications folder with your other apps. The other
advantage is that you can save your projects in the Documents folder.
For me, that style has been easier to manage than the command-line.
While I’m comfortable with the command line, I’m not a pro. Using this
combination of applications, you’ll be up and running within a half
hour.

Otherwise, this site has good notes on getting Ruby on Rails running
via the command line:

On Jun 7, 2007, at 10:55 AM, Mark wrote:

sudo script/server provides the same response
ls -la script/server returns:
-rwxr-xr-x 1 pogo admin 98 Nov 13 2006 script/server

I have all of 2 weeks experience on a Mac, which probably explains the
basic problem. Can someone advise?

Try:
ruby script/server

Then, if that works, look at the #! line at the top of the file (head
-1 script/server)

Mine is:
$ head -1 script/server
#!/usr/bin/env ruby

If yours is something else, then add a line that says where to find
your ruby. (particularly if the first line is not a #! unless you
just want to explicitly use “ruby script/whatever …”

Also, your ruby is where: which ruby
says it is based on your path.

-Rob

Rob B. http://agileconsultingllc.com
[email protected]

What does your path look like? (in terminal: printenv PATH). The ./
directory is not in their by default, so you would have to type
something like ./script/server. To save yourself the trouble of having
to do that each time, just add ./ to your path in your shell’s rc file:

You don’t need to use ./ when you already have a directory name
(‘script’ in this case) in the command.

‘script/server’ is the same as ‘./script/server’.

You only need ./ if you are already in the same directory as a command.

 cd script
 ./server

Also, adding ‘.’ to your PATH is generally a bad idea. You might end up
running a command you didn’t expect.

Grant Hollingworth wrote:

You don’t need to use ./ when you already have a directory name
(‘script’ in this case) in the command.

‘script/server’ is the same as ‘./script/server’.

You only need ./ if you are already in the same directory as a command.

 cd script
 ./server

Also, adding ‘.’ to your PATH is generally a bad idea. You might end up
running a command you didn’t expect.

Yeah…I’m not really sure what I was thinking (probably shouldn’t post
before morning coffee…). As for the wisdom in adding ‘.’ to PATH, my
rule of thumb has always been NEVER for root/superuser accounts,
normally no for user accounts, but for dev accounts (where I’ll be
compiling a lot of test code into directories not in PATH) it can be a
bit of a time-saver. Oddly, though, I still end up typing
‘./my_ruby_prog.rb’ half the time…

Cheers (and hope everything for the OP is working now!),

Josh

Tony Thomas wrote:

I’ve run into problems installing on OS X from source too. I found it
much easier to install MAMP and Locomotive.

http://locomotive.raaum.org/
http://www.mamp.info/en/home/

Yeah, I’ll throw my hat in with that suggestion. In fact, for the
current Rails app I’m developing, I’ve got a flash drive with
locomotive, textmate (http://macromates.com/), css edit
(Espresso — The Web Editor for Mac), and my rails directory on it. If you
change your dev environment to use SQLite3 then you can run (and
showcase!) your app from any mac (honestly, I don’t know why anyone
would go to the trouble of setting up a full blown MySQL DB just for
development…testing and deployment I can understand, but for dev
sqlite3 is just so attractive).

Really, I can’t say enough about this solution! In fact, if you throw
one of the all-in-one rail packages for Widows or Linux on there, then
you can develop anywhere.