strange conflict with -rails- irb seemingly #8

Closed
fringd opened this Issue Aug 13, 2012 · 14 comments

Projects

None yet

4 participants

@fringd

Calling Spreadsheet.open works fine in a simple ruby script, but blows up my machine and (seemingly) never finishes when i try to use it in my rails app. Also blows up in a newly minted rails app that just has gem 'spreadsheet' added

Any guesses as to what might cause this? Core extensions maybe? Is there anything I can do to help debug this problem?

Thinking to just create a separate service to handle xls files, but would be easier to integrate it and access all my existing models and helpers, etc...

@fringd

So it seems that there is a problem not with rails, but with irb

to reproduce

irb
> require 'spreadsheet'
> Spreadsheet.open 'my_file.xls'

does anybody else have this problem with their files?

same problem with pry. eats up gigabytes of memory and grows and grows

@fringd

OKAY, so my real problem is that Workbook cannot be nicely printed...

> book = Spreadsheet.open 'my_file.xls';nil
=> nil

works fine, but then

> book

again waits forever...
there's some sort of infinite loop in the inspection code...

@fringd

the culprit seems to be that workbook#inspect loops over all its instance variables, and so does worksheet.... does worksheet keep a reference back to workbook somewhere?

@zdavatz
Owner

How was the file "my_file.xls" created? Did you create that file with MS Office, LibreOffice or with spreadsheet?

@victor-ono

I have the same problem with memory in irb under Ruby 1.9.3. No problem under 1.8.7

@zdavatz
Owner

interesting.

@BiggerNoise

Ditto. Same problem under irb, ruby 1.9.3 (installed from RVM if that matters).

@zdavatz
Owner

BiggerNoise: What is your sample code? What are you trying to do?

@BiggerNoise

Sample is:

require 'spreadsheet'
wb = Spreadsheet.open('./tmp/analysis.summary.xls')

If I try and run this under irb, it will exhaust the memory on my machine (starting from ~8GiB).

However, if I just put this in a script, it will run fine. I am able to see the worksheets and get row and column counts.

As far as what I am trying to accomplish, my ultimate goal is to take the spreadsheet that this analysis program produces and import it into my rails application. I may need to jump through some hoops to make that happen in a reasonably performant way, but the first step will be reading the spreadsheet.

Let me know if that answers your questions.

@zdavatz
Owner

Yes, it does answer my question. I do not know why irb is exhausting your memory. Are you on Linux or Windows or Mac?

@BiggerNoise

I am running Mac (10.7). And, if it helps:

andy@Andy-MBP:Crucible $ruby --version
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin11.4.0]

I did follow the advice that I found elsewhere and shutdown irb's inspection of the workbook:

wb = Spreadsheet.open('./tmp/analysis.summary.xls'); nil

That allows me to work in irb.

@zdavatz
Owner

Awesome! Can you post analysis.summary.xls somewhere please and link it here.

@BiggerNoise

I am trying to make a spreadsheet where I can reproduce the problem. Unfortunately, I can't post the one that is actually giving me grief. I will see what I can do and get back to you.

@zdavatz zdavatz closed this Feb 27, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment