Ruby 1.9 - no such file to load 'win32/open3' - ruby

I'm running ruby 1.9.2 on Windows and am trying to port code that worked in Ruby 1.8. The code uses Open4.popen4 which previously worked fine. With 1.9.2 I have done the following:
Installed POpen4 via gem install POpen4
Required POpen4 via require 'popen4'
Attempted to use POpen4 like:
Open4.popen4("cmd") {|io_in,io_out,io_er| ... }
When I do, I get the error:
no such file to load -- win32/open3
If I try and install win32-open3 (gem install win32-open3) I get the error:
win32-open3 requires Ruby version < 1.9.0
Does anyone know how I get around this problem?

Haven't used it, but this might work: https://github.com/matschaffer/win32-open3-19

Adding
gem "win32-open3-19", :platforms => :mingw, :git => "github.com/matschaffer/win32-open3-19.git"
to my Gemfile didn't exactly work.
Here are the steps that solved this for me:
Add this to the Gemfile -> gem 'win32-open3-19', :platforms => :mingw
Run bundle to install win32-open3-19
That was it. For me the git location was unncessary and didn't work.

Related

etc.bundle => warning: already initialized constant

When I run Ruby scripts, I get 157 lines of warning messages like this:
/Users/clay/.rvm/rubies/ruby-2.6.3/lib/ruby/2.6.0/x86_64-darwin19/etc.bundle: warning: already initialized constant Etc::SC_AIO_LISTIO_MAX
/Users/clay/.rvm/rubies/ruby-2.6.3/lib/ruby/2.6.0/x86_64-darwin19/etc.bundle: warning: already initialized constant Etc::SC_AIO_MAX
/Users/clay/.rvm/rubies/ruby-2.6.3/lib/ruby/2.6.0/x86_64-darwin19/etc.bundle: warning: already initialized constant Etc::SC_AIO_PRIO_DELTA_MAX
... lots more
After some digging, it seems like the Ruby/gem/bundle industrial complex is using both the RVM version of Ruby 2.6.3 and the macOS system version of 2.6.3 in order to resolve the etc gem.
My hard-won quick-fix is to uninstall the rvm-ruby's etc gem, like:
rvm use 2.6.3
gem uninstall etc
However, anytime I initiate a gem update on this version of Ruby, etc will get reinstalled, and I'm back to a torrent o' warnings. I cannot get the system-ruby to uninstall etc at all.
Is there a more permanent fix?
Deets:
rvm 1.29.9
macOS Catalina 10.15.2
It appears I can suppress installing the etc gem in my Gemfile, like this:
source 'https://rubygems.org'
ruby '2.6.3'
gem 'cocoapods', '1.9.1'
# ... other gems
gem 'etc', :require => false
Because the system etc gem is already, um, "on the path", it all seems to work for now, but yikes, do not like.

Ruby gem for Mozenda

Has anyone worked with Mozenda in ruby on rails project before?
I am looking for gem or wrapper of Mozenda API.
Searched online there were two library 'mozenda' and 'mozenda-api'.
Unfortunately, both cannot be found when i tried to install them.
Install one of them as a git repo by adding the proper record into Gemfile:
gem 'mozenda', :git => 'https://github.com/jefferyf/mozenda.git'
or
gem 'mozenda-api', :git => 'https://github.com/darrikmazey/mozenda-api.git'
Then issue:
$ bundle install

Ruby : trying to install rubyXL gem from file

I am just starting with Ruby on Rails and need to use the RubyXL gem (https://github.com/gilt/rubyXL). I was told by one of the other devs to use bundle install. I cannot seem to get the syntax correct however, if I run "bundle install ./rubyXL-1.2.10.gem" I get ""install" was called incorrectly. Call as "bundle install".". How do I use bund
If you need bundler you can add
gem 'rubyXL', :path => '_path_to_file_'
to your Gemfile
You want gem install ./rubyXL-1.2.10.gem.

Installing a gem has no effect (aka how to use check_puppet.rb)

I'm sure this question is an easy one for Ruby users. However for me this is a issue I can't figure out by myself.
My goal is to use a script included in the Puppet archive (ext/nagios/check_puppet.rb) on a Ubuntu-10.4 system.
I try to launch the script:
$ sudo ./check_puppet.rb
./check_puppet.rb:4:in `require': no such file to load -- sys/proctable (LoadError)
from ./check_puppet.rb:4
Ok so there's something missing. I fount out I need some library called sys-proctable available at http://raa.ruby-lang.org/project/sys-proctable/
wget http://rubyforge.org/frs/download.php/65609/sys-proctable-0.9.0-x86-linux.gem
[...]
sudo apt-get install rubygems
[...]
$ sudo gem install sys-proctable-0.9.0-x86-linux.gem
Successfully installed sys-proctable-0.9.0-x86-linux
1 gem installed
Installing ri documentation for sys-proctable-0.9.0-x86-linux...
Installing RDoc documentation for sys-proctable-0.9.0-x86-linux...
Everything looks pretty good so far! Time to launch the script again
$ sudo ./check_puppet.rb
./check_puppet.rb:4:in `require': no such file to load -- sys/proctable (LoadError)
from ./check_puppet.rb:4
the gem listoutput tells me this:
$ gem list
*** LOCAL GEMS ***
sys-proctable (0.9.0)
Where has this gem been installed?
Why can't the script load the sys-proctable lib?
What the %&$# am I doing wrong?
Where's the official doc of gem?
The gem is installed - but in Ruby 1.8 you need to have the line:
require 'rubygems'
To use rubygems. This changes the 'require' function so it will pull in rubygems when you ask it to.
So in the script:
https://github.com/puppetlabs/puppet/blob/master/ext/nagios/check_puppet.rb
Just add the require near the top and try again.
For instructions on other ways to use rubygems, consult the Rubygems documentation:
http://docs.rubygems.org/read/chapter/3#page70
this is what i am getting on centos 6.4
sudo ./check_puppet.rb
./check_puppet.rb:75:in `-': no implicit conversion to float from nil (TypeError)
from ./check_puppet.rb:75:in `check_state'
from ./check_puppet.rb:122
i added require 'rubygems'
and installed sys-proctable

How to tell the bundle to use specific version of hpricot [duplicate]

Upgraded to rails 3, and using Bundler for gems, in a mixed platform development group. I am on Windows. When I run Bundle Install it completes succesfully but will not install hpricot. The hpricot line is:
gem "hpricot", "0.8.3", :platform => :mswin
also tried
gem "hpricot", :platform => :mswin
Both complete fine but when I try to do a "bundle show hpricot" I get:
Could not find gem 'hpricot' in the current bundle.
If I do a run a rails console and try "require 'hpricot'" I get:
LoadError: no such file to load -- hpricot
I have manually installed hpricot as well, and still get the above error. This worked fine before moving to rails 3.
Try this in console and then do bundle install, it will work:
gem install hpricot --platform=mswin32
It may be that you are using a version of ruby that was built with MinGW in which case your platform will be 'mingw' rather than 'mswin'. Try changing your Gemfile line to the following:
gem "hpricot", "0.8.3", :platform => :mingw
And if you have other developers that are using the current setup and don't wan to break it for them, change it to this:
gem "hpricot", "0.8.3", :platforms => [:mswin, :mingw]

Resources