I am trying to create my first GUI using wxRuby. I installed wxRuby (using gem install wxruby-ruby19) and, it seemed to be installed alright. I copied some code directly from the wxRuby site. Here is the code I used:
test.rb
require "wx"
include Wx
class MinimalApp < App
def on_init
Frame.new(nil, -1, "The Bare Minimum").show()
end
end
MinimalApp.new.main_loop
When I ran it, I got this error:
<internal:lib/rubygems/custom_require>:29:in `require': libwx_gtk2u_stc-2.8.so.0: cannot open shared object file: No such file or directory - /usr/local/ruby/lib/ruby/gems/1.9.1/gems/wxruby-ruby19-2.0.1-x86-linux/lib/wxruby2.so (LoadError)
from <internal:lib/rubygems/custom_require>:29:in `require'
from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/wxruby-ruby19-2.0.1-x86-linux/lib/wx.rb:12:in `<top (required)>'
from <internal:lib/rubygems/custom_require>:33:in `require'
from <internal:lib/rubygems/custom_require>:33:in `rescue in require'
from <internal:lib/rubygems/custom_require>:29:in `require'
from test.rb:2:in `<main>'
I thought it was saying that wxruby wasn't in that directory, but I checked and it was, so I'm not sure what the problem is. If anyone could help, that would be awesome.
I tried the same thing and got the same result.
It turns out that there are 2 wxRuby gems. If you are using Ruby 1.9x, you want wxRuby-ruby19. (gem install wxruby-ruby19).
I uninstalled the wxruby gem that I installed the first time (gem uninstall wxruby), and then installed the gem for my version of Ruby (gem install wxruby-ruby19). And Voila! All the sample code just worked. No additional downloads needed.
To use wxRuby you need wxWidgets installed (wxGTK in your case).
The problem is wxRuby uses the wxWidgets shared libraries (e.g. libwx_gtk2u_stc-2.8.so.0) and it cant find them.
Related
I've followed all of the steps from this question: Highgui and ruby
opencv was installed via brew, and rb_webcam was installed via gem install.
require "opencv"
require "rb_webcam"
capture = Webcam.new
The error is:
/Users/swills/.rvm/rubies/ruby-2.1.1/lib/ruby/gems/2.1.0/gems/nice-ffi-0.4/lib/nice-ffi/library.rb:98:in `load_library': Could not load highgui. (LoadError)
from /Users/swills/.rvm/rubies/ruby-2.1.1/lib/ruby/gems/2.1.0/gems/rb_webcam-0.3.0/lib/rb_webcam.rb:7:in `<module:Highgui>'
from /Users/swills/.rvm/rubies/ruby-2.1.1/lib/ruby/gems/2.1.0/gems/rb_webcam-0.3.0/lib/rb_webcam.rb:4:in `<top (required)>'
from /Users/swills/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:135:in `require'
from /Users/swills/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:135:in `rescue in require'
from /Users/swills/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:144:in `require'
from gem_testing.rb:3:in `<main>'
In the other stackoverflow post from above, the the user made the post said that they-
"Solved it by downloading gem from here https://github.com/TyounanMOTI/rb_webcam and building and installing it manually."
My question is, how do I solve it by building and installing it manually?
(especially if 'gem install rb_webcam' isn't considered manual installation).
I'm learning Ruby from "Beginning Ruby from Novice to Professional" by Peter Cooper. I am on Chapter 7. I have ruby 2.0 installed. I am facing this error:
C:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- 2.0/redcloth_scan (LoadError)
When trying to run this code:
require 'rubygems'
require 'RedCloth'
r = RedCloth.new("This is a *test* of _using RedCloth_")
puts r.to_html
I'm getting this result:
ruby redcloth.rb
C:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- 2.0/redcloth_scan (LoadError)
Couldn't load 2.0/redcloth_scan
The $LOAD_PATH was:
C:/Ruby200/lib/ruby/gems/2.0.0/gems/RedCloth-4.2.9-x86-mingw32/lib
C:/Ruby200/lib/ruby/gems/2.0.0/gems/RedCloth-4.2.9-x86-mingw32/lib/case_sensitive_require
C:/Ruby200/lib/ruby/gems/2.0.0/gems/RedCloth-4.2.9-x86-mingw32/ext
C:/Ruby200/lib/ruby/site_ruby/2.0.0
C:/Ruby200/lib/ruby/site_ruby/2.0.0/i386-msvcrt
C:/Ruby200/lib/ruby/site_ruby
C:/Ruby200/lib/ruby/vendor_ruby/2.0.0
C:/Ruby200/lib/ruby/vendor_ruby/2.0.0/i386-msvcrt
C:/Ruby200/lib/ruby/vendor_ruby
C:/Ruby200/lib/ruby/2.0.0
C:/Ruby200/lib/ruby/2.0.0/i386-mingw32
from C:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/RedCloth-4.2.9-x86-mingw32/lib/RedCloth.rb:13:in `<top (required)>'
from C:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:135:in `require'
from C:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:135:in `rescue in require'
from C:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:144:in `require'
from redcloth.rb:2:in `<main>'
Exit code: 1
I already installed ruby gems and RedCloth. They didn't give me an errors. If somebody could shed some light on this topic it would be greatly appreciated.
try this:
goto into C:/Ruby200/lib/ruby/gems/2.0.0/gems/RedCloth-4.2.9-x86-mingw32/lib
and create a dir named '2.0'.
Then copy redcloth_scan.so from 'C:/Ruby200/lib/ruby/gems/2.0.0/gems/RedCloth-4.2.9-x86-mingw32/lib' into '2.0' dir.
I installed in past RedCloth with Ruby 1.9.1.
Actually I suspect that RedCloth doesn't work with Ruby 2.0.
On ruby 2.x.x you need to compile the gem.
For example for the windows ruby 2.2.4:
Setup the DevKit (https://github.com/oneclick/rubyinstaller/wiki/Development-Kit)
Run into command window:
gem install RedCloth --platform=ruby
Goto to your installed RedCloth path
lib\ruby\gems\2.2.0\gems\RedCloth-4.2.9\lib
Create there a new directory called "2.2" and copy the file redcloth_scan.so on it.
If you use the gem RedCloth-4.2.9-x86-mingw32, the redcloth_scan.so contains the ruby 1.9 dependency and it doesn't works with ruby 2.2.4.
I know that rb-appscript is officially no longer supported.
However, I tried and found that rewriting existing libraries to use alternative methods (e.g. osascript) was a non-trivial work and it occurred to me that monkey-patching rb-appscript to work again seemed like a better approach, if ever possible.
Here's what happens.
$ rvm 2.0.0
$ gem install rb-appscript
$ irb
> require 'appscript'
LoadError: cannot load such file -- _aem/mactypes
from ruby-2.0.0-p0/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
from ruby-2.0.0-p0/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
from ruby-2.0.0-p0/gems/rb-appscript-0.6.1/lib/appscript.rb:8:in `<top (required)>'
from ruby-2.0.0-p0/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:110:in `require'
from ruby-2.0.0-p0/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:110:in `rescue in require'
from ruby-2.0.0-p0/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:35:in `require'
What change in Ruby 2.0.0 is causing this?
It seems that there was a bug in Rubygems 2.0.0, and upgrading to 2.0.2 by
gem update --system
fixed the problem.
Because of a bug with Float#round in Ruby 1.8.6, I was forced to upgrade to 1.9.3 and boy was that awful. After install, irb didn't work, complaining of a lack of psych. So I tried to install the gem, but it was angry that libyaml didn't exist, so I installed that. Not sure why they weren't included if they were so important.
Now when I use require 'Location.rb' (after having to specify that I actually do want to look in the current folder... using $LOAD_PATH), I get this error:
LoadError: cannot load such file -- crack/xml
from /usr/local/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /usr/local/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /usr/local/lib/ruby/gems/1.9.1/gems/ap-0.1.1/lib/ap.rb:2:in `<top (required)>'
from /usr/local/lib/ruby/1.9.1/rubygems/custom_require.rb:59:in `require'
from /usr/local/lib/ruby/1.9.1/rubygems/custom_require.rb:59:in `rescue in require'
from /usr/local/lib/ruby/1.9.1/rubygems/custom_require.rb:35:in `require'
from /Users/tyre77/Dropbox/Aurora/GMap.rb:4:in `<top (required)>'
from /usr/local/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /usr/local/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from (irb):3
from /usr/local/bin/irb:12:in `<main>'
What does this mean? Also, when I execute ruby -v, it lists my version as 1.9.3p0 but this is dicking around in 1.9.1? All I want is my irb back and working!
It turned out that Ruby was looking for an XML parser called 'crack'. I don't know why it is referencing 2 versions of Ruby or why these dependencies aren't included in the Ruby build (since irb won't work without them) but to fix I installed the crack gem. sudo gem install crack
you can use
require_relative 'Location.rb'
or
require './Location.rb'
I have installed Ruby v1.9.2, and (according to the instructions on http://rubyonrails.org/download) I am trying to install Gems. I've downloaded the 1.4.2 zip from http://rubyforge.org/frs/?group_id=126, but when I run setup.rb, I get the following error/trace:
C:\temp\rubygemsInstall\rubygems-1.4.2\rubygems-1.4.2>setup.rb
C:/temp/rubygemsInstall/rubygems-1.4.2/rubygems-1.4.2/lib/rubygems/source_index.
rb:62:in `installed_spec_directories': undefined method `path' for Gem:Module (N
oMethodError)
from C:/temp/rubygemsInstall/rubygems-1.4.2/rubygems-1.4.2/lib/rubygems/
source_index.rb:52:in `from_installed_gems'
from C:/temp/rubygemsInstall/rubygems-1.4.2/rubygems-1.4.2/lib/rubygems.
rb:914:in `source_index'
from C:/temp/rubygemsInstall/rubygems-1.4.2/rubygems-1.4.2/lib/rubygems/
gem_path_searcher.rb:83:in `init_gemspecs'
from C:/temp/rubygemsInstall/rubygems-1.4.2/rubygems-1.4.2/lib/rubygems/
gem_path_searcher.rb:13:in `initialize'
from C:/temp/rubygemsInstall/rubygems-1.4.2/rubygems-1.4.2/lib/rubygems.
rb:873:in `new'
from C:/temp/rubygemsInstall/rubygems-1.4.2/rubygems-1.4.2/lib/rubygems.
rb:873:in `searcher'
from C:/temp/rubygemsInstall/rubygems-1.4.2/rubygems-1.4.2/lib/rubygems.
rb:495:in `find_files'
from C:/temp/rubygemsInstall/rubygems-1.4.2/rubygems-1.4.2/lib/rubygems.
rb:1034:in `load_plugins'
from C:/temp/rubygemsInstall/rubygems-1.4.2/rubygems-1.4.2/lib/rubygems/
gem_runner.rb:84:in `<top (required)>'
from <internal:lib/rubygems/custom_require>:29:in `require'
from <internal:lib/rubygems/custom_require>:29:in `require'
from C:/temp/rubygemsInstall/rubygems-1.4.2/rubygems-1.4.2/setup.rb:25:i
n `<main>'
I am running Windows Server 2008 R2 - please post a comment if there is any other relevant info.
How do I get around this error?
The windows RubyInstaller includes rubygems already, so you don't have to install it separately. I'm assuming you're using RubyInstaller because that's what the rubyonrails.org page links you to if you click on the Windows link, but there is more information on the RubyInstaller page in the Help section.
What happens if you go to a cmd prompt and do "gem list"?
Older versions of rubygems aren't completely compatible with Ruby 1.9.2. I realize the OP discovered that rubygems was already installed, but for those who still need to install it, all you need to do is downgrade to Ruby 1.8.7 and then it should work properly. This is where a tool like RVM really comes in handy.