title: Ruby Code Not Working
body: <p>I've inherited some code from a coworker, the catch being I haven't done coding before.  This code works on my machine, and other machines.  However when I attempt to run it on a new system with newly installed Ruby and the dependent gems, it doesn't preform as expected.  So this code DOES work... just not on all our systems.  And I'm too unfamiliar to know what exactly to look for to find the inconsistency.</p>
  
  <p>If anyone has an idea or any tips on how I can solve this, I'd be extremely grateful.</p>
  
  <pre><code>require 'curb' # For Curl statement
  require 'nokogiri' # for screen scrapping
  require 'io/console' # hide password input
  require 'mechanize' # clicking through and logging in
  
  #start your engines
  agent = Mechanize.new
  agent.keep_alive = false
  agent.open_timeout   = 180
  agent.read_timeout   = 180
  page  = agent.get('http://_____.co.__________.com/admin/_____/user/')
  
  #get login for _____
  puts "Please enter your _____ Login:"
  prompt = '&gt;'
  print prompt
  page.forms.first.fields[1].value =  STDIN.gets.chomp()
  puts "Please enter your password:"
  print prompt
  #this way keeps you from seeing the password on the screen
  page.forms.first.fields[2].value =  STDIN.noecho(&amp;:gets).chomp()
  puts "Searching for %s" % ARGV[0]
  #click the login button
  login_page = page.forms.first.submit    
  #take the first argument and put it in the user search box
  login_page.forms.first.fields.first.value = ARGV[0]
  #click search
  users_page = login_page.forms.first.submit
  #click on the only link, people with "deleted" account might need some hacking to make work
  inventory_page = users_page.links.last.click
  puts "Found %s, now opening user page..." % ARGV[0]
  active_inventory = []
  puts "checking total active inventorys..."
  #find the inventory table and get all the rows. Then loop through and check if active. If active put FSID into an array to check next
  inventory_page.parser.xpath('//tr[contains(@id,"filesystemproperties")]').each do |row|  
  #inventory_page.parser.css('tr.has_original').each do |row|     
      if row.at('img')["alt"] == "True"
          active_inventory &lt;&lt; row.children[2].text.gsub("\n",'').strip
          puts row.children[2].text.gsub("\n",'').strip
      end
  end
  
  #now lets send a inventory, go to the inventory Versions link at the top of the page
  get_inventory = inventory_page.links[3].click
  
  #require 'logger' #debug stuff, pay no attention.
  #agent.log = Logger.new $stderr
  #agent.agent.http.debug_output = $stderr
  puts "checking total size of inventorys..."
  
  #time for some simple addition
  inventory_size = 0
  #clear out any blank fsid, then each one send (POST)
  active_inventory.reject!(&amp;:empty?).each do |fsid|
      get_inventory.forms.first.fields.first.value = fsid
      size = get_inventory.forms.first.submit
      #get the top row second column for latest size, and add it to the existing tally for total size
      inventory_size += size.parser.xpath('//tbody/tr[1]/td[2]').text.to_i
      puts "%s is %d Bytes" % [fsid, size.parser.xpath('//tbody/tr[1]/td[2]').text.to_i]
      puts "current inventory: #{inventory_size}"
      #sleep 15
  end
  #convert those bytes to MEGABytes
  puts "%d currently active inventory(s) found\n" % (active_inventory.count - 3)
  puts "\n \n \nTotal inventory size is: %f MB" % [inventory_size/(1024*1024).to_f]
  </code></pre>
  
  <p>You can see the output in the attached images.  <strong>Purple</strong> background is working, <strong>white</strong> background is busted.  I've also had the same unsuccessful results on an Ubuntu VM</p>
  
  <p><strong>Works:</strong> OS X 10.8.5; Ruby 2.1.1; XCODE 5.1.1
  <strong>Doesn't work:</strong> OS X 10.8.5 (VirtualBox); Ruby 2.1.1; XCODE 5.1.1
  <strong>Doesn't work:</strong> Ubuntu 14.04 (VirualBox); Ruby 2.1.2; XCODE n/a</p>
  
  <p><img src="https://i.stack.imgur.com/x05t9.png" alt="enter image description here"></p>
  
  <p><img src="https://i.stack.imgur.com/GEZYX.png" alt="enter image description here"></p>