How to run ruby programs on Windows 7? - ruby

Does anyone know how to run/compile Ruby programs on Windows 7? For example you can compile Java in Eclipse, but I can't seem to find one for Ruby.

http://rubyinstaller.org/ - "The easy way to install Ruby on Windows".
Will give you the language and execution environment - everything you should need to get started.

Ruby isn't compiled, but rather interpreted. You need to install Ruby using the above link given by #ilollar.
Then, if you have the source code of a program in the file some_ruby.rb, you will execute this in cmd:
ruby some_options.rb
This is the general form of a ruby command:
ruby [ruby options] [program name] [program options]

Here is a free online book that will answer most of the question you have about Ruby if you are just starting out: http://ruby.learncodethehardway.org/book/
It's called "Learn Ruby the Hard Way", but don't let the name throw you off - the book is actually pretty easy to follow and doesn't assume you know anything about programming.
It will get you started writing Ruby and running programs for the first time.
Like ilollar said, the Ruby Installer is the best way to put Ruby on your Windows computer.
I'm currently running Ruby on Windows 7 writing Rails applications. You can do a lot on Windows with Ruby, however, you can't do everything. There are bundles of files that you can download that will help you write your Ruby programs - they are called Gems. Some gems will not run on Windows - The Ruby Racer and some versions of EventMachine are two that immediately come to mind.
This can be frustrating, but if it ever happens you can install a version of Linux in a virtual machine on your Windows computer so that you can use these gems without having to get a new machine.
You can also install Linux to run alongside Windows without having to reformat or mess with the partitions on your hard drive. There is a program called 'Wubi' that will install Ubuntu (a version of Linux) to run inside your Windows machine. It will actually let you pick Windows or Linux when you start your machine.
But all this is stuff to think about later on. You can certainly develop Ruby on Windows for now.

Also, in case you want to run just Ruby interactively, find the location where it is installed and browse to the bin subdirectory. For me this was \RailsInstaller\Ruby1.9.3\bin. In this directory there should be a file irb.bat. Double-click on it and you'll get a Ruby console session.

You can create window executables with ocra. That way you can create the app and push the app to another pc that does not have Ruby installed on it.

Related

Uninstalling Lua

How in the world do I get rid of Lua on my Macbook Air?
I installed the programming language just to test it out and now I am not sure how to get rid of it.
I used the official Lua website <lua.org> to install it and followed the instructions on the download page using 'curl' or whatever it is.
I am a programming beginner. Other languages, like Java and Python, don't have this issue. Can someone please help me get rid of the annoying thing? I don't need it clogging up my computer.
Lua's Makefile has an uninstall target which should allow you to remove it from your system. cd to the Lua source directory (lua-5.4.3 for the current version) and type this command:
sudo make uninstall
The sudo is required if you need administrative privileges to remove software.
(I'm not familiar with MacOS, but from the comments, it seems to work the same way as it does on GNU systems.)

Single executable binary of Ruby gem

What options are available to create a single binary that contains my Ruby gem along with a Ruby runtime?
My goal is to be able to share the executable with another developer and they could simply run the executable from their command line passing it required arguments similar to Vagrant.
P.S. The program is intended to be run in a *nix operating systems with Ruby versions >= 2.5.
There's ruby-packer but the repo has been dead for a while. There are forks with Ruby 2.5. It can produce binaries for Linux, Mac, Windows and probably some others.
For linux based systems you could use AppImage (there are some scripts found on google that put a ruby in the image) or maybe Snapcraft.
When you have ruby-packer and the dependencies installed, it's just a matter of rubyc -o binary-name gem-executable-name in the app's directory. Takes about 15 minutes to compile.

Firefox cannot open "libgtk-3.so.0". How to circumvent?

I have two CentOS VMs which use Jenkins to run automated tests through firefox. Both have firefox installed. Both versions of firefox are the same (firefox-56.0.1). I do not know if they are both x86_64 or some other type, but whichever they are, they are the same. (I am using the same .tar.bz2 file. I copied it from one instance to the other.)
In one instance, I am able to run firefox. "firefox --headless" returns "*** You are running in headless mode."
After copying the .tar.bz2 file to the other instance and installing firefox, I find that the new instance does not have the same performance. "firefox --headless" returns the following:
XPCOMGlueLoad error for file /usr/local/firefox/libmozgtk.so:
libgtk-3.so.0: cannot open shared object file: No such file or directory
Couldn't load XPCOM.
What might explain this difference? It appears that I did something right in the first instance, but I cannot tell what. Is there some setting that will prevent firefox from trying to use the "libgtk-3.so.0" file? This file does not exist on either instance.
I've seen this question elsewhere, but the answer seems to focus on versions (I know my version has worked in the first instance) and a particular bug that has been backlogged (this bug only bothers me for the new instance).
Problem solved minutes after asking the question.
Simply run:
yum info gtk3
Check if gtk3 is installed. If not:
yum install gtk3
My old instance had gtk3 version 3.22.10 installed. My new instance had the same available but not installed. I don't recall seeing this in any of the guides to running firefox headlessly, but a search result that I did not originally think worth checking was able to resolve this rather quickly. Credit to the folks at https://forums.fedoraforum.org/showthread.php?310652-Udating-Firefox-fedora-19
For Ubuntu or Debian distros use:
apt-get install packagekit-gtk3-module
You probably installed the wrong firefox version for 32bit on a 64bit system.
try downloading firefox with this portable installer download-mozilla-portable.sh which should work on a 64bit linux (tested in Ubuntu 19.10)

How to "install" sqlite3 on my Windows 10 computer?

So I wanted to get started on Ruby on Rails because it sounds like fun but as I reached part 3.1 over here I ran into some problems.
First I just attempted "sqlite3 --version" in the "ruby cmd" and it came up with: "'sqlite3' is not recognized as an internal or external command, operable program or batch file." So I attempted to just install the sqlite ruby gem and it did that just fine but as I typed "sqlite3 --version", same story. So I just figured you needed to install the thing your self.
So after I downloaded the "Precompiled Binaries for Windows" (64-bit DLL (x64) for SQLite version 3.11.1.) over here I moved the .dll and .def files to my system32 folder, launched CMD as admin and typed regsvr32 sqlite3.dll I get this error message: "The module "C:\WINDOWS\System32\sqlite3.dll" was loaded but the entry-point DIIRegisterServer was not found. Make sure that "C:\WINDOWS\System32\sqlite3.dll" is a valid DLL or OCX file and then try again.
I did a lot of googleing and talked with microsoft support and nothing helped. So im hopeing someone can help me out here. Thanks in advance :)
PS: My PC is "Windows 10 pro" 64 bit. If it matters.
SQLite is an embedded database; it does not run as a separate server process, but is a library that is usually compiled directly into the application itself.
Running the sqlite3 command-line shell does not make sense, because the version of the SQLite library compiled into that is not necessarily related to the version compiled into the Ruby gem. The guide you linked to is wrong; just ignore that point.
(But if you want to test SQL queries outside of Ruby, there's nothing wrong with installing and running sqlite3.exe.)
You do not need to install the DLL manually; any program that needed it would already ship with it.
For how to test the SQLite Ruby gem, see the sqlite3-ruby documentation.
Guide of what a path is and how to add stuff to it it. You may also want to consider using PostgreSQL as many members of the community prefer it over the packaged sqlite3.
These guys are also right about Ruby development kind of sucking on non-Unix systems though so if you plan on getting into this you might want to consider dual booting a Linux OS for development. You'll probably save yourself a lot of bugs.

Installing Ruby 1.8.7 (and other stuff) manually

I don't want to rely on the one-click installer any more, and I want to learn how to install Ruby manually. Is there a resource for this?
Download the Windows binaries for Ruby 1.8.7 here: http://www.ruby-lang.org/en/downloads/. Extract that to wherever you would like; I use C:\ruby. Then put C:\ruby\bin in your PATH environment variable.
Download the zlib package: http://www.zlib.net/zlib123-dll.zip and extract the zlib1.dll, rename it to zlib.dll and move it into your Windows\System32.
Download the iconv package: http://sourceforge.net/project/showfiles.php?group_id=25167&package_id=51458. Find and extract the iconv.dll file into your Windows\System32.
Download the rubygems package and follow the instructions, basically extracting the package and running ruby setup.rb.
Verify that everything works properly by trying a gem install rails, once that installs then do: rails test_project
Well, if you're on a Mac I'd recommend MacPorts. There's a good post on it here that's still valid.
If you're on Windows and don't want to use the one-click installer you can install Cygwin and build ruby through it. Here's a post I found.
I'd start with the one-click installer, probably by taking a good look inside the source on RubyForge (disclaimer, I haven't actually done this...). These guys clearly know how to build Ruby on Windows from source, so I'd be inclined to see how they did it.
Beyond that, did you know you can download the 1.8.7 Windows binary from the ruby-lang.org downloads page? That page also has the current stable 1.8.7 source
You might also need libeay32.dll and ssleay32.dll, found in OpenSSL: http://www.slproweb.com/products/Win32OpenSSL.html
I've pretty much concluded that Ruby 1.8.7 just isn't stable yet for Windows. I was able to get it running on one Vista machine following the instructions above but not my laptop.
For the laptop I followed the following steps and everything seems to be working so far:
Install 1.8.6 using the 1-click
installer. Let it delete old copies
of Ruby if necessary.
Install gems 1.3.4
gem install rails
ruby script\console
point browser to http://localhost:3000/. Make sure everything works as expected
stop console
extract 1.8.7 zip file into the Ruby 1.8.6 directory
copy dll files discussed above into the ruby/bin directory
restart console and again check http://localhost:3000/
I would only follow these directions as a last resort if the instructions above don't work.
Before you wag a finger at me and scold me for this approach...
please consider that I spent ~8 hours reading and trying everything possible and was able to use the approach above successfully on another computer. I'm open to other suggestions!
If you are looking for a place to get all those DLL files - here is a trick: If you install the Ruby one-click-installer for Ruby 1.8.6, it has all of those DLL files in C:\ruby1.8.6\bin (assuming you installed it there).
I was playing with the PIK gem (rvm for Windows) and ran into that problem for Ruby 1.9.1 and after copying those DLL files everything worked perfectly.
Of course, those DLL files are somewhat old, so if Ruby 1.9.1 or 1.8.7 relies on any new features in those DLL files there might be a potential for a bug, but I haven't noticed anything so far and it beats hunting down them on the Internet.

Resources