Skip to content
dredknight edited this page Nov 4, 2020 · 3 revisions

Shoes 3.2 has many features for handling ruby Gems, all of them confusing. Which is why I created Cobbler. To help you deal with gems. Please see [http://walkabout.mvmanila.com/2014/05/26/this-is-why-shoes-3-2-exists/]

Shoes 3.2 (reluctantly) includes two gems that you can 'require', sqlite3 which is a 'light' SQL database and hpricot which is an HTML/XML parser and jquery thing-a-ma-jig thingy. Can you detect my love for these bastard step children? No? But, historical purposes does prevail and so they come with Shoes 3.2.15. because there might be some Shoes script out there that needs them. (cough Hackety Hack).

Shoes has it's own gem directory ($HOME/.shoes/+gems) and there is a way tell Shoes to check for and install gems to there. Shoes.setup takes a block that only allows require commands inside. It never worked well and grinds the nerves of some people (aka me). See samples/simple-gems.rb and samples/simple-sqlite.rb, for an examples of how to includes gems from the internet into your Shoes program. There's a problem, though: Not all gems will work on all platforms for all versions of Shoes.

There are 3 kinds of gems that you might encounter: Pure Ruby, source code and binary. Gems that only use Ruby are easily installed by Shoes. What some of us call source are really gems that have C source code that has to be compiled when installed - That's a pain for Windows and OSX folks who don't have the development tool. Recently, there are gems available that actually have the C source precompiled (usually for Windows but only the MingW ones can possibly work with Shoes). So, if you arer running Windows and your Gem installs with Shoes.setup, take a few moments to acknowledge how lucky you are.

In Federales (shoes 3.2) there is a way (or two or three and a half) to get out of the Shoes Sandbox. Tight Shoes is a downloaded Shoes. Loose Shoes is one you built from source. Different rules. For Tight Shoes, You can add a directory (or more) to the list of directories that Shoes's Ruby will search through to find gems. If you already have a Ruby and gems installed on your system, then you just tell Shoes where those gems are. I call it a Jailbreak. There's a Cobbler option to do that for you. Just like breaking out a real jail, you can get in deep do-do and it's up to you to see the problems and fix it. No big deal if you know what your're doing. You'll avoid a lot of trouble if you install the exact Ruby that Shoes is using. If it's 2.1.0 in Shoes then that what you want to use to install gems. If Shoes is 2.1.2, install that Ruby and then you can use that ruby gem install from the commandline. It's all up to you to manage the versions and directories. Consider yourself empowered. Avoid evil.

Loose Shoes (that you built from Shoes source) already uses your installed gems and ruby. It's intimately tied to them. There is not a copy of Ruby inside a Loose Shoes it uses what ever Ruby it was built with. You can package a script with Loose Shoes for Linux, OSX and Windows. What you can't do with Loose Shoes is make an Shoes installer. (rake package). If you're confused about that restriction, think about how a linking loader works - repeat until the light bulb goes off.

No Shoes. be they Loose or Tight will package up the gems your script needs. It would be one cool enhancement if they did and I can think of ways to do it but it probably wouldn't work for Windows. Shoes.setup does work if the gems are available and installable)

[Update 2015-05-14] That last paragraph is not current with Shoes 3.2.23. It is possible to distribute pre-built binary gems (all platforms) if and only If you can build them (somewhere). This violates almost everything done in the last few years to complexify ruby gems.

Nokogiri is a fine example (it's now included with Shoes so our process can work). If you can navigate the nokogiri build process, you can create a nokogiri precompiled binary gem - For Windows and just Windows and it's a huge gem, larded up with things Shoes doesn't need or could use. Precompiled for OSX ? No. Linux binaries? No. ARM ? No. MIPS? All possible but why bother if you believe everybody has Ruby and Dev tools installed? A perfectly reasonable assumption for Ruby Gem writers. Nokogiri also requires building the Windows code on Linux or OSX - won't do it on Windows. Their rake compiler process is conflicts with how Shoes is built - not that Shoes couldn't be fixed but it's a lot to swallow and get nothing Shoes useful for the effort.

Its possible to install gems from files in Windows by command line through executing cshoes. It is advisable to launch CMD with administrator rights as with Windows 10 you never know when access to file will not be possible. C:\Program Files (x86)\Shoes\cshoes --gem install 'C:\Program Files (x86)\Shoes\rubyzip-1.3.0.gem'

Clone this wiki locally