Reputation: 894
I am trying to create a simple ruby app to work with an Arduino. My problem is that the Ruby Gems are not being found. This is my script code - it is from a tutorial i found:
#!/usr/bin/ruby -rubygems
require 'rubygems'
require 'serialport'
require 'gmail'
#plug in your username and password here
gmail = Gmail.connect("username", "password")
#count the number of unread messages
prev_unread = gmail.inbox.count(:unread)
#this *will* be different for you
#You need to find out what port your arduino is on
#and also what the corresponding file is on /dev
#You can do this by looking at the bottom right of the Arduino
#environment which tells you what the path.
port_file = '/dev/tty.usbmodem1421'
#this must be same as the baud rate set on the Arduino
#with Serial.begin
baud_rate = 9600
data_bits = 8
stop_bits = 1
parity = SerialPort::NONE
#create a SerialPort object using each of the bits of information
port = SerialPort.new(port_file, baud_rate, data_bits, stop_bits, parity)
wait_time = 4
#for an infinite amount of time
loop do
#get the number of unread messages in the inbox
unread = gmail.inbox.count(:unread)
#lets us know that we've checked the unread messages
puts "Checked unread."
#check if the number of unread messages has increased
#if so, we have a new email! So, blink the LED.
if unread > prev_unread
port.write "b"
end
#reset the number of unread emails
prev_unread = unread
#wait before we make another request to the Gmail servers
sleep wait_time
end
I then go to the directory where this file (gmail_notifier.rb) lives and run ruby gmail_notifier.rb
. This is the error i am receiving after running that command:
/Users/ryan/.rvm/rubies/ruby-2.0.0-head/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:51:in `require': cannot load such file -- serialport (LoadError)
from /Users/ryan/.rvm/rubies/ruby-2.0.0-head/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:51:in `require'
from gmail_notifier.rb:4:in `<main>'
Anyone know why the gems are not being found? I did run gem install gmail
and gem install serialport
already.
Upvotes: 0
Views: 894