Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

undefined method each for path #11

Closed
HoffiMuc opened this issue Sep 15, 2023 · 8 comments
Closed

undefined method each for path #11

HoffiMuc opened this issue Sep 15, 2023 · 8 comments
Labels
bug Something isn't working

Comments

@HoffiMuc
Copy link

ruby: 3.2.2
jekyll 3.9.3

bundle info jekyll-drawio

  • jekyll-drawio (1.1.0)

on doing (in my markdown file):

{% drawio path="/assets/drawio/arch/Arch_Overview.drawio" page_number=0 height=400 %}

I get:

  Liquid Exception: undefined method `each' for "path=\"/assets/drawio/arch/Arch_Overview.drawio\" page_number=0 height=400 ":String in dev/arch/Arch_0_Overview.md
bundler: failed to load command: jekyll (/Users/hoffi/.gem/ruby/3.2.2/bin/jekyll)
/Users/hoffi/.gem/ruby/3.2.2/gems/jekyll-drawio-1.1.0/lib/jekyll-drawio.rb:17:in `initialize': undefined method `each' for "path=\"/assets/drawio/arch/Arch_Overview.drawio\" page_number=0 height=400 ":String (NoMethodError)

    variables.each do |variable|

any ideas?

@mutcher
Copy link
Owner

mutcher commented Sep 16, 2023

Hi @HoffiMuc,

Thank you for highlighting this issue.
So far, it looks like a problem related to the parsing of variables.

@mutcher mutcher added the bug Something isn't working label Sep 16, 2023
mutcher added a commit that referenced this issue Sep 16, 2023
@mutcher
Copy link
Owner

mutcher commented Sep 16, 2023

Fixed, will be released as part of 1.1.1

cc: @HoffiMuc

@HoffiMuc
Copy link
Author

HoffiMuc commented Sep 18, 2023

sorry to disturb again, but I still don't get it to fly with v1.1.1:

my jekyll project is in subfolder docs/ of my gitproject.

so my filesystem locations for Jekyll are:

  • <PRJROOT>/docs/Gemfile
  • <PRJROOT>/docs/_config.yml
  • <PRJROOT>/docs/assets/...
  • <PRJROOT>/docs/dev/arch/....md

the markdown file in which I want to render the drawio image is: <PRJROOT>/docs/dev/arch/Arch_0_Overview.md

in there I have

{% drawio path="/assets/arch/drawio/Arch_Overview.drawio" page_number=0 height=400 %}
/Users/hoffi/.gem/ruby/3.2.2/gems/jekyll-drawio-1.1.1/lib/diagram_extractor.rb:6:in `initialize':
    No such file or directory @ rb_sysopen - /assets/arch/drawio/Arch_Overview.drawio (Errno::ENOENT)
	from /Users/hoffi/.gem/ruby/3.2.2/gems/jekyll-drawio-1.1.1/lib/diagram_extractor.rb:6:in `open'
	from /Users/hoffi/.gem/ruby/3.2.2/gems/jekyll-drawio-1.1.1/lib/diagram_extractor.rb:6:in `extract_diagram'
	from /Users/hoffi/.gem/ruby/3.2.2/gems/jekyll-drawio-1.1.1/lib/jekyll-drawio.rb:68:in `render'
❯❯❯ tree <PRJROOT>/docs/assets
<PRJROOT>/docs/assets/
├── Chassis.png
└── arch/
    └── drawio/
        └── Arch_Overview.drawio

explicityly:

❯❯❯ ls -l <PRJROOT>/docs/assets/arch/drawio/Arch_Overview.drawio
-rw-r--r--@ 1 hoffi  staff  13347 Sep 18 09:47 docs/assets/arch/drawio/Arch_Overview.drawio

any ideas?

@mutcher
Copy link
Owner

mutcher commented Sep 18, 2023

Long story short. Use a relative path instead of an absolute.

The plugin works only with relative paths so far. I didn't find a way to recognize the project root folder. Maybe, jekyll can provide this info somehow.

{% drawio path="/assets/arch/drawio/Arch_Overview.drawio" page_number=0 height=400 %}

This code means that the plugin will try to open exactly the "/assets/arch/drawio/Arch_Overview.drawio" path disregarding the project root. I'll update the documentation accordingly.

@HoffiMuc
Copy link
Author

HoffiMuc commented Sep 18, 2023

./docs/dev/arch/Arch_0_Overview.md
./docs/assets/arch/drawio/Arch_Overview.drawio

with relative:

{% drawio path="../../assets/arch/drawio/Arch_Overview.drawio" page_number=0 height=400 %}

but still the same:

/Users/hoffi/.gem/ruby/3.2.2/gems/jekyll-drawio-1.1.1/lib/diagram_extractor.rb:6:in `initialize':
    No such file or directory @ rb_sysopen - ../../assets/arch/drawio/Arch_Overview.drawio (Errno::ENOENT)
	from /Users/hoffi/.gem/ruby/3.2.2/gems/jekyll-drawio-1.1.1/lib/diagram_extractor.rb:6:in `open'
	from /Users/hoffi/.gem/ruby/3.2.2/gems/jekyll-drawio-1.1.1/lib/diagram_extractor.rb:6:in `extract_diagram'
	from /Users/hoffi/.gem/ruby/3.2.2/gems/jekyll-drawio-1.1.1/lib/jekyll-drawio.rb:68:in `render'

any ideas @mutcher ?

@HoffiMuc
Copy link
Author

ah, found it out:

{% drawio path="assets/arch/drawio/Arch_Overview.drawio" page_number=0 height=400 %}

without a leading / in path before assets works ...

I apologize for the inconveniences.

@HoffiMuc
Copy link
Author

HoffiMuc commented Sep 18, 2023

unfortunately it doesn't work with github pages :(

(but I fear that's (currently) beyond what you want to achieve)

@mutcher or can you "guide" me on how to include a copy of jekyll-drawio in docs/_plugins ??

Gemfile

gem "github-pages", group: :jekyll_plugins

group :jekyll_plugins do
  gem "jekyll-feed", "~> 0.12"
  gem "jekyll-drawio", "~> 1.1.1"
end

github workflow error:

Resolving dependencies...
Bundler can't satisfy your Gemfile's dependencies.
Install missing gems with `bundle install`.
Warning:  github-pages can't satisfy your Gemfile's dependencies.
  Logging at level: debug
Configuration file: /github/workspace/./docs/_config.yml
      GitHub Pages: github-pages v228
      GitHub Pages: jekyll v3.9.3
             Theme: jekyll-theme-primer
      Theme source: /usr/local/bundle/gems/jekyll-theme-primer-0.6.0
         Requiring: jekyll-github-metadata
To use retry middleware with Faraday v2.0+, install `faraday-retry` gem
  Liquid Exception: Liquid syntax error (line 9): Unknown tag 'drawio' in dev/arch/Arch_0_Overview.md
/usr/local/bundle/gems/liquid-4.0.4/lib/liquid/document.rb:[23](https://github.com/hoffipublic/chassis/actions/runs/6...1#step:5:24):in `unknown_tag':
    Liquid syntax error (line 9): Unknown tag 'drawio' (Liquid::SyntaxError)

ADDENDUM: tried out many things, but couldn't get it to work with github actions workflow for github-pages

But if you consider implementing something for it, I am happy to assist!

@HoffiMuc
Copy link
Author

HoffiMuc commented Sep 18, 2023

but one last question: (as I am a total jekyll noob)

is it possible to have jekyll-drawio gem in _plugins so that I don't need the gem and github pages doesn't complain on your drawio tags???

Own answer: yes it is ... but doesn't help as github-pages run in safe mode, so won't work either

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants