ruby-docx / docx

a ruby library/gem for interacting with .docx files

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Errno::ENOENT: No such file or directory - word/styles.xml

theasteve opened this issue · comments

I'm getting the following error when I try to open a .docx file. Errno::ENOENT: No such file or directory - word/styles.xml in the following line.

4] pry(#)> doc = Docx::Document.open("./tmp/511676831_1.docx")
Errno::ENOENT: No such file or directory - word/styles.xml

Here is the file I'm trying to open:

https://www.dropbox.com/s/guhjbcevwu8nrb7/511676831_1.docx?dl=0

Hello, unfortunately I am getting the following error now with file link above and my own files.

My gem version from gem list: docx (0.6.1)
My ruby version: ruby 2.6.6p146 (2020-03-31 revision 67876)

Can you advice me any workaround?

Could you share the stacktrace of the error you saw here?

Yes, sure! Thank you for your answer.

stacktrace:

No such file or directory - word/styles.xml Traceback (most recent call last): 10: from func.rb:8:in

'
9: from /Users/tolubaev/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/docx-0.6.1/lib/docx/document.rb:61:in paragraphs' 8: from /Users/tolubaev/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/docx-0.6.1/lib/docx/document.rb:61:in map'
7: from /Users/tolubaev/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/nokogiri-1.11.5-x86_64-darwin/lib/nokogiri/xml/node_set.rb:238:in each' 6: from /Users/tolubaev/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/nokogiri-1.11.5-x86_64-darwin/lib/nokogiri/xml/node_set.rb:238:in upto'
5: from /Users/tolubaev/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/nokogiri-1.11.5-x86_64-darwin/lib/nokogiri/xml/node_set.rb:239:in block in each' 4: from /Users/tolubaev/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/docx-0.6.1/lib/docx/document.rb:61:in block in paragraphs'
3: from /Users/tolubaev/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/docx-0.6.1/lib/docx/document.rb:189:in parse_paragraph_from' 2: from /Users/tolubaev/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/docx-0.6.1/lib/docx/document.rb:48:in document_properties'
1: from /Users/tolubaev/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/docx-0.6.1/lib/docx/document.rb:88:in hyperlinks' /Users/tolubaev/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/docx-0.6.1/lib/docx/document.rb:94:in hyperlink_relationships': undefined method xpath' for nil:NilClass (NoMethodError)

Also I share my test code:

require 'docx'

# Create a Docx::Document object for our existing docx file
doc = Docx::Document.open('/Users/user1/test_proj/1.docx')

# Retrieve and display paragraphs
doc.paragraphs.each do |p|
  puts p
end