Using JRuby+Sikuli on Windows - ruby

This video shows JRuby+Sikuli working on Windows 7 or higher. There we have to require "java"; require "sikuli".
So I've installed SikuliX using sikuli-setup.jar and did some practice in Sikuli IDE.
However the \jruby-1.7.15\bin\gem install java gives java requires Ruby version >= 2.1.0., since the latest JRuby installer is jruby 1.7.15 (1.9.3p392), so I had to ... install-fjava.
Then I had to manually set ENV variable SIKULI_HOME, but now I have this error:
irb> require "sikuli"
LoadError: Failed to load 'C:\Users\admin\Downloads\nakilon\sikuli/sikuli-script.jar'
Is Sikuli installed?
And yes, I have no sikuli-script.jar in my SikuliX folder.
So what is the proper way to make JRuby+Sikuli[X] to work on Windows 7/8?
UPD:
I just realized, that gem install sikuli installs a 2 years old stuff, that isn't a Sikuli X.
So I did a hack -- renamed sikuli-ide.jar to sikuli-script.jar.
Trying to execute some lines from that video: screen = Sikuli::Screen.new goes fine.
But since script = org.sikuli.script.SikuliScript.new gives:
cannot load Java class org.sikuli.script.SikuliScript
I checked github sources -- there is really no SikuliScript class, so now I'm lost (

Current official JRuby gem way
This question posted as GitHub issue, with solution
Google Drive shared folder with stack of files that seems to work for me
Checksums of files in it:
MD5 (jruby_windows_1_7_15.exe) = 61600abdb47177dc50c4ec887dc6c3f1
MD5 (sikulixsetup-1.1.0-Beta4.jar) = 7b836f4dad2e6817fd599f91cb1b9e7f
MD5 (sikulix-1.1.0.3.gem) = e1083cf09b55c917b62a34cc45cdded0
Google Drive doesn't allow to share .exe, so you'll see only two files.

Related

Can a ruby gem/module be added just like a java jar file?

I use Eclispse Kepler with DLTK plugin for ruby. I am unable to "require" nokogiri module because it cannot be found by eclipse. I tried some gem install command from some website and that did not help. Now, I don't want to use commandline until I first master Ruby programming.
I learned that I can add java jars to my project by creating a lib folder, copying jars to that folder and then adding them all to the build path. So easy, right ?
Can I do the same thing for ruby gems and modules ? Ideally, I'd like to use only the IDE for this instead of using commandline and complext install scripts.
Please help.
If this gem already installed with all dependencies, then you can add it with simple require command:
require "/path_to_gems/gem_name/lib/gem_name"
In my case the command is:
require '/Users/yukke/.rvm/gems/ruby-2.1.1/gems/nokogiri-1.6.1/lib/nokogiri'
Otherwise you can try to require rubygems first:
require "rubygems"
require "gem-name"
I would suggest maybe using a different IDE with better Ruby support, such as Aptana, which is Eclipse-based but has a lot of additional addons to support Ruby development. You can install Ruby gems in it on the start page, or through the integrated terminal.
If you run the command gem which bundler you will see the folder gems are installed on your system.
You can copy executables there but it's highly recommended you use gem install on the command line.
I have find the answer to this question. I not sure if this is the best way to do it, but it works for me. Pro developers, can you please review this answer ? So, for now let me give quick guide for this.
1 - Install Eclipse DLTK plugin for Ruby as suggested here - Preferred Ruby plugin for Eclipse?
See the answer with photo, by James.
2 - Next, lets pick a random gem such as nokogiri and download it from rubygems.org. The file name of the Gem tells you which OS its meant for. I use windows 7 64bits. So, I take version with x64-mingw32. Here is a sample list of downloads:
1.6.4.1 November 7, 2014 java (2.37 MB)
1.6.4.1 November 7, 2014 x64-mingw32 (2.86 MB)
1.6.4.1 November 7, 2014 (8.81 MB)
1.6.4.1 November 7, 2014 x86-mingw32 (3.91 MB)
1.6.4 November 5, 2014 java (2.37 MB)
Show all versions (271 total)
3 - AFAIK, eclipse cannot use the gem file as is. You need to unpack it first. Lets say you kept the gem file in c:\RubyGems\extras, and you want to unpack it there itself.
open windows cmd > cd into the above directory > gem unpack nokogiri-1.6.4.1-x64-mingw32.gem > press enter !!!
Now, your gem will be unpacked into a folder nokogiri-1.6.4.1-x64-mingw32.
4 - Locate the nokogiri.rb file inside the unpacked folder. Its in the lib folder.
Copy the full path of this folder - c:\RubyGems\extras\nokogiri-1.6.4.1-x64-mingw32\lib. We need this for eclipse.
5 - Eclipse > create new ruby project > right click project > build path > configure build path > libraries tab > add external source folder > enter the path from step 4 > Ok > ok. You can now use the gem in your project.
6 - Testing if the steps work. Use the code in your project !
require 'nokogiri'
puts "Chenqui ! It is work!!!"
If the message prints without error, then you are a success ! To see the error you get when the required modules can't be found, add something like this require 'restclient'.

Moving Sinatra from Webrick to a different server on windows - thin installed but can't load eventmachine

I'm building a simple web app on Sinatra that I can deploy like a gem to artifactory; to start with I'm getting everything setup.
Here's what I've done:
I've got the the gemspec done so I can deploy like a gem
I've got sinatra modular set up with a basic 'hello world' page
I've got Rspec setup for testing (hello world test passes)
I've got rake tasks to make things easier (booting up sinatra, building the gem, running tests, etc)
Now I need to move Sinatra from Webrick to somthing a bit more robust and that's this is where I'm hitting a wall.
I've tried Unicorn,thin and Puma but they all won't install and I don't know what to do.
They all fail at Building Native extensions, I don't know what to do.
I'm using windows 8.1 (i'd rather be doing this on ubuntu but the company uses windows and to be honest I like a challenge) ruby 2.1 and I have devkit installed (and it's working now, wouldn't last night).
From what I've read Unicorn won't work on windows so the best bet is to go with thin but that fails with: extconf.rb
checking for main() in -lc... *** extconf.rb failed ***
It mentions that I need the devkit installed (it is the first line is Temporarily enhancing PATH to include DevKit...)
Despite this it fails, I tried doing what I found in this but that didn't help ( Installing event machine didn't do anything).
I'm at a loss of what to do next.
EDIT:
Whilst I've solved the problem of getting Thin to install it now has a differant error
IT can't load eventmachine.
EDIT:
It all comes down to the fact that the Devkit wasn't being recognised or it didn't install properly or something. I wonder why.
I've tried Unicorn,thin and Puma but they all won't install and I don't know what to do. They all fail at Building Native extensions, I don't know what to do.
The reason these are failing is that many ruby gems use native C extensions which expect to be compiled and installed on a linux or unix environment.
Doing any sort of Ruby development work on a Windows machine is an exercise in sadomasochism.
I strongly recommend you install VirtualBox, download an Ubuntu or similar linux virtual machine image, boot it, configure it, and use it as your development webserver. You can continue to edit your code in windows, but you will be running it in a sane environment.
Ultimately, you may have to learn some new skills, but you will save yourself an enormous amount of frustration by moving off windows as your development platform.
I managed to get thin installed but it wasn't easy
I wiped every bit of ruby from my machine, including all references in the registry, got rid of pik as well.
I then followed these steps (that I worked out along with an answer from another question) and it now works
install rubyinstaller 2.1.3
install devkit
gem install thin --platform=[win64]
notepad C:\Ruby21-x64\lib\ruby\gems\2.1.0\gems\eventmachine-1.0.3\ext\project.h #append line 97 with //
cd C:\Ruby21-x64\lib\ruby\gems\2.1.0\gems\eventmachine-1.0.3
gem build eventmachine.gemspec
move eventmachine-1.0.3.gem up one directory
cd ..
gem install eventmachine-1.0.3.gem
del the gemfile
cd
gem install thin --platform=[win64]
A bit of a job BUT it worked,
The answer in question isthis one.
specifically
2) edited the file:
c:\Ruby21-x64\lib\ruby\gems\2.0.0\gems\eventmachine-1.0.3\ext\project.h
and commented the line 97
//typedef int pid_t; for a more robust correction, checkout the
solution here
https://github.com/eventmachine/eventmachine/pull/450/files
3) then, i've opened command prompt, and went to the gem folder
c:\Ruby21-x64\lib\ruby\gems\2.0.0\gems\eventmachine-1.0.3 and run:
gem build eventmachine.gemspec
In the end, after hammering my head against a wall, on a suggestion I installed chef-client and using the embedded ruby allowed it to work, that said it only uses ruby 1.9.3 but it works so for now it will have to do.

RGeo on Ruby under Windows: How to enable GEOS support?

I'm trying to do some spatial operations in Ruby with the RGeo gem. Unfortunately, a lot of operations require the GEOS library and I can't find any documentation showing how to integrate this in Windows (I am using Windows 7 64bit).
I tried downloading and installing the Windows binaries of GEOS from http://trac.osgeo.org/osgeo4w/ and reinstalling the RGeo gem via gem install rgeo -- --with-geos-dir="C:\OSGeo4W64\bin (<< in this directory there is a file geos_c.dll).
Still, using RGeo::Geos.supported? returns false.
Does anybody know how to solve this?
For anyone else looking to do this - here are some tips as to how I got it working.
install GEOS Windows binaries by following the link from http://trac.osgeo.org/geos/ (I have Ruby 32 bit version, so I went for the 32 bit version)
you should now be able to find a file geos_c.dll in C:\OSGeo4W\bin
set a Windows environment variable ENV['GEOS_LIBRARY_PATH'] to be C:\OSGeo4W\bin
check at this point to make sure that ENV variable is there - maybe restart your PC!
in your Gemfile, add gem 'ffi-geos' and gem 'rgeo' and bundle install
in your Ruby file, remember to require 'ffi-geos' and require 'rgeo' (in that order)
use factory = RGeo::Geos.factory(:native_interface => :ffi) - not RGeo::Cartesian.factory
check RGeo::Geos.supported? as Dirk said

Building CompassApp (jruby app) executable from source on Windows

I would like to build the executable of CompassApp, a GUI application that lets webdesigners compile stylesheets by using SASS and Compass without using the command line.
The source can be found on GitHub here: https://github.com/handlino/CompassApp.
CompassApp is a an application developed in Jruby.
From the GitHub webpage of the project:
If you want to build your own copy, you will need JRuby and rawr
I am using Windows 7 as operating system for my webdesign projects. I never built a jruby app from source. It seems on linux it's easier to install the required things, anyway i'm using Windows now.
First i cloned the GitHub repository.
Then i installed jruby.
Now i should install rawr (https://github.com/rawr/rawr)
It seems that rawr also requires javac and rake
I saw that rawr and rake are 2 ruby gems.
So how do i install those 2 ruby gems for jruby on Windows?
And how do i build CompassApp from source after i have everything i need?
I would need a step by step guide from the install of the requirements
to the build of the application.
(i never used jruby in the past).
If someone of you develops apps in jruby i think that can help me easily.
I thank you in advance.
#Fabio Hi, we made Compass.app and Fire.app :-)
It is easy to build Compass.app on OS X or Linux. We have a (almost) step by step guide about building Fire.app on the GitHub wiki and it can be applied to Compass.app too: https://github.com/handlino/FireApp/wiki
We have never tried to build it on Windows, and do not think it can be done easily.
I'm trying to do a similar thing, but in my case only package the gems in a self-contained executable jar. the docs are not very descriptive and some are outdated.
I tried rawr but managed to get further with warbler
here's what I did: I created a folder named jrcompass and installed compass into it:
c:\test\jrcompass>%JRUBY%\jruby -S gem install compass -i .
I installed warbler and then ran the warble command in that folder:
C:\test\jrcompass>c:\apps\jruby\bin\jruby -S warble
that created a ~20MB jar file named jrcompass.jar which is farther than I got with rawr.
now I'm trying to execute the jar with:
C:\test\jrcompass>java -jar jrcompass.jar
and I get the following error below. I hope that this will help you make progress. please let me know if you figure it out.
Gem::LoadError: Could not find compass (>= 0) amongst [rake-0.9.2.2]
to_specs at jar:file:/C:/Users/Admin/AppData/Local/Temp/jruby1564362137331239458extract/jruby-stdlib-1.7.1.jar!/META-INF/jruby.home/lib/ruby/shared/rubygems/dependency.rb:247
to_spec at jar:file:/C:/Users/Admin/AppData/Local/Temp/jruby1564362137331239458extract/jruby-stdlib-1.7.1.jar!/META-INF/jruby.home/lib/ruby/shared/rubygems/dependency.rb:256
gem at jar:file:/C:/Users/Admin/AppData/Local/Temp/jruby1564362137331239458extract/jruby-stdlib-1.7.1.jar!/META-INF/jruby.home/lib/ruby/shared/rubygems.rb:1231
(root) at file:/C:/Apps/test/jrcompass/jrcompass.jar!/jrcompass/bin/compass:22
load at org/jruby/RubyKernel.java:1046
(root) at file:/C:/Apps/test/jrcompass/jrcompass.jar!/META-INF/main.rb:1
require at org/jruby/RubyKernel.java:1027
(root) at file:/C:/Apps/test/jrcompass/jrcompass.jar!/META-INF/main.rb:1
(root) at jar:file:/C:/Users/Admin/AppData/Local/Temp/jruby1564362137331239458extract/jruby-stdlib-1.7.1.jar!/META-INF/jruby.home/lib/ruby/shared/rubygems/custom_require.rb:1

Ruby cannot find sqlite3 driver on windows

I am trying to set up Ruby on Rails on windows. I am using the Flash Rails distribution that looks pretty good, but there is an issue with sqlite3. I found the threads telling me to install version 1.2.3, which installed fine. I'm using ruby 1.9.0, and every time I try and run a script (e.g. rake db:create) that uses the database I get an error message "no driver for sqlite3 found".
This apparently is a missing sqlite3.dll, but I have the dll in my %PATH%, and I have also tried copying it into the directory where I am running the script from, the directory where the sqlite3 ruby code lives.
Does anyone have any ideas? If possible I want all teh ruby stuff to be self contained so I can use it from a pen drive.
EDIT: To clarify, I already used gem install to install the ruby-sqlite3 gem - it is just non functional as it cannot find the sqlite3.dll (even though it is actually present in a directory on my %PATH%)
EDIT PART 2: After doing some more digging, the problem appears that ruby will not load the sqlite3_api.dll. I have copied it all over my filesystem, I just get a failure to read file. Other dll libraries in the same directory (e.g. zlib.dll) work fine!
I tried installing the dlls into system32, and that did not work either.
The problem put simply is that sqlite3-ruby 1.2.3 is not compatible with ruby 1.9. This is caused because ruby 1.9 does not use .dll files for c libraries it uses .so files instead. Additionally, since sqlite3_api.dll is written against msvcrt-ruby18.dll. This means that it specifically only will support ruby 1.8.*.
The good news is that there is a fat binary version that will support both ruby 1.8 and ruby 1.9. Uninstalling all former versions of sqlite3-ruby and then installing this one. (You may have to manually delete some versions the gem after uninstalling.) in order to install it use
install sqlite3-ruby --source http://gems.rubyinstaller.org
for more information see this website
Try installing the sqlite3-ruby gem:
gem install sqlite3-ruby
Something similar happened to me recently so I thought I'd update my answer.
For reference there's a sqlite3_api.dll file located in the gem's lib directory. Also the sqlite3.dll file needs to be reachable on the path. They are different files, the first is required by the gem to interface Ruby to C code, while the second contains the actual Sqlite implementation.
It's best to get the second file from the sqlite website and extract it to the Ruby\bin directory (as you shouldn't manually put DLL's into the windows or windows\system directories any more).
So for reference "sqlite3_api.dll" needs to be in:
Ruby\lib\ruby\gems\1.8\gems\sqlite3-ruby-1.2.3-x86-mswin32\lib
and "sqlite3.dll" needs to be on the path, possibly in:
Ruby\bin
As for the "driver not found" problem I would suggest trying the easy things first and making sure gems is installed correctly, up to date, and that the RUBYLIB and PATH environment variables are set appropriately. (System restart may be required to propagate the changes fully.)
Re this link
Download sqlitedll-3_6_10.zip and extract into ruby/bin!
Try going to sqlite.org download page and get the zipped up dll. Then put that in your c:\windows\system32 folder, that should allow Ruby to find it.
Restart your machine after running install sqlite3-ruby
To clarify, which gem are you using? sqlite-ruby or sqlite3-ruby?
They're part of the same project, but different releases. The key is that sqlite3 appears to have driver code included.
I assume you're attempting to use the first, since it's giving me the same error. If so, try switching.
Also.. How literal do you mean by this?
but I have the dll in my %PATH%
PATH=...;C:\sqlite\sqlite3.dll
PATH=...;C:\sqlite
The first will attempt to find C:\sqlite\sqlite3.dll\sqlite3.dll, AFAIK.
I use Ruby 1.8.7 (works with 1.9.1 too)
OS is WindowsXP SP3
Go to
http://www.sqlite.org/download.html
and Download file
sqlitedll-3_7_0_1.zip (265.19 KiB)
and unzip then we will get
sqlite3.dll
Copy sqlite3.dll to your bin folder
as C:\Ruby191\bin or C:\Ruby187\bin
then it works

Resources