alfred-hoogle-workflow
alfred-hoogle-workflow copied to clipboard
Include `rubygems`
Hi,
thanks for the workflow, it's greatly appreciated. I had a little trouble to get it working though. Turns out that I first had to manually do a gem install --user-install json
in order to fetch the corresponding json gem, and then also include require 'rubygems'
prior to the line that requires json in script.rb
.
Thanks, Alexander
Hi Alexander,
thanks for reporting this bug.
Could you also tell me what is the Ruby version on your machine? What version of OSX are using?
Thank you.
Hi Carlos,
that machine runs ruby 1.8.7 on OS X 10.8.5. I'm using the default version of ruby that ships with OS X (it's probably really outdated, right?).
Thanks, Alexander
Same problem with Ruby 2.0 on Mountain Lion:
➜ ~ uname -a
Darwin marbook 12.5.0 Darwin Kernel Version 12.5.0: Sun Sep 29 13:33:47 PDT 2013; root:xnu-2050.48.12~1/RELEASE_X86_64 x86_64
➜ ~ ruby --version
ruby 2.0.0p0 (2013-02-24 revision 39474) [x86_64-darwin12.5.0]
Alfred debug mode reveals
[ERROR: alfred.workflow.input.scriptfilter] Code 1: script.rb:2:in `require': no such file to load -- json (LoadError)
from script.rb:2
@afwlehmann yeah, but that's apple's fault which they fixed on mavericks, I think.
@mbenke woah, that's strange because the json
library should've been on ruby 2.0.
but anyway guys, I will look for the best option to fix this and I will let you know of any progress I make.
thanks for reporting.
Perhaps it would be sufficient to include a line in the "Installation" section of the docs that says that this may be a problem due to Apple's defaults and how to fix it, e.g. gem install --user-install json
.
I may be wrong but I think that there's many people who have no clue about ruby (actually, I haven't any idea myself and I had to google about gem, try stuff and so on). Including the line require 'rubygems'
in the source shouldn't cause problems (or should it? Ruby-wise?), and hinting potential OS X users at gem might also suffice, hence saving you the trouble of finding another solution :-)
Many thanks for looking into this matter! I've used the workflow a couple of times yesterday and like it quite much.
@carlosgaldino so it seems my problem was that /usr/bin/ruby was 1.8.7 while /usr/local/bin/ruby was 2.0. Alfred seems to insist on using /usr/bin/ruby even if it's absent. Linking /usr/local/bin/ruby -> /usr/bin/ruby fixed my problem (uncovering other problems that I report separately).
@marcin: This could maybe be solved by prefexing the file with a she-bang like "#!/usr/bin/env ruby" and calling that script as a bash executable instead of calling ruby explicitly from within the workflow. However, OS X is kind of troublesome in this regard, as applications do not automatically inherit the PATH from your environment variable. There's a lot of ways to do work around this. Linking might prove problematic once a system update overwrites the link (should Apple ever decide to update ruby ;-)).
On 19.04.2014, at 10:18, Marcin Benke [email protected] wrote:
@carlosgaldino so it seems my problem was that /usr/bin/ruby was 1.8.7 while /usr/local/bin/ruby was 2.0. Alfred seems to insist on using /usr/bin/ruby even if it's absent. Linking /usr/local/bin/ruby -> /usr/bin/ruby fixed my problem (uncovering other problems that I report separately).
— Reply to this email directly or view it on GitHub.