How to distribute frozen binary gems with Ruby application (not Rails) - ruby

I wrote a bunch of Ruby scripts that integrate different tools to create a "workflow for academics". A number of my friends have been very interested in trying this out, however they are held back by how hard it is to install or replicate my environment.
Although Ruby comes built-in with Mac OSX (the applications I integrate are all Mac applications, so unfortunately the solution can only work on Mac), I use a few binary gems, including Appscript (bridge to AppleScript). The problem is that this requires XCode, which my non-programmer friends do not have installed (and it seems a bit demanding to ask them to install 3GB of software to run a few kbs of code).
I tried freezing the gems by installing them with gem -i, into a subdirectory of the source (on github), and tried removing my entire central gems directory on my local computer - it worked fine, the scripts still ran, etc. However, when my friends tried running the scripts, they got error messages about missing library files etc.
So my two questions are:
* how specific are compiled binary gems? will they work on other Mac OSX versions? with other versions of Ruby? etc
* how can I find out exactly which binary files (located in central locations) a Ruby gem depends on, and package this with the source (and how do I tell the gem where to find these files in non-standard locations)
I know this might not be "standard procedure", and I should just package it as a gem and let my friends deal with the problems etc - but I'd really like to solve this, and I am sure there must be some way of doing this?
Thanks a lot

In my experience, compiled gems are not portable. They're dependent on the exact version of ruby and whatever other libraries they use. A better solution would be to have your friends install the "Command Line Tools" version of Xcode -- it's only 100-150 MB and includes everything you need to build gems (and other software). You'll need a (free) Apple Developer ID to download it though.
https://developer.apple.com/downloads?q=Command%20Line%20Tools

Related

How to install Haskell on Mac

I am trying to install Haskell on Mac, and doing it as instructed on Haskell site Haskell site.
When I run the script from above website on terminal, it says to install "ghcup", "ghc" and "cabal". However, it seems that it installs "ghcup" successfully, but an error occurs when it comes to install "ghc".
Error: ghc: unknown version :lion
how can I fix this? or, is there another way to install Haskell on Mac?
(I saw similar posts but they are too old)
You seem to be running macOS Lion, which is ancient, insecure, and no longer supported by Apple. As such, most modern software isn't tested for compatibility with it anymore, and a lot of it won't work. Upgrading to a modern version of macOS such as Catalina will make it work.
There are different options to get a working Haskell development environment on your Mac. The most popular seem to be
Haskell Platform
Install via homebrew
The Haskell Tool Stack
Of course, you can also install most tools individually by hand or compile everything from source.
Together with the type of installation, you need to choose how to build your projects: Using Cabal or Stack.
My personal preferences as a beginner is Stack, because (a) the entire Haskell tool stack is installed locally for each project, so you don't get into problems with conflicting versions of certain tools; (b) dependencies are curated, such that you do not need to deal with incompatible versions of libraries. From a beginner's perspective, it is very helpful that I can focus on actual development work and less on infrastructure and tooling.

I need a way to run Haskell code without any install on a Mac

I enjoy developing in Haskell, but am presently confronted with a challenge. At my place of education, I don't have administrative rights on my account. I want to debug/test while there. I need a way to run Haskell code without installing haskell-platform or ghci or anything else requiring of an administrative level of privilege. For instance, a web site which will run haskell code (abeit limited to not include file access of course) or a java utility (or standalone .app, though java is preferred due to the nature of the "parental controls"), or something else I haven't thought of. Source or compiled Java, Flash, and source code in Ruby or Python are preferred to native code. This is on Mac OS X 10.6, for reference.
You can install GHC without admin privileges, but you'll have to build from source. Check out the Building on MacOS X for more details.
Essentially, like any other open-source project, you can compile code and install it, generally, anywhere on your filesystem like into a folder in your home folder (I often use the ~/.local folder for that purpose).
As the linked page mentions, you can also use MacPorts and install it to any place you can write to. Once MacPorts is installed you can install GHC.
EDIT
As pointed out by Carl in the comments below, you don't need to build from source. Just grab the binary tarball from http://www.haskell.org/ghc/download_ghc_7_4_1#binaries.
In addition to all the other ideas, several companies will rent you virtual (cloud) linux servers for a few cents an hour. You have root on those and can install whatever you want, then freeze the image until you need it again.
Normally this might not be advantageous over a local solution if you can make one work, but a possible extra benefit would be that your work can stay on a single "computer" which you could access while sitting in front of any variety of modern PC that might be available to you on a given day.
An alternative not only for Haskell is http://ideone.com/
For the website option, TryHaskell will hardly cut it, it's way to limited.
codepad, OTOH, is more liberal, and should be of more use.
But honestly the bindist option is the best one, clearly!
If you truly can't install anything, then there's
http://tryhaskell.org/ -- like GHCi, but you can't load modules, which means not only that you can't use many standard functions (say, the functions in Data.List), but also that you can't use certain language features (like user-defined algebraic data types).
I also remember a hpaste-style site which executes its code -- and allows you to have private pastes -- but I can't remember it at the moment. Edit: I was thinking of http://codepad.org/ -- thanks #Mog
Try http://hiji.tinyrocket.se/ It is a haskell interpreter written using javascript.
http://ghc.io/ GHC.IO is a version of the Haskell interactive interpreter, ghci, that runs online in a web browser.
You just need to install homebrew, which you can do without root rights if you do so in your home directory. You can then brew install cabal-install
which will automatically install cabal and ghc, or brew install stack to install stack.
There is a web-based interpreter for Haskell at http://tryhaskell.org/. However, it may not provide enough functionality for your requirements.

How can I create debian package (*.deb) from ruby application written with qt4?

I found a lot of tutorials how to build application with Ruby and Qt, but i have no idea how anybody else will be able to run it! I am using Ubuntu 11.10, ruby 1.9.2 with rvm and:
rbqtapi -v output "QtRuby 2.0.5 using Qt-4.7.4"
P.S. I have no idea how to build *.deb, it will be my first desktop app, not web.
please have a look on http://shoesrb.com/ this is the best way I heard off for writing GUI apps.
Shoes has now not it's greatest time, but we put our best time to make it better, give it a try and someone will help you.
In case you are in need of assistance just ask as question on #shoes IRC channel on freenode servers.
If you're sold on QT, then you will need your users to install all the support libraries for QT (and anything else), then you can upload a rubygem to rubygems.org for your users to download.
Once, they've installed the support libraries, you'd only need to update your rubygem, which is fairly quick and easy for updates.
You may also wan to look at visualruby. It uses GTK. Then you'd install the GTK libraries instead of the QT ones.
http://www.visualruby.net
As far as .deb packages go, I tried to research the same thing with little success. The rubygems packaging system is designed to distribute ruby programs, so it is the best way to go. Also, you'll need to install different support libraries for different platforms. If you look at visualruby's install page, you can see how to install GTK for Linux and Windows.
Good Luck.

What are the pros and cons of building from source versus installing from a Disk Image on OS X?

What are the pros and cons of installing things like Python and Git from source instead of simply using the community provided Disk Image on OS X?
Dan Benjamin has an article about "Using /usr/local". However, given that the Git DMG installs into /usr/local/git and the Python DMG installs as a Framework, I'm not sure that the advantages Dan lists for building from source aren't still gained via a DMG install in these cases.
Obviously, one pro of using a Disk Image is that it's much simpler. However, are they tradeoffs that make it worth building from source?
There are two separate questions here: should add-on software you install go in /usr or /usr/local (short answer: it should go in /usr/local for the reasons Dan Benjamin gives), and should you install add-on software from a provided installer (disk image) or by building it yourself (short answer: whatever works best for you, but either way it should go in /usr/local).
I'll take Python as an example. OS X v10.6.6 includes python v2.6.1 in /usr/bin, with its frameworks in /System/Library/Frameworks. If you download an installer for a newer version (currently installers for v2.7.1 and v3.1.3 are available), it'll put the new version in /usr/local/bin, and its frameworks in /Library/Frameworks (/Library has roughly the same relation to /System/Library that /usr/local has to /usr), which is exactly what you want. If your paths are set properly, you'll use the newer version automatically. OTOH system scripts that may not be compatible with, say, Python v3 should start with #!/usr/bin/python, and keep using the old (standard) version. Furthermore, when OS X v10.6.7 ships and includes a relinked version of Python v2.6.1, it won't step on the update you installed.
If you were to build a newer version of Python yourself, you should do it just like the installer does: put the binary in /usr/local/bin and the frameworks in /Library/Frameworks, for exactly the same reasons. If you aren't sure how to do this, you should probably stick to the installer -- at least for major projects like Python and Git, there are likely to be smart people involved who know how to get this sort of thing right.

mingw32 Ruby Installer for Windows

How good is the new Ruby Installer for Windows?
I asked before about why Ruby was so slow on windows and now I've seen some impressive benchmarks showing marked speed improvements with the minGW compilation used in the new installers and am curious how it has worked for people who have tried it?
How many gems are broken for this version? Any big ones you have been bit by not on this list?
I've played with it a fair bit. It's definitely faster, both because of the new YARV VM in 1.9.1, and the use of a C compiler created sometime this century.
Pure Ruby gems are pretty reliable, obviously. Getting mswin32 binaries to work is a hit/miss situation (mostly miss IMHO), and native mingw32 binaries are still the exception, not the rule.
I wanted FXRuby on Windows, and went through the following to get it: Getting FXRuby Going with Ruby 1.9.1 and the new RubyInstaller
So it depends what gems you care about and how handy you are with build scripts and such. Despite the heroic efforts of Louis Lavena and the Ruby Installer contributors, Ruby on Windows remains a second-class citizen.
As you've already noticed, the RubyInstaller guys maintain a list of gems known to work, or not, but this is pretty fluid. The mailing list is usually pretty responsive to questions as well.
It's quite a bit faster, the exact experience varying according to your application. For low-volume Rails stuff, for example, I think you would probably not notice much: database access doesn't really change, for example.
Easiest thing is to try it. If you save your ruby\bin and ruby\lib directories first, you can install over your existing Ruby and be able to switch between the two. I think only those two directories are affected - it seems to work for me at least.
Once you have an installed mingw32 instance, start with the gem installs. The ones that have compiled components will hopefully already have mingw32 versions. Failing that, you could try modifying with the mswin32 versions from your "old" lib - I haven't done this myself and have only the vaguest memory of reading something that suggested it may work...
At the bare minimum, the mingw32 binaries run fine. If you start installing some esoteric gems, you might get some install failures. I highly recommend using Ruby on Linux or Mac, everything works better on those platforms. You will actually be spending time writing Ruby code instead of yak shaving your way to get gems to configure and build properly. I am writing this based on installing Ruby 1.9.1 mingw bins. The 1.8 version might be more stable. The msvc Ruby 1.9.1 binaries have their own separate set of issues, mostly run time ones.

Resources