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).
Related
What must I do when I want to copy an installed gem from one installation to another one without using the gem command?
I have to install SQLite3 on a server without an internet connection. Normally I can do it with a copy of the gem-file:
gem install --local sqlite3-1.4.0.gem --platform ruby
But for SQLite3 it needs a connection to the internet to get libraries to compile some binaries. The installation worked well on a computer with an internet connection.
So my idea was to take my successful installation on the same OS and same Ruby version and copy all the related components, but this did not work.
When I called:
require 'sequel'
db = Sequel.sqlite
I got this error:
LoadError: The specified module could not be found
d:/bin/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sqlite3-1.4.1/lib/sqlite3/sqlite3_native.so
(Sequel::AdapterNotFound)
In the trace is:
d:/bin/Ruby26-x64/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require': LoadError: 126: The specified module could not be found. - d:/bin/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sqlite3-1.4.1/lib/sqlite3/sqlite3_native.so (Sequel::AdapterNotFound)
from d:/bin/Ruby26-x64/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from d:/bin/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sqlite3-1.4.1/lib/sqlite3.rb:6:in `rescue in <top (required)>'
from d:/bin/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sqlite3-1.4.1/lib/sqlite3.rb:2:in `<top (required)>'
from d:/bin/Ruby26-x64/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:130:in `require'
from d:/bin/Ruby26-x64/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:130:in `rescue in require'
from d:/bin/Ruby26-x64/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:34:in `require'
from d:/bin/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sequel-5.17.0/lib/sequel/adapters/sqlite.rb:3:in `<top (required)>'
from d:/bin/Ruby26-x64/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from d:/bin/Ruby26-x64/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from d:/bin/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sequel-5.17.0/lib/sequel/database/connecting.rb:88:in `load_adapter'
from d:/bin/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sequel-5.17.0/lib/sequel/database/connecting.rb:17:in `adapter_class'
from d:/bin/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sequel-5.17.0/lib/sequel/database/connecting.rb:45:in `connect'
from d:/bin/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sequel-5.17.0/lib/sequel/core.rb:121:in `connect'
from d:/bin/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sequel-5.17.0/lib/sequel/core.rb:399:in `adapter_method'
from d:/bin/Ruby26-x64/lib/ruby/gems/2.6.0/gems/sequel-5.17.0/lib/sequel/core.rb:406:in `block (2 levels) in def_adapter_method'
from _ruby_version.rb:21:in `<main>'
but the file exists:
What is my error?
I'm using Windows Server 2016.
I found a precompiled version of SQLite3 in a GitHub issue which works for me, but I would like to use a newer version.
Use Bundler for this.
In short:
Run gem install bundler on each machine you're using.
Maintain a project Gemfile listing all requirements
Run bundle install when your Gemfile changes and bundle update to update to latest versions. This will generate the Gemfile.lock file.
Prefix ruby execution with bundle exec, e.g. bundle exec ruby myscript or bundle exec rails c
That's a brief summary, but please read up more on Bundler. It's an essential part of modern Ruby deployment.
You need to use the package option of bundler.
First you need to cache your dependencies into vendor/cache with:
bundle package --all --all-platforms
This will install all the dependencies of your Gemfile locally, then add the directory to your source code repository.
When deploying make sure you use bundle install --local to use the local version.
See the documentation for bundle package for more information.
I get the following error when trying to do anything with Ruby, specifically ruby gems:
/usr/local/rvm/rubies/ruby-2.4.5/lib/ruby/2.4.0/yaml.rb:5:in `<top (required)>':
It seems your ruby installation is missing psych (for YAML output).
To eliminate this warning, please install libyaml and reinstall your ruby.
/usr/local/rvm/rubies/ruby-2.4.5/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:130:in `require': incompatible library version - /usr/local/rvm/gems/ruby-2.4.5/gems/psych-3.1.0/lib/psych.so (LoadError)
from /usr/local/rvm/rubies/ruby-2.4.5/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:130:in `rescue in require'
from /usr/local/rvm/rubies/ruby-2.4.5/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:34:in `require'
from /usr/local/rvm/gems/ruby-2.4.5/gems/psych-3.1.0/lib/psych.rb:16:in `rescue in <top (required)>'
from /usr/local/rvm/gems/ruby-2.4.5/gems/psych-3.1.0/lib/psych.rb:13:in `<top (required)>'
from /usr/local/rvm/rubies/ruby-2.4.5/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /usr/local/rvm/rubies/ruby-2.4.5/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /usr/local/rvm/rubies/ruby-2.4.5/lib/ruby/2.4.0/yaml.rb:6:in `<top (required)>'
from /usr/local/rvm/rubies/ruby-2.4.5/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /usr/local/rvm/rubies/ruby-2.4.5/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /usr/local/rvm/rubies/ruby-2.4.5/lib/ruby/site_ruby/2.4.0/rubygems.rb:729:in `load_yaml'
from /usr/local/rvm/rubies/ruby-2.4.5/lib/ruby/site_ruby/2.4.0/rubygems/config_file.rb:349:in `load_file'
from /usr/local/rvm/rubies/ruby-2.4.5/lib/ruby/site_ruby/2.4.0/rubygems/config_file.rb:202:in `initialize'
from /usr/local/rvm/rubies/ruby-2.4.5/lib/ruby/site_ruby/2.4.0/rubygems/gem_runner.rb:79:in `new'
from /usr/local/rvm/rubies/ruby-2.4.5/lib/ruby/site_ruby/2.4.0/rubygems/gem_runner.rb:79:in `do_configuration'
from /usr/local/rvm/rubies/ruby-2.4.5/lib/ruby/site_ruby/2.4.0/rubygems/gem_runner.rb:44:in `run'
from /usr/local/rvm/rubies/ruby-2.4.5/bin/gem:21:in `<main>'
I believe the line of note is this one:
LoadError: incompatible library version - /usr/local/rvm/gems/ruby-2.4.5/gems/psych-3.1.0/lib/psych.so
I get this from gem install puppet, gem update, etc. I tried uninstalling and reinstalling libyaml, and same with Ruby. The error happened after I did bundle uninstall puppet to get it to stop pointing to the 6.3.0 gem and point to the 4.10.2 executable. I need Ruby to be able to use Rspec to test the modules. Does anyone know how I can fix this?
Without steps to reproduce the broken system it is hard to say what happened, but I can say in general how you can set this up correctly to use a specific version of Puppet.
Does this help? In the worst case, you can probably uninstall RVM and reinstall it.
Before I continue, let me note that Puppet 4.10.2 and 4.10.3 have both been removed from Rubygems. (Although I was able to install it with PDK.)
For the remainder I assume 4.10.4 instead (just to distinguish it from latest 4.10).
The recommended approach is to use Puppet Development Kit (pdk). If you download and install PDK, you probably just need to do these steps:
pdk convert
rm Gemfile.lock
PUPPET_GEM_VERSION=4.10.4 bundle update # If that version isn't already in PDK.
pdk test unit --puppet-version 4.10.4
If you don't want to go down the PDK path, you can try these alternatives:
Hardcode the version of Puppet you want in Gemfile.
gem 'puppet', '4.10.4'
Or:
gem 'puppet', '~> 4.10' # latest 4.10
Then update your bundle:
rm -f Gemfile.lock
bundle update
Or, you can implement the PUPPET_GEM_VERSION feature by adding this code (this is what I do, for what it's worth):
if puppetversion = ENV['PUPPET_GEM_VERSION']
gem 'puppet', puppetversion
else
gem 'puppet'
end
And then:
rm -f Gemfile.lock
PUPPET_GEM_VERSION='~> 4.10' bundle update
Now you can run your unit tests against a specific version of Puppet per normal:
bundle exec rake spec
Or however you set it up.
I have upgraded Ruby version to 2.1.0 from Ruby 1.8.7 and installed all dependencies to run a sample Appium test case using Ruby. But I am facing an issue to load nokogiri while running a test case.
I am using
OS: Mac OS - 1.9.2
Ruby: 2.1.0
Appium: 1.2.0
Nokogiri: 1.6.3.1
This works fine on Ruby: 1.8.7.
Error:
Users/.rvm/gems/ruby-2.1.0/ruby/2.1.0/gems/nokogiri-1.6.3.1/lib/nokogiri.rb:29:in `require': dlopen(/Users/.rvm/gems/ruby-2.1.0/ruby/2.1.0/gems/nokogiri-1.6.3.1/lib/nokogiri/nokogiri.bundle, 9): Library not loaded: /Users/.rvm/rubies/ruby-2.1.0/lib/libruby.2.1.0.dylib (LoadError)
Referenced from: /Users/.rvm/gems/ruby-2.1.0/ruby/2.1.0/gems/nokogiri-1.6.3.1/lib/nokogiri/nokogiri.bundle
Reason: image not found - /Users/.rvm/gems/ruby-2.1.0/ruby/2.1.0/gems/nokogiri-1.6.3.1/lib/nokogiri/nokogiri.bundle
from /Users/.rvm/gems/ruby-2.1.0/ruby/2.1.0/gems/nokogiri-1.6.3.1/lib/nokogiri.rb:29:in `rescue in <top (required)>'
from /Users/.rvm/gems/ruby-2.1.0/ruby/2.1.0/gems/nokogiri-1.6.3.1/lib/nokogiri.rb:25:in `<top (required)>'
from /Users/.rvm/gems/ruby-2.1.0/ruby/2.1.0/gems/appium_lib-4.1.0/lib/appium_lib/driver.rb:4:in `require'
from /Users/.rvm/gems/ruby-2.1.0/ruby/2.1.0/gems/appium_lib-4.1.0/lib/appium_lib/driver.rb:4:in `<top (required)>'
from /Users/.rvm/gems/ruby-2.1.0/ruby/2.1.0/gems/appium_lib-4.1.0/lib/appium_lib.rb:28:in `require_relative'
from /Users/.rvm/gems/ruby-2.1.0/ruby/2.1.0/gems/appium_lib-4.1.0/lib/appium_lib.rb:28:in `<top (required)>'
from /Users/Documents/rslRuby/li_workspace/flagship_native_tests/UITestFramework/selenium/base/LI_framework.rb:32:in `require'
from /Users/Documents/rslRuby/li_workspace/flagship_native_tests/UITestFramework/selenium/base/LI_framework.rb:32:in `<top (required)>'
from /Users/.rvm/rubies/ruby-2.1.0/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/.rvm/rubies/ruby-2.1.0/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from samle_tests/sign_in_test.rb:10:in `<main>'
Possible Fix 1:
This usually happens when gems are linked wrong, i recommend trying to re-install ruby via rvm.
rvm reinstall 2.1
rvm use 2.1
Make sure all the gems are up to date by running(in your apps directory)
bundle install
Possible Fix 2:
Another common problem is to install rvm as a root user, if you've done this re install rvm.
You can uninstall rvm by running
rvm implode
Follow the steps on the website to install rvm
I'm working on some cucumber tests from The Cucumber Book. I've got the code that tries to use a transaction processor and there is a file with the following code:
require 'service_manager'
ServiceManager.start
This is on Mac OS X 10.6.8 using Ruby 1.9.2. When this file executes, I get the following:
no such file to load -- service_manager (LoadError)
/opt/local/lib/ruby1.9/site_ruby/1.9.1/rubygems/custom_require.rb:59:in `require'
/opt/local/lib/ruby1.9/site_ruby/1.9.1/rubygems/custom_require.rb:59:in `rescue in require'
/opt/local/lib/ruby1.9/site_ruby/1.9.1/rubygems/custom_require.rb:35:in `require'
/Users/gpollice/MyCucumber/ATMBookExample/features/support/services.rb:6:in `<top (required)>'
/opt/local/lib/ruby1.9/gems/1.9.1/gems/cucumber-1.1.2/lib/cucumber/rb_support/rb_language.rb:143:in `load'
/opt/local/lib/ruby1.9/gems/1.9.1/gems/cucumber-1.1.2/lib/cucumber/rb_support/rb_language.rb:143:in `load_code_file'
/opt/local/lib/ruby1.9/gems/1.9.1/gems/cucumber-1.1.2/lib/cucumber/runtime/support_code.rb:171:in `load_file'
/opt/local/lib/ruby1.9/gems/1.9.1/gems/cucumber-1.1.2/lib/cucumber/runtime/support_code.rb:83:in `block in load_files!'
The service_manager gem is installed in /opt/local/lib/ruby1.9/gems/1.9.1/gems as are other gems that the application uses. Until I added the code for this iteration, there were no problems. I've looked for reasons why the gem is not found and just can't figure out why. Any help would be appreciated.
It appears to be a load path issue.
Is require "rubygems" invoked prior to this require statement?
Also, if you're using bundler, you have to add this gem to your Gemfile, as bundler attempts to sandbox your dependencies. If you're using bundler, try the following after adding the gem to the Gemfile:
bundle exec rake cucumber
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.