Forum: Ruby How do I install Ruby on my Ubuntu 12.10 partition.

Posted by Kaye Ng (marlon)
on 2012-12-25 12:01
I already have Ruby installed on my Windows 7 partition.

I need it on my Ubuntu partition.

I know there are instructions on the ruby website but I want to be sure.

Thank you guys!
Posted by Bhavesh Pansheriya (Guest)
on 2012-12-25 12:07
(Received via mailing list)
Hello Kaye,
-> Following commands to install Ruby with RVM

sudo apt-get update

apt-get install build-essential

sudo apt-get install build-essential libmysqlclient-dev libmysql-ruby
libsqlite3-ruby libsqlite3-dev

apt-get install curl git-core build-essential zlib1g-dev libssl-dev
libreadline5-dev

bash -s stable < <(curl -sk
https://raw.github.com/wayneeseguin/rvm/master/bin...)

apt-get install build-essential openssl libreadline6 libreadline6-dev 
curl
git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0
libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev
ncurses-dev automak

echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" #
Load RVM function' >> ~/.bash_profile

echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" #
Load RVM function' >> ~/.bashrc

restart console

type below line into console for successful installtion of rvm

rvm | head -1

rvm install 1.9.2

rvm install 1.8.7

rvm use 1.9.2 --default

Thanks,
Bhavesh -RubyonRails
Posted by Hans Mackowiak (hanmac)
on 2012-12-25 12:11
it works without RVM!

just install "apt-get install ruby-full"
and you already get the nearly newest ruby
Posted by Kiswono Prayogo (Guest)
on 2012-12-25 13:46
(Received via mailing list)
without rvm, and newer than ruby-full (1.9.3.194), use brightbox's ppa
(1.9.3.327)

sudo apt-add-repository ppa:brightbox/ruby-ng
sudo apt-get update
sudo apt-get install ruby1.9.1
Posted by Kaye Ng (marlon)
on 2012-12-25 17:14
Thanks guys! So now how do I run a simple Ruby program inside Ubuntu?
I have a file named Dungeon_interactive.rb
In Windows, I just typed that file name in command prompt and it would 
run.
It's a simple, text based game, a Ruby exercise for beginners.

How do I run it in Ubuntu?

Thanks!!!
Posted by Derrick B. (dbuckhal)
on 2012-12-25 19:27
Kaye Ng wrote in post #1090172:
> Thanks guys! So now how do I run a simple Ruby program inside Ubuntu?
> I have a file named Dungeon_interactive.rb
> In Windows, I just typed that file name in command prompt and it would
> run.
> It's a simple, text based game, a Ruby exercise for beginners.
>
> How do I run it in Ubuntu?
>
> Thanks!!!

You can simply type:

$ ruby interactive.rb

... from the shell prompt, and that should do it.  The dollar sign
indicates your shell prompt and is not meant to be typed.  Only type
what follows the dollar sign.

To make your Ruby file executable, first find your Ruby executable:

$ which ruby

---example output---
/usr/bin/ruby

...then add this line as the FIRST line of your Ruby file:

#!/usr/bin/ruby

IMPORTANT: Make sure that path matches the path found using the "which"
command.

Lastly, type:

$ chmod 755 interactive.rb

...to make your file executable.  Now all you need to do is type:

$ ./interactive.rb

...and it should be executed.
Posted by Hans Mackowiak (hanmac)
on 2012-12-26 05:54
duckhai you are wrong again its
#!/usr/bin/env ruby

otherwise you could get evil problems
Posted by Matt Lawrence (Guest)
on 2012-12-26 06:08
(Received via mailing list)
I recommend "sudo synaptic" and use the GUI interface to choose the
versions and extensions you want.

-- Matt
It's not what I know that counts.
It's what I can remember in time to use.
Posted by Derrick B. (dbuckhal)
on 2012-12-26 06:25
Hans Mackowiak wrote in post #1090216:
> duckhai you are wrong again its
> #!/usr/bin/env ruby
>
> otherwise you could get evil problems

"wrong again"???  what does that mean?

It is not wrong, just another way to do it.  Right?  Or am I "wrong
again"?  :)
Posted by D. Deryl Downey (ddd)
on 2012-12-26 06:38
(Received via mailing list)
NEITHER of you are wrong. You won't run into nasty problems. What nasty 
problems could you get? So long as the ruby install that that *specific* 
ruby binary comes from (and is referenced in its internal compilation 
manifest) is fine, the ruby will be fine. EITHER way works.

--
D. Deryl Downey

"The bug which you would fright me with I seek" - William Shakespeare - 
The Winter's Tale, Act III, Scene II - A court of Justice.
Posted by Hans Mackowiak (hanmac)
on 2012-12-26 06:42
when you install ruby yourself, its mostly put under /usr/local/bin ...

so then the path does not match with the ruby program anymore, and then 
the user comes back because they programs does not work anymore (because 
of newer ruby features maybe)
Posted by THUFIR H. (thufir_h)
on 2012-12-26 07:26
(Received via mailing list)
On Tue, 25 Dec 2012 20:01:39 +0900, Kaye Ng wrote:


> I need it on my Ubuntu partition.
>
> I know there are instructions on the ruby website but I want to be sure.



 Unless doing guided install you should read all sub-sections under the
RVM Section.
Install RVM with ruby:

$ \curl -L https://get.rvm.io | bash -s stable --ruby

Additionally with rails:

$ \curl -L https://get.rvm.io | bash -s stable --rails


https://rvm.io/rvm/install/



do not install ruby with the package manager.  IDE's and programming
languages move too quickly to use package managers.  Hence, tools like
RVM.


HTH,

Thufir
Posted by D. Deryl Downey (ddd)
on 2012-12-26 07:31
(Received via mailing list)
That should point out instinctively that the user is responsible for 
ensuring the right ruby is loaded. Using #!/usr/bin/env ruby does one 
thing and one thing only. It ensures that the first found ruby in the 
path is used, by checking en environment for the binary and using its 
full path. This presupposes that *that* particular ruby *is* the one a 
user wishes to use, which is generally the case. However, if a user wish 
a to invoke a specific ruby not in the path, they would then use the 
full path to *that* ruby and have their script/app use that one.

All of this, in turn is affected by the settings of GEM_HOME and 
RUBY_HOME and RUBY_OPTS. Under version managers, this can be affected by 
MY_RUBY_HOME and GEM_PATH settings as well.

So, the point being made is that *either* approach is, in fact, correct. 
One just needs to understand the impact(s) of using one or the other, 
which is a self-education pointer.

--
D. Deryl Downey

"The bug which you would fright me with I seek" - William Shakespeare - 
The Winter's Tale, Act III, Scene II - A court of Justice.
Posted by Kaye Ng (marlon)
on 2012-12-26 17:14
Derrick B. wrote in post #1090185:
>
> You can simply type:
>
> $ ruby interactive.rb
>
> ... from the shell prompt, and that should do it.  The dollar sign
> indicates your shell prompt and is not meant to be typed.  Only type
> what follows the dollar sign.
>
> To make your Ruby file executable, first find your Ruby executable:
>
> $ which ruby
>
> ---example output---
> /usr/bin/ruby
>
> ...then add this line as the FIRST line of your Ruby file:
>
> #!/usr/bin/ruby
>
> IMPORTANT: Make sure that path matches the path found using the "which"
> command.
>
> Lastly, type:
>
> $ chmod 755 interactive.rb
>
> ...to make your file executable.  Now all you need to do is type:
>
> $ ./interactive.rb
>
> ...and it should be executed.

Thanks a lot guys. Derrick, /usr/bin/ruby is right. So I edited the file 
with Ubuntu's text editor, added #!/usr/bin/ruby (with the pound sign) , 
then saved it.

Went back to shell prompt. Typed:
chmod 755 Dungeon_interactive.rb

Got this:
chmod: cannot access `Dungeon_interactive.rb': No such file or directory

Does my ruby file Dungeon_interactive.rb being in my THUMB DRIVE have 
anything to do with it?

Thanks a lot!!!
Posted by Derrick B. (dbuckhal)
on 2012-12-26 19:29
Kaye Ng wrote in post #1090268:
>
> Went back to shell prompt. Typed:
> chmod 755 Dungeon_interactive.rb
>
> Got this:
> chmod: cannot access `Dungeon_interactive.rb': No such file or directory
>
> Does my ruby file Dungeon_interactive.rb being in my THUMB DRIVE have
> anything to do with it?
>
> Thanks a lot!!!

Two possibilities:

1. You are using that command in the same location of the file.
--> It is a possibly a typo.  You can use tab completion to help ensure
the right file is found in the current directory.

2. You are using that command in a location other than that of the
target file.
--> Make sure that you are in the same directory of your target file.

Look for your mounted media under /media/ and cd to the appropriate
location before using the command.

From https://help.ubuntu.com/community/Mount/USB:
----------------
Mounting
By default, storage devices that are plugged into the system mount
automatically in the /media directory, open a file browser window
for each volume and place an icon on your desktop. If you plug in a usb
hard disk with many partitions, all of the partitions will automatically
mount. This behaviour may not be what you want so you can configure it
as shown below.

If the volumes have labels the icons will be named accordingly,
otherwise they will be named "disk" and as more volumes are added, you
can get "disk-1" and so on.
----------------

Hope this helps!

Derrick
Posted by Kaye Ng (marlon)
on 2012-12-27 17:16
Hey Derrick,

kaye@kaye-R439-R478:/media/kaye/MARLON/ruby/practice$ chmod 755 
Dungeon_interactive.rb

kaye@kaye-R439-R478:/media/kaye/MARLON/ruby/practice$
./Dungeon_interactive.rb

bash: ./Dungeon_interactive.rb: Permission denied

What now?

Also, is there anyway to change the "kaye@kaye-R439-R478" ? It's 
probably a Ubuntu question but what the heck....

Thanks!!!
Posted by Panagiotis Atmatzidis (Guest)
on 2012-12-27 17:24
(Received via mailing list)
Hello,

On 27 Δεκ 2012, at 18:16 , Kaye Ng <lists@ruby-forum.com> wrote:

> What now?
You changed the "permissions" of the file but didn't make the file 
"executable".

Either you run it as:

ruby file.rb

Or you need to "chmod +x file.rb" to make it 'executable' under UNIX and 
clones (like linux).

>
> Also, is there anyway to change the "kaye@kaye-R439-R478" ? It's
> probably a Ubuntu question but what the heck....

gksudo gedit /etc/hostname

>
> Thanks!!!
>
> --
> Posted via http://www.ruby-forum.com/.
>

No prob :-)


Panagiotis (atmosx) Atmatzidis

email:  atma@convalesco.org
URL:  http://www.convalesco.org
GnuPG ID: 0xE736C6A0
gpg --keyserver x-hkp://pgp.mit.edu --recv-keys 0xE736C6A0
Posted by Hassan Schroeder (Guest)
on 2012-12-27 17:59
(Received via mailing list)
On Thu, Dec 27, 2012 at 8:24 AM, Panagiotis Atmatzidis
<atma@convalesco.org> wrote:

> You changed the "permissions" of the file but didn't make the file "executable".

Uh, no; 755 *is* executable mode for user/group/world. Something else
has gotten messed up in the file in question. Really, this is so basic:

08:48 /tmp $ cat > example.rb
#!/usr/bin/env ruby

puts "hello"
08:48 /tmp $ ./example.rb
bash: ./example.rb: Permission denied
08:48 /tmp $ ruby ./example.rb
hello
08:48 /tmp $ chmod 755 example.rb
08:48 /tmp $ ./example.rb
hello
08:48 /tmp $

>> Also, is there anyway to change the "kaye@kaye-R439-R478" ? It's
>> probably a Ubuntu question but what the heck....
>
> gksudo gedit /etc/hostname

Seriously, you would suggest someone change their *hostname*
just to have different prompt text?

When it can be configured to show actual *useful* information like
the directory you're in or which git branch is checked out?

And to the OP - yes, it's an Ubuntu/shell question, and you should
make time to learn about working in a command-line environment;
it will be effort well-spent.
Posted by Derrick B. (dbuckhal)
on 2012-12-27 17:59
Panagiotis Atmatzidis wrote in post #1090372:
>
> Or you need to "chmod +x file.rb" to make it 'executable' under UNIX and
> clones (like linux).
>

I'm really surprised by that!  Why did changing the permissions to 755 
not allow it to be executed?  It still sets the 'x' flag.  I've used 
both methods and either worked in FreeBSD, Debian, and Cygwin 
environments.  What is the difference?  I Google'd and check the man 
pages, but did not find an answer.

Thanks,
Posted by "张月乾" <nohappiness@gmail.com> (Guest)
on 2012-12-28 05:00
(Received via mailing list)
2012/12/28 Kaye Ng <lists@ruby-forum.com>

> What now?
>
> Also, is there anyway to change the "kaye@kaye-R439-R478" ? It's
> probably a Ubuntu question but what the heck....
>
> Thanks!!!
>
> --
> Posted via http://www.ruby-forum.com/.
>
>
Did you have "shebang" line at the beginning ?
Like this:
#!/usr/bin/ruby
OR
#!/usr/bin/env ruby
Posted by Panagiotis Atmatzidis (Guest)
on 2012-12-29 01:10
(Received via mailing list)
Hello,

On 27 Δεκ 2012, at 18:58 , Hassan Schroeder <hassan.schroeder@gmail.com> 
wrote:

>
> puts "hello"
> 08:48 /tmp $ ./example.rb
> bash: ./example.rb: Permission denied
> 08:48 /tmp $ ruby ./example.rb
> hello
> 08:48 /tmp $ chmod 755 example.rb
> 08:48 /tmp $ ./example.rb
> hello
> 08:48 /tmp $

Yeah you're right. My bad, I'll die and go to hell for that.

However you don't even need 755, 600 is enough to make it exec.

>
>>> Also, is there anyway to change the "kaye@kaye-R439-R478" ? It's
>>> probably a Ubuntu question but what the heck....
>>
>> gksudo gedit /etc/hostname
>
> Seriously, you would suggest someone change their *hostname*
> just to have different prompt text?

I didn't *suggest* that. I did not suggest anything for that matter.

I just answered a very straight forward question.

>
> When it can be configured to show actual *useful* information like
> the directory you're in or which git branch is checked out?

So according to you a user that doesn't know how to change his hostname
will be able to use oh-my-zsh-like prompts and 
git/mercurial/svn/cvs/whatever???

>
> And to the OP - yes, it's an Ubuntu/shell question, and you should
> make time to learn about working in a command-line environment;
> it will be effort well-spent.
>
> --
> Hassan Schroeder ------------------------ hassan.schroeder@gmail.com
> http://about.me/hassanschroeder
> twitter: @hassan
>


Panagiotis (atmosx) Atmatzidis

email:  atma@convalesco.org
URL:  http://www.convalesco.org
GnuPG ID: 0xE736C6A0
gpg --keyserver x-hkp://pgp.mit.edu --recv-keys 0xE736C6A0
Posted by Panagiotis Atmatzidis (Guest)
on 2012-12-29 01:14
(Received via mailing list)
On 29 Δεκ 2012, at 02:07 , Panagiotis Atmatzidis <atma@convalesco.org> 
wrote:

>> has gotten messed up in the file in question. Really, this is so basic:
>> 08:48 /tmp $ ./example.rb
>> hello
>> 08:48 /tmp $
>
> Yeah you're right. My bad, I'll die and go to hell for that.
>
> However you don't even need 755, 600 is enough to make it exec.

No it's not, you actually *need* 700 .. oh my ... :-( I need to spent 
some time in cli.
pays back! ... (2 secs)

> I didn't *suggest* that. I did not suggest anything for that matter.
>>
>
> Panagiotis (atmosx) Atmatzidis
>
> email:  atma@convalesco.org
> URL:  http://www.convalesco.org
> GnuPG ID: 0xE736C6A0
> gpg --keyserver x-hkp://pgp.mit.edu --recv-keys 0xE736C6A0
> --
> The wise man said: "Never argue with an idiot. They bring you down to their 
level and beat you with experience."
>


Panagiotis (atmosx) Atmatzidis

email:  atma@convalesco.org
URL:  http://www.convalesco.org
GnuPG ID: 0xE736C6A0
gpg --keyserver x-hkp://pgp.mit.edu --recv-keys 0xE736C6A0
Posted by Hassan Schroeder (Guest)
on 2012-12-29 02:26
(Received via mailing list)
On Fri, Dec 28, 2012 at 4:07 PM, Panagiotis Atmatzidis
<atma@convalesco.org> wrote:

> So according to you a user that doesn't know how to change his hostname
> will be able to use oh-my-zsh-like prompts and git/mercurial/svn/cvs/whatever???

I'm saying that a user not familiar with a CLI environment is best
served by learning its capabilities. And yes, that includes knowing
what a shell prompt represents, and how to change it.

YMMV,
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.