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

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Fa219946c14ebfdfca6ff1c822dbb395?d=identicon&s=25 Mark (Guest)
on 2007-06-07 16:55
(Received via mailing list)
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?
E8a419959139f3f505b49bb95f7e7afe?d=identicon&s=25 Joshua Ballanco (jballanc)
on 2007-06-07 17:03
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
66aa5a090ed94f654da16b279bf589a6?d=identicon&s=25 Tony Thomas (Guest)
on 2007-06-07 17:11
(Received via mailing list)
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:

http://hivelogic.com/narrative/articles/ruby-rails...
Ef3aa7f7e577ea8cd620462724ddf73b?d=identicon&s=25 Rob Biedenharn (Guest)
on 2007-06-07 17:13
(Received via mailing list)
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 Biedenharn    http://agileconsultingllc.com
Rob@AgileConsultingLLC.com
E8a419959139f3f505b49bb95f7e7afe?d=identicon&s=25 Joshua Ballanco (jballanc)
on 2007-06-07 17:31
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
(http://macrabbit.com/cssedit/), 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.
Fcfabbc97b3b4d68b33ee58d775691c9?d=identicon&s=25 Grant Hollingworth (Guest)
on 2007-06-08 19:18
(Received via mailing list)
* Joshua Ballanco <jballanc@gmail.com> [2007-06-07 09:05]:
>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.
E8a419959139f3f505b49bb95f7e7afe?d=identicon&s=25 Joshua Ballanco (jballanc)
on 2007-06-08 19:23
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
This topic is locked and can not be replied to.