fbarros Posted October 31, 2013 Share Posted October 31, 2013 It can also be because of the way the developer packages any needed gem Link to comment
ClintonStrong Posted November 1, 2013 Share Posted November 1, 2013 I'm becoming less convinced that this is a Ruby problem at all, but an Alfred / Mavericks problem. If I run my Ruby script directly using the same path/command as Alfred it works fine. However, from Alfred it immediately fails silently as described earlier in this thread. If I go one step further and modify the workflow itself, for instance flip it to try and run the Ruby script with Python, I see exactly the same behaviour, and still nothing in the logs. It seems that Alfred is immediately failing the execution of the script and not logging anything to the Alfred-Workflow.log. It looks like it's an encoding issue. When I ran your workflow in Alfred, it output this error message: plist-3.1.0/lib/plist/parser.rb:91:in `scan': invalid byte sequence in US-ASCII (ArgumentError) from plist-3.1.0/lib/plist/parser.rb:91:in `parse' from plist-3.1.0/lib/plist/parser.rb:29:in `parse_xml' from alfred-workflow-1.11.1/lib/alfred.rb:122:in `info_plist' from alfred-workflow-1.11.1/lib/alfred.rb:127:in `bundle_id' from alfred-workflow-1.11.1/lib/alfred.rb:100:in `ui' from alfred-workflow-1.11.1/lib/alfred.rb:47:in `rescue in with_friendly_error' from alfred-workflow-1.11.1/lib/alfred.rb:28:in `with_friendly_error' from ./search.rb:62:in `<main>' I did some further testing and it looks like the external encoding of Ruby is set to US-ASCII when run in Alfred, while it's normally set to UTF-8 when a script is run elsewhere. Looks like this is why it works in the Terminal but errors out in Alfred. You can manually set the external encoding to UTF-8 by adding the following line of code at the top of your Ruby file: Encoding::default_external = Encoding::UTF_8 if defined? Encoding That seems to fix the issues on my system anyway. Hope that helps. Link to comment
neilmiddleton Posted November 1, 2013 Share Posted November 1, 2013 (edited) Can I confirm that this is the only change that you made to the workflow? I just did a fresh install of it from https://github.com/neilmiddleton/alfred-devcenter-search/raw/master/Heroku%20DevCenter%20Search.alfredworkflow and made that one change, but no cigar. Edited November 1, 2013 by neilmiddleton Link to comment
ClintonStrong Posted November 1, 2013 Share Posted November 1, 2013 Can I confirm that this is the only change that you made to the workflow? I just did a fresh install of it from https://github.com/neilmiddleton/alfred-devcenter-search/raw/master/Heroku%20DevCenter%20Search.alfredworkflow and made that one change, but no cigar. Ah yeah, that download doesn't seem to have the Ruby 2.0.0 versions of the gems bundled with it. When I cloned the repository into Alfred it worked fine. Link to comment
neilmiddleton Posted November 1, 2013 Share Posted November 1, 2013 Got it now, thanks. So, for posterity, there's two things here. Firstly you need to include the Ruby 2.0.0 gems as well as 1.8 for pre-mavericks installs, and then you need to respect the different encoding that Alfred seems to run with Ruby scripts (as per Clinton's response). Link to comment
ClintonStrong Posted November 1, 2013 Share Posted November 1, 2013 Got it now, thanks. So, for posterity, there's two things here. Firstly you need to include the Ruby 2.0.0 gems as well as 1.8 for pre-mavericks installs, and then you need to respect the different encoding that Alfred seems to run with Ruby scripts (as per Clinton's response). I suppose there is another option: you could just force your workflow to run on Ruby 1.8.7. Mavericks comes with both 1.8.7 and 2.0.0 installed, you just have to point it to the full path for 1.8.7. /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby That should work with older installs of OS X as well. Just throwing that out there. Link to comment
jdfwarrior Posted November 2, 2013 Share Posted November 2, 2013 I suppose there is another option: you could just force your workflow to run on Ruby 1.8.7. Mavericks comes with both 1.8.7 and 2.0.0 installed, you just have to point it to the full path for 1.8.7. /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby That should work with older installs of OS X as well. Just throwing that out there. Thanks for helping run this to ground Clinton marikbane 1 Link to comment
sphardy Posted November 5, 2013 Share Posted November 5, 2013 FYI: I have a markdown ruby script I run via Alfred - actually a bash script in alfred that just passes selected text to the ruby script. That too was failing since upgrading to Mavericks with the raw ruby script just generating errors. Updating the script to specifically call Ruby 1.8 as Clinton suggests immediately fixed the issue. Link to comment
marikbane Posted November 7, 2013 Share Posted November 7, 2013 I guess we can say that a simple sudo ln -s /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby /usr/bin/ruby will help most Mavericks users to keep using their SL/ML workflows, right? Link to comment
neilmiddleton Posted November 7, 2013 Share Posted November 7, 2013 I guess we can say that a simple sudo ln -s /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby /usr/bin/ruby will help most Mavericks users to keep using their SL/ML workflows, right? And cause untold issues for anyone doing anything else with Ruby. Link to comment
marikbane Posted November 7, 2013 Share Posted November 7, 2013 And cause untold issues for anyone doing anything else with Ruby. I see.. I am not a ruby user and have very little understanding of the "programming" part of the workflows, so may i ask how one can modify a workflow so that the workflow itself calls the older version of ruby and not the whole system? If its a 2-3 lines answer that is and doesn't require reading like 10+ pdf's about programming workflows/ruby Link to comment
jdfwarrior Posted November 7, 2013 Share Posted November 7, 2013 I see.. I am not a ruby user and have very little understanding of the "programming" part of the workflows, so may i ask how one can modify a workflow so that the workflow itself calls the older version of ruby and not the whole system? If its a 2-3 lines answer that is and doesn't require reading like 10+ pdf's about programming workflows/ruby I think you kinda already have the answer. What you would do is, instead of letting the workflow use /usr/bin/ruby, which is not the desired version, move all the ruby code to a file, leave the language as /usr/bin/bash, and execute the file with the desired version of ruby (unless ruby has some method for specifying the version to run as?). So, as a bash command do.. /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby <file.rb> Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now