# To convert a Ruby tk script to \*.exe

**URL:** <https://rubytalk.org/t/to-convert-a-ruby-tk-script-to-exe/64111>\
**Category:** ruby-talk\
**Created:** [11 November 2011 11:54 UTC](https://rubytalk.org/t/to-convert-a-ruby-tk-script-to-exe/64111 "2011-11-11T11:54:47Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Manju\_M1](https://avatars.discourse-cdn.com/v4/letter/m/5f8ce5/32.png) [@Manju\_M1](https://rubytalk.org/u/Manju_M1)\
**Post date:** [11 November 2011 11:54 UTC](https://rubytalk.org/t/to-convert-a-ruby-tk-script-to-exe/64111/1 "2011-11-11T11:54:47Z")

</div>

Hi,

I am building a gui for ruby using Tk. I built one and I would like to  
convert that into \*.exe file. Can anyone suggest me how can I do  
that?  
I tried using Ocra, but I was not successful

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

---

<div class="post-metadata">

**Author:** ![11142](https://avatars.discourse-cdn.com/v4/letter/1/e0b2c6/32.png) [@11142](https://rubytalk.org/u/11142)\
**Post date:** [13 November 2011 14:41 UTC](https://rubytalk.org/t/to-convert-a-ruby-tk-script-to-exe/64111/2 "2011-11-13T14:41:01Z")

</div>

What precisely was your problem? I've never really had trouble with Ocra.

-- Matma Rex

> **···**
>
> 2011/11/11 Manju M. \<manjuvpm12@gmail.com\>:
> 
> > I tried using Ocra, but I was not successful

---

<div class="post-metadata">

**Author:** ![Manju\_M1](https://avatars.discourse-cdn.com/v4/letter/m/5f8ce5/32.png) [@Manju\_M1](https://rubytalk.org/u/Manju_M1)\
**Post date:** [13 November 2011 15:17 UTC](https://rubytalk.org/t/to-convert-a-ruby-tk-script-to-exe/64111/3 "2011-11-13T15:17:40Z")

</div>

When I tried using ocra I got some error messages. The normal programs I  
was able to convert easily without any problem using ocra, but for the  
tk scripts I couldnt do so. I have attached the screenshot of error  
messages that I got.

Attachments:  
[http://www.ruby-forum.com/attachment/6741/screenshot.png](http://www.ruby-forum.com/attachment/6741/screenshot.png)

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

---

<div class="post-metadata">

**Author:** ![Manju\_M1](https://avatars.discourse-cdn.com/v4/letter/m/5f8ce5/32.png) [@Manju\_M1](https://rubytalk.org/u/Manju_M1)\
**Post date:** [14 November 2011 04:30 UTC](https://rubytalk.org/t/to-convert-a-ruby-tk-script-to-exe/64111/4 "2011-11-14T04:30:07Z")

</div>

Oh.. Sorry. Please have a look at this one.

Attachments:  
[http://www.ruby-forum.com/attachment/6744/scr.png](http://www.ruby-forum.com/attachment/6744/scr.png)

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

---

<div class="post-metadata">

**Author:** ![Luca\_Email](https://avatars.discourse-cdn.com/v4/letter/l/76d3ee/32.png) [@Luca\_Email](https://rubytalk.org/u/Luca_Email)\
**Post date:** [29 December 2011 06:56 UTC](https://rubytalk.org/t/to-convert-a-ruby-tk-script-to-exe/64111/5 "2011-12-29T06:56:53Z")

</div>

-----Messaggio originale-----

> **···**
>
> Da: Manju M. [[mailto:manjuvpm12@gmail.com](mailto:manjuvpm12@gmail.com)]  
> Inviato: venerdì 11 novembre 2011 12:55  
> A: ruby-talk ML  
> Oggetto: To convert a Ruby tk script to \*.exe
> 
> Hi,
> 
> I am building a gui for ruby using Tk. I built one and I would like to  
> convert that into \*.exe file. Can anyone suggest me how can I do that?  
> I tried using Ocra, but I was not successful
> 
> --  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
> 
> --  
> Caselle da 1GB, trasmetti allegati fino a 3GB e in piu' IMAP, POP3 e SMTP autenticato? GRATIS solo con [Email.it](http://Email.it) [http://www.email.it/f](http://www.email.it/f)
> 
> Sponsor:  
> Conto Arancio al 4,20%. Zero spese e massima liberta', aprilo in due minuti!  
> Clicca qui: [http://adv.email.it/cgi-bin/foclick.cgi?mid](http://adv.email.it/cgi-bin/foclick.cgi?mid)922&d)-12

---

<div class="post-metadata">

**Author:** ![Jon\_Cooper](https://avatars.discourse-cdn.com/v4/letter/j/d26b3c/32.png) [@Jon\_Cooper](https://rubytalk.org/u/Jon_Cooper)\
**Post date:** [6 January 2012 15:50 UTC](https://rubytalk.org/t/to-convert-a-ruby-tk-script-to-exe/64111/6 "2012-01-06T15:50:24Z")

</div>

Maybe too late but the thing to do is to copy the ruby file you wish to  
compile to the C:\Ruby193\lib folder which contains the tcltk directory  
and then run ocra there as follows....

ocra yourfile.rb tcltk --no-autoload

... then you can copy the resulting .exe file to wherever you want  
afterwards and it runs fine.

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

---

<div class="post-metadata">

**Author:** ![11142](https://avatars.discourse-cdn.com/v4/letter/1/e0b2c6/32.png) [@11142](https://rubytalk.org/u/11142)\
**Post date:** [13 November 2011 17:17 UTC](https://rubytalk.org/t/to-convert-a-ruby-tk-script-to-exe/64111/7 "2011-11-13T17:17:11Z")

</div>

> Attachments:  
> [http://www.ruby-forum.com/attachment/6741/screenshot.png](http://www.ruby-forum.com/attachment/6741/screenshot.png)

This screenshot is missing the top, with the actual error...

-- Matma Rex

---

<div class="post-metadata">

**Author:** ![Luca\_Email](https://avatars.discourse-cdn.com/v4/letter/l/76d3ee/32.png) [@Luca\_Email](https://rubytalk.org/u/Luca_Email)\
**Post date:** [29 December 2011 06:52 UTC](https://rubytalk.org/t/to-convert-a-ruby-tk-script-to-exe/64111/8 "2011-12-29T06:52:03Z")

</div>

-----Messaggio originale-----

> **···**
>
> Da: Manju M. [[mailto:manjuvpm12@gmail.com](mailto:manjuvpm12@gmail.com)]  
> Inviato: lunedì 14 novembre 2011 05:30  
> A: ruby-talk ML  
> Oggetto: Re: To convert a Ruby tk script to \*.exe
> 
> Oh.. Sorry. Please have a look at this one.
> 
> Attachments:  
> [http://www.ruby-forum.com/attachment/6744/scr.png](http://www.ruby-forum.com/attachment/6744/scr.png)
> 
> --  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
> 
> --  
> Caselle da 1GB, trasmetti allegati fino a 3GB e in piu' IMAP, POP3 e SMTP autenticato? GRATIS solo con [Email.it](http://Email.it) [http://www.email.it/f](http://www.email.it/f)
> 
> Sponsor:  
> Capodanno al parco Oltremare Riccione: Pacchetto hotel 3 stelle in centro + ingresso al parco.  
> \* Mezza pensione, Internet gratis, animazione per bimbi. Scopri l'offerta!  
> Clicca qui: [http://adv.email.it/cgi-bin/foclick.cgi?mid](http://adv.email.it/cgi-bin/foclick.cgi?mid)981&d)-12

---

<div class="post-metadata">

**Author:** ![7stud2](https://avatars.discourse-cdn.com/v4/letter/7/9de053/32.png) [@7stud2](https://rubytalk.org/u/7stud2)\
**Post date:** [25 July 2012 23:04 UTC](https://rubytalk.org/t/to-convert-a-ruby-tk-script-to-exe/64111/9 "2012-07-25T23:04:34Z")

</div>

Jon Cooper wrote in post #1039744:

> Maybe too late but the thing to do is to copy the ruby file you wish to  
> compile to the C:\Ruby193\lib folder which contains the tcltk directory  
> and then run ocra there as follows....
> 
> ocra yourfile.rb tcltk --no-autoload
> 
> ... then you can copy the resulting .exe file to wherever you want  
> afterwards and it runs fine.

For future reference as well, if you want to let Ocra pick up gems which  
it doesn't acquire properly from their "require" statements, you can  
check for the "Ocra" constant and deviate. For example:

require 'watir-webdriver'

if defined?(Ocra)  
&nbsp;&nbsp;puts "I'm building an exe!"; b = Watir::Browser.new; b.quit; exit  
end

puts "I'm not using Ocra this time."

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/\](http://www.ruby-forum.com/%5C).
