PDA

View Full Version : Ruby on Rails



Taresa
02-09-2006, 10:54 AM
Sign me up!

-taresaco

rando
02-09-2006, 12:25 PM
Send an email to rando@bluehost.com with your domain name and I'll get you moved over to box85 so you can test it.

Taresa
02-10-2006, 08:00 AM
Is anyone else using Ruby? I tried this:

taresaco@taresa.com [~]# ls -la calc.rb
-rw-r--r-- 1 taresaco taresaco 8 Feb 9 16:09 calc.rb
taresaco@taresa.com [~]# ruby calc.rb
-bash: ruby: command not found

calc.rb is just one line:

puts 1+2

Maybe I'm looking at the wrong Ruby tutorial. Has anyone else had success?

rando
02-10-2006, 08:05 AM
Ruby isn't in your path for some reason. It's installed to /usr/local/bin/ruby.

Taresa
02-10-2006, 08:07 AM
taresaco@taresa.com [~]# cd usr/local/bin/ruby
-bash: cd: usr/local/bin/ruby: No such file or directory

Que?

Taresa
02-10-2006, 08:08 AM
If I need to tell bash where Ruby is... I'm not really sure how to do that, but I'll look it up. Is that the case?

DrSuSE
02-10-2006, 08:45 AM
That last ruby is the executable, not another directory. Try entering:

/usr/local/bin/ruby calc.rb

Presuming that works, enter the following:

echo $PATH

I assume /usr/local/bin won't be in the listed directories.

Edit (with something simple like pico or vi) the .bash_profile file in your homedir and on the end of the PATH line, add (without quotes) ":/usr/local/bin"

So for example, it might read:

PATH=$PATH:$HOME/bin

make that:

PATH=$PATH:$HOME/bin:/usr/local/bin

Then either source .bash_profile or simple log out and back in. Presuming the executable is where Rando says it is AND you have the appropriate access rights, that should make it work normally for you.

--DrSuSE

macgyver2
02-10-2006, 09:00 AM
taresaco@taresa.com [~]# cd usr/local/bin/ruby
-bash: cd: usr/local/bin/ruby: No such file or directory

Que?
A couple things here...

First, you're missing the leading '/'. You're telling the cd command to go to the usr directory under your current working directory as opposed to the system usr directory. Second, you can't cd to that anyway (it'll throw another error) because it's not a directory. If you want to see if the ruby executable is really there, try 'ls /usr/local/bin | grep ruby'.


If I need to tell bash where Ruby is... I'm not really sure how to do that, but I'll look it up. Is that the case?
If you need to tell bash about /usr/local/bin, put the following line in your ~/.bashrc (and your ~/.bash_profile if you don't have that pointing at your .bashrc):

PATH=/usr/local/bin:${PATH}; export PATH
Here's (http://linux.org.mt/article/terminal) a decent intro to bash. Environment settings are dealt with briefly towards the bottom of the page. And here's (http://www.digilife.be/quickreferences/QRC/Bash%20Quick%20Reference.pdf) a link to a bash quick reference card (well, cards).


Edit: Looks like DrSuSE beat me to it. That's what happens when you're interrupted halfway through writing a post. :)

Taresa
02-10-2006, 09:06 AM
DrSUSE:

taresaco@taresa.com [~]# /usr/local/bin/ruby calc.rb
-bash: /usr/local/bin/ruby: No such file or directory

Macgyver2:

taresaco@taresa.com [~]# cd /usr/local/bin/ruby
-bash: cd: /usr/local/bin/ruby: No such file or directory

It's been too long since I've edited a shell.

I'll try editing my .bashes now. Thanks guys! I'll post what happens.

DrSuSE
02-10-2006, 09:08 AM
Taresa,

If you're getting: "/usr/local/bin/ruby: No such file or directory" then either ruby isn't there or there's some sort of privelages type situation going on. Sounds like you're going to need BH to doublecheck the location for you.

--DrSuSE

Taresa
02-10-2006, 10:00 AM
That was unspeakably painful.

I don't have Pico somehow, got a headache trying to remember vi, so...

taresaco@taresa.com [~]# emacs .bash_profile
taresaco@taresa.com [~]# source .bash_profile
taresaco@taresa.com [~]# /usr/local/bin/ruby calc.rb
-bash: /usr/local/bin/ruby: No such file or directory

I bestow cool points upon thee for helping me out.

Taresa
02-10-2006, 10:03 AM
taresaco@taresa.com [~]# ls /usr/local/bin | grep ruby
/bin/ls: /usr/local/bin: No such file or directory
taresaco@taresa.com [~]# ls /usr/local | grep ruby
/bin/ls: /usr/local: No such file or directory
taresaco@taresa.com [~]# ls / | grep ruby
taresaco@taresa.com [~]# ls /usr | grep ruby

It seems I've forgotten just enough of this to humiliate and annoy myself ;) Will wait to see if Rando replies.

macgyver2
02-10-2006, 10:30 AM
That was unspeakably painful.

I don't have Pico somehow, got a headache trying to remember vi, so...
Try nano. Nano is the new pico...on my box pico is just a link to nano anyway...

Edit: punctuation

rando
02-10-2006, 10:51 AM
Taresa, hold on. I'm looking into it.

rando
02-10-2006, 11:13 AM
Yeah that was interesting. I'm glad I had people testing this before rolling it out everywhere, I had to completely change my build process just now.



taresaco@taresa.com [~]# ruby calc.rb
3


it's /usr/bin/ruby now instead of /usr/local/bin/ruby. ruby scripts should have "#!/usr/bin/env ruby" as their first line anyway, though, which will just find the right one.

This issue didn't affect things running under apache, just when you were logged into the shell, which is why I didn't catch this much earlier. :)

DrSuSE
02-10-2006, 11:35 AM
Taresa,

Let us know if you need any help readjusting things.

--DrSuSE

bmac
02-17-2006, 11:13 AM
Hi,
Could you tell me how to run a ruby script throught the browser?

something like wwwdomain.com/script.rb (or .rbx)

I've tried several things and none seems to work. :confused: