Ruby Roo Loaderror: Cannot Load Such File -- Spreadsheet/Note

Ruby roo LoadError: cannot load such file -- spreadsheet/note

Try to fix version of "spreadsheet" gem to "0.9.0".

In my case adding

gem "spreadsheet", "0.9.0"

right before roo gem made a trick.

ruby on rails roo gem cannot load zip/zipfilesystem

rubyzip v1.0.0 was released 29 August 2013: https://github.com/rubyzip/rubyzip/releases

This is a new major version number, and more than one gem or project that depends on this has been caught out by the break with backwards-compatibility.

The quickest "get my code working like before" fix is to alter Gemfile reference to rubyzip:

gem 'rubyzip', '< 1.0.0'

In the longer-term, this may not be the best fix, it depends on how and/or why you are using rubyzip. I expect some gem publishers such as roo's authors will need to figure out how to transition nicely so that their own users don't end up with simultaneous requirements for incompatible versions of rubyzip.


Just opinion:

Seeing this in action has actually made me much less a fan of Ruby gems semantic versioning for major versions. If I ever break with backwards compatibility on any of my own projects, I think I'll just start a new gem, and put a notice on the old gem.

Rails - getting errors installing the spreadsheet gem using rubygems

Check your gems:

gem list

Check for that one being installed:

gem list | grep spreadsheet 

Follow the instructions for use at http://rubygems.org/gems/spreadsheet which also talks about Development Dependencies:

hoe ~> 2.13   
rdoc ~> 3.10

There is a great "getting started" guide at http://spreadsheet.rubyforge.org/files/GUIDE_txt.html

The wiki - http://spreadsheet.ch/ is also useful.

Getting uninitialized constant Student::Roo error while importing csv file in rails

First, after @SKV comment: the correct name for CSV class is Roo::CSV and not Roo::Csv.

If the error persists, then it means that any of the Roo classes (Roo::CSV, Roo::Excel, etc) is not defined at this point in Student class. This probably means that, while you probably added the roo gem to your Gemfile and bundled, you need to require roo wherever you want to use the gem. This is mentioned in the gem docs.

Add require 'roo' to the top of student.rb file and it should work fine:

# student.rb
require 'roo' # <====

class Student < ActiveRecord::Base
def self.open_spreadsheet(file)
...
end
end

File does not exist, while using roo in Ruby-on-rails

It would be worth using the File class here rather than creating the path and gsubbing file separators. For example:

file = File.join(RAILS_ROOT, 'public', 'data', 'import.xls')

I'm pretty sure you don't need to worry too much about using backslashes for file separators though in Windows (I've stopped developing on windows though so can't test).

You can then test whether ruby thinks the file exists by doing File.exists?(file) prior to doing anything roo-specific.

Also, are you running your rails app and console as different users? That might cause some permissions problems in one but not the other.

How to omit empty rows using last_row in Roo Rails

You might want to chain the map call off of a reject filter like this example

You may just need to change the map line to this (assuming the missing rows all look like those above):
(2..spreadsheet.last_row).reject{|i| spreadsheet.row(i)[0] }.map do |i|

This is assuming the blank rows return as nil and that blank rows will always have all four desired fields blank as shown in the image. The reject call tests to see if spreadsheet.row(i)[0], the id column, is nil, if so the item is rejected from the list output given to map



Related Topics



Leave a reply



Submit