Distributing ruby application as standalone in linux and windows - ruby

I have developed ruby application (desktop application) on version 1.9.1 with few gems(qtbindings). Now i would like to distribute my application to users as stand alone.I would like to distribute my application as stand alone in linux too. What is the best gem/script for doing this job.

Have a look at this link where several options are offered to distribute a Ruby script as a "native" executable.
Keep in mind that Linux users usually do not need this, bundle install and ruby myscript.rb is enough on those systems.

First define "stand alone," please. If you mean "I assume that you will have a suitable Ruby interpreter installed and on the PATH" then on Linux and other Unix-alikes it should suffice to add a shebang line at the top:
#! /bin/env ruby
and set the executable bits in the permission mask.
If you mean that your users may not have Ruby installed, and you don't want to make it a prerequisite, that's a much taller order and I have no advice.

Related

Python3 segfaults on OSX, works on Linux and windoze, tk libraries issue perhaps

I'm fairly experienced in Python, but a total noob on OSX. I've been using it for a couple of years on windoze then linux OK. Unfortunately I now need to port stuff to an iMac with El Capitain 10.11.3.
I checked out the guides before I tried to install it, in particular the issues around the versions of the tk/tcl libraries. I therefore visited ActiveState, and installed the latest version, then python 3.5.1. This is something that I have never done with 'doze or 'nux.
Simple text programs run OK, whether from IDLE/run, python3 progname, or shebang. The following simple tki program also runs OK, also from those three launch methods.
#! /Library/Frameworks/Python.framework/Versions/3.5/bin/python3
import tkinter as tki
def cmd():
print('doing command')
exit()
root = tki.Tk()
but = tki.Button(root, text='hello', command=cmd)
but.grid()
root.mainloop()
But when I try to run a sizeable tki based app, it complains that it has found classes TKApplication, TKMenu, TKContentView and TKWindow in both /Library/Frameworks/... which is where python is installed, and /System/Library/Frameworks/... which is presumably where the tcl/tk install from ActiveState went. It then exits with a segfault 11. The app is basically low level tk stuff, just a lot of it. Both locations include /Versions/8.5/ in the name.
I suspect the key is that it says which one of each of those TKxx will be used is undefined. Perhaps it's picking a mix of those, and so when they go to talk to each other, they are not in predictable locations.
Is this what's happening? Why does the simple tk app work but not the complex one, is it the size, or the need to use several classes from different libraries?
As there seems to be a set of tk libraries in the python tree, I'm inclined to remove the ActiveState ones. Is this sensible? How do I do this (Mac noob alert)!
I don't seem to be able to find a definitive 'how to' install python 3 on OSX. Not found too much specifically for 10.11.3, could this OSX version need a different procedure?

Identify what terminal a ruby script is running in

I'm creating a gem that utilizes SGR codes. There are discrepancies between terminals that I've found myself. E.g. \e[2m makes faint text in Ubuntu's gnome terminal, but \e[2m does nothing in Windows 8.1's Command Prompt With Ruby. So my ruby program needs to know what terminal it is running in and from there, utilize (or not utilize) certain sgr codes.
Is there a magic bullet, in pure ruby or hopefully with a gem, for finding out what terminal we're running in? And I mean any terminal, no matter how exotic. I'd love be able to do this, depending on the terminal we're running my gem in (This is pseudo-code, MagicBullet is a class belonging to the gem I'm hoping you'll refer me to):
MagicBullet.identify #=> ['gnome-terminal', '6.3.2']
Or:
MagicBullet.identify #=> ['konsole', '4.5']
Or:
MagicBullet.identify #=> ['command-prompt', '13.37']
Or:
MagicBullet.identify #=> ['NeWT', '15.2']
Is there a a sure-fire way to find out regardless of OS...this information feels so readily available...maybe a gem that looks for a range of OS signals/processes that belong to a list of known terminals, something like that. I've tried ENV['TERM'], and while that returns :xterm in a gnome-terminal, I'd prefer it to return :gnome-terminal. In Command Prompt With Ruby it returns nil, which isn't very helpful considering all non-linux (I think) terminals will return nil. Of course, I could run if !ENV['TERM'] and then utilize a different set of logic to find the terminal's name, but that doesn't feel "sure fire" to me. It'll probably fail with other "exotic" terminals.
So I'd like, as an answer, either:
A gem that gives a sure-fire way to identify what terminal and what version we're running
A pure ruby way to give a sure-fire way to identify what terminal and what version we're running
An algorithm that gives me a pretty good shot at identifying what terminal and version we're running, and I'm talking all flavors of Linux, Sun Microsystems stuff, Apple's operating systems (Terminal and the third-party iTerm are two terminals for Apple's operating systems for example). Anything that MRI can be installed on.

alternative bash for windows / or help on cygwin with specific tasks

my goal: to create a suite of scripts that do some common system tasks, which include these
copy/move/list/search/grep files
watch/start/stop processes
run queries against Oracle via sqlplus
i grew accustomed to using Cygwin/bash to ease my life at work, and frankly speaking, i don't want to move away from bash language and start learning PowerShell, for example - so i started searching for a way to run bash scripts on Windows, ... preferably something alternative to Cygwin.
the truth is that i am still not pleased with Cygwin installation, and the fact that there is no simple way around it, that it is targeting more or less expert users, and there are a number of things that might pop up during the installation. i mean. what i am trying to do now is to write a suite of scripts that will target someone less expert than me (and i am in no way a real expert) - in most cases some kind of an administrator who doesn't want to know the script details.
i am thinking that this user will also want to be able to run these scripts on another machine, and i want to be able to explain him/her how to do it, without just saying, call the support, and, me, eventually (so that we can install cygwin on another machine etc etc.)
i tried MinGW(msys) but it also needs manual steps to set things up - i mean, these manual steps have become something of a de facto standard in these Windows ports (sorry, maybe i have a mood for bragging). win-bash looked like it could be a solution, but i ended up trashing it too, because of the old bash version, and its inability to do things i was able to do in cygwin - specifically
here documents
things like "cmd /C dir *" (don't know why) - and yes, i do cmd /C dir in cases i am in some kind of shared network folder with thousands of files, and ls is significantly slower than dir
my questions at last:
am i doomed to use PowerShell? i guess i will, reluctantly, if i have to
is there a simple pre-packaged "slim" cygwin installation.. or, portable cygwin, even better? there is a cygwin-portable project on sourceforge, but it's not that doesn't need those manual steps, again, apparently - is there a way to automate those steps, perhaps? and if there is, i wonder why somebody hasn't done it already? - and then, would it be possible to call bash scripts from Windows command prompt using a simple command like "bash somescript.sh"?
thanks for your attention.
As mentioned here, the Cygwin installation can totally be scripted and parametrized to ran in a silently and automatic mode.
If you define the minimal list of cygwin packages you need, just use a little .bat script that call the cygmin setup executable like this
setup.exe --packages=list_of_packages_you_need --quiet-mode
If you wrap the cygwin install process, it should be tolerable for a less technical user.
The cygwin install can be streamlined using command-line args;
http://sources.redhat.com/ml/cygwin-apps/2003-03/msg00526.html
You can also automate the install of most cygwin packages through cyg-apt.
I haven't verified this but I suspect that msys implements a *nix look alike by creating windows executable versions of system commands. All of the common commands have an executable on my install of msys. If that is true then it should be possible to use them separate from a complete install.
Try copying "bash.exe", "cp.exe", etc. from the msys bin directory to a machine/vm that does not have an msys install and see if it works. You may need to copy some dll's or shared libraries as well. A windows dependency checker program would show which dll's an executable is using.
You could package up the stuff you use and make a simple installer or just copy the files with your scripts.
Take a look at MKS Toolkit. Unlike Cygwin, it can live within the Windows world. Files end in CR/LF like Windows files, and you don't have that /cygdrive/c stuff. Naked drive letters work fine in MKS Toolkit.
A few caveats:
I haven't used MKS Toolkit in a long time. See following reason.
MKS Toolkit is (sit down for this) $600 per license. Ouch! That's why I use Cygwin even though I don't think it's as good or works as well.
It's Kornshell based and not Bash (although this may be a bit different). Kornshell and BASH are 95% alike. However, that last 5% gets you. I actually like Kornshell better than BASH in many respects. Kornshell has the print statement which is way superior than the echo statement. Variable names don't disappear in blocks. You can easily do double loops because almost all the commands can take unit numbers of input and output. However, Kornshell doesn't have those neat escape characters in the prompt, and it's hard to find the exit status of a command in the middle of the pipeline.

Ruby compiler for mac?

so I made a program in ruby (using FXRuby as well if that changes anything) and I was wondering how I would compile it so that another person could download and use the program? Thanks
You don't need to compile it you can just run it as a ruby script,
start your file with #!/path/to/your/ruby/interpreter/bin
after changing it to the appropriate file and it should just launch from the command line
$ chmod +x ./my_ruby_script
$ ./my_ruby_script
However if you are devloping a full fledged application in ruby for the mac then consider using MacRuby which provides ruby-cocoa bridge. It can be found here
Ruby is interpreted, not compiled. The code itself will be what runs on another person's computer, provided they have a Ruby interpreter.
A quick Google search, however, turned up this. I've never used it, but it's an interesting idea. Basically it wraps the Ruby application code with the executable(s) and library(s) needed to run it into one single all-encompassing application.

Installing a perl application along with the supporting modules onto a Windows PC that doesn't have a compiler

I'm building a perl application that interacts with a PostgreSQL database via the DBD::Pg module, and that uses Perl/Tk for it's GUI. It works fairly well on my system, but I'm designing it for a family member to use for their business. They don't have a c++ compiler and don't have a clue what CPAN is. The goal is to not bog them down by having to load a c++ compiler and go to all of the trouble of building a module from source if I can avoid it.
I need to get the Tk module installed onto their computer along with Strawberry Perl (it includes DBD:Pg right out of the box). How do I go about including this module along with my application in order to make things easier on for my end user? Would simply copying my entire C:\strawberry\perl\site\lib\Tk folder into their computer during setup do the trick or does perl need more than that in order to use Tk and be happy with it?
Thanks for the help!
One way is to convert your application to an executable, using tools like perlapp, perl2exe, or par. If not, i think you can try Strawberry Perl portable versions.
You can use PAR::Packer module.
it generates exe on windows with a simple shell command.
> pp -o test.exe test.pl

Resources