Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3969110
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T03:55:28+00:00 2026-05-20T03:55:28+00:00

I’ve moved my original question to the bottom as its no longer fully relavent

  • 0

I’ve moved my original question to the bottom as its no longer fully relavent to the problem.

I am unable to locate serialport.so which I am able to require like this:

$ rvmree@global
$ irb
> require 'serialport.so'
=> true

(gem list returns emtpy)

Update:

require 'serialport'

when executed in an irb session, both requires return true even when I uninstall the gem. So, it appears another gem is being required via “require ‘serialport'”. I’ve searched my system for any other versions of this gem without result.

How can I ensure the correct gem is being required?

Update:

[Removed list of gems]

When I uninstall all gems in rvm global namespace, I can still require ‘serialport’ and get true.

Now my output of gem list is completely empty and require ‘serialport’ still returns true from within irb.

I’m using rvm, I’ve emptied the global gems, and all gems in the gemset I’m using. There are no system gems with a name containing ‘serialport’, I’ve searched for files which would be included in the gem directory such as serialport.o, serialport.so and didn’t find anything.

I’m at a loss for what could possibly be responding to require ‘serialport’

require 'serialport.so'

also returns true and

sudo find / -name 'serialport.so' -print

doesn’t return anything.

Any ideas?

Original Post:

I’m using the serialport (1.0.4) gem.

Documentation is found at http://rubydoc.info/gems/serialport/1.0.4/

Here is my implementation.rb:

require 'rubygems'
require 'serialport'
port_str = "/dev/cu.usbserial" # Serialport mount point
baud_rate = 9600
data_bits = 8
stop_bits = 1
parity = 0

sp = SerialPort.new(port_str, data_bits, stop_bits, baud_rate, parity)

while barcode = sp.gets do
  puts barcode
end

sp.close

When running ruby implementation.rb, I get:

implementation.rb:14:in `initialize': wrong number of arguments (5 for 2) (ArgumentError)
from implementation.rb:14:in `open'
from implementation.rb:14

This is weird as there doesn’t appear to be an initialize method anywhere (maybe ruby is internally naming SerialPort::new as initialize?).

The ruby part of the gem looks like:

require 'serialport.so'

class SerialPort
   private_class_method(:create)

   # Creates a serial port object.
   #
   # <tt>port</tt> may be a port number
   # or the file name of a defice.
   # The number is portable; so 0 is mapped to "COM1" on Windows,
   # "/dev/ttyS0" on Linux, "/dev/cuaa0" on Mac OS X, etc.
   #
   # <tt>params</tt> can be used to configure the serial port.
   # See SerialPort#set_modem_params for details
   def SerialPort::new(port, *params)
      sp = create(port)
      begin
         sp.set_modem_params(*params) # Calls C extension
      rescue
         sp.close
         raise
      end
      return sp
   end
  # SerialPort::open removed as its the same thing as new() with a block
end

This was working the other day and I can’t think of anything which would of changed.

I also get the same error with ruby-serialport gem (0.7.0) which appears to be exactly the same from a quick glance at both sources.

A sample implementation is found at http://www.sfc.wide.ad.jp/~mitsuya/4U/ruby-serialport-macosx.html

The latter gem (ruby-serialport) is found at http://rubyforge.org/projects/ruby-serialport/ (documentation at http://ruby-serialport.rubyforge.org/)

Any ideas? Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T03:55:28+00:00Added an answer on May 20, 2026 at 3:55 am

    Looking at $LOAD_PATH from within irb, I started searching through them for anything serialport related.

    Before long, I found ~/.rvm/rubies/ree-1.8.7-2010.02/lib/ruby/site_ruby/1.8/i686-darwin10.6.0/serialport.bundle. After deleting it, I tried require 'serialport' and got the expected LoadError: no such file to load -- serialport as I had previously uninstalled the serialport gem for debugging this problem.

    After gem install serialport, my code works again as expected.

    Had I been thinking clearly, I would have done this in the first place and avoided the headache. I hope this helps anyone with a similar problem to debug it more quickly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to select an H1 element which is the second-child in its group
I have been unable to fix a problem with Java Unicode and encoding. The
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have an autohotkey script which looks up a word in a bilingual dictionary
This could be a duplicate question, but I have no idea what search terms

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.