thomthom / skippy

CLI Development tool for SketchUp extensions
MIT License
21 stars 5 forks source link

Skippy fails if Sketchup Viewer is installed #45

Closed Postur closed 3 years ago

Postur commented 3 years ago

fails in Win.rb pattern = "#{program_files}/{@Last Software,Google,SketchUp}/*SketchUp *" --- Will include the sketchup veiwer path

later version = File.basename(path).match(/[0-9.]+$/)[0].to_i --- will return undefined method for veiwer path as it does not contain numbers

this fources skippy to crash

my fix pattern = "#{program_files}/{@Last Software,Google,SketchUp}/*SketchUp 2*"

works for me because I don't use version not starting with 2

thomthom commented 3 years ago

Can you elaborate on how it fails? Do you get an error? If so, what's the error message and stack trace?

Postur commented 3 years ago
skippy sketchup:list
Known SketchUp versions:
Traceback (most recent call last):
        20: from C:/Ruby27-x64/bin/skippy:23:in `<main>'
        19: from C:/Ruby27-x64/bin/skippy:23:in `load'
        18: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/skippy-0.4.2.a/exe/skippy:2:in `<top (required)>'
        17: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/skippy-0.4.2.a/exe/skippy:2:in `require_relative'
        16: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/skippy-0.4.2.a/app/boot.rb:40:in `<top (required)>'
        15: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/thor-0.20.3/lib/thor/base.rb:466:in `start'
        14: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/thor-0.20.3/lib/thor.rb:387:in `dispatch'
        13: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/thor-0.20.3/lib/thor/invocation.rb:126:in `invoke_command'
        12: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/thor-0.20.3/lib/thor/command.rb:128:in `run'
        11: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/thor-0.20.3/lib/thor/command.rb:29:in `run'
        10: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/skippy-0.4.2.a/lib/skippy/cli.rb:71:in `method_missing'
         9: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/thor-0.20.3/lib/thor/base.rb:466:in `start'
         8: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/thor-0.20.3/lib/thor.rb:387:in `dispatch'
         7: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/thor-0.20.3/lib/thor/invocation.rb:126:in `invoke_command'
         6: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/thor-0.20.3/lib/thor/command.rb:27:in `run'
         5: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/skippy-0.4.2.a/app/commands/sketchup.rb:32:in `list'
         4: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/skippy-0.4.2.a/lib/skippy/os/win.rb:23:in `sketchup_apps'
         3: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/skippy-0.4.2.a/lib/skippy/os/win.rb:23:in `each'
         2: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/skippy-0.4.2.a/lib/skippy/os/win.rb:25:in `block in sketchup_apps'
         1: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/skippy-0.4.2.a/lib/skippy/os/win.rb:25:in `glob'
C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/skippy-0.4.2.a/lib/skippy/os/win.rb:28:in `block (2 levels) in sketchup_apps': undefined method `[]' for nil:NilClass (NoMethodError)

Edit: sorry for bad formatting, vscode includes github code block characters image

Postur commented 3 years ago

When running skippy sketchup:list

Postur commented 3 years ago

image The pattern is going to match with sketchup veiwer folder. (default install dir) And the version evaluation can't happen because this line: version = File.basename(path).match(/[0-9.]+$/)[0].to_i specifically: 'C:\Program Files\SketchUp\SketchUp Viewer'.match(/[0-9.]+$/) match will return nothing (nil). Therefore if you index into nothing with [0] you'll get a nil:NilClass NoMethodError.

A proper fix would be to exclude the Veiwer folder in the pattern. I just don't know the correct syntax. My fix works if you only use sketchup versions starting with a 2.

thomthom commented 3 years ago

I just pushed an update to the gem; 0.4.3 which should fix the problem. Skippy should be more robust to parsing the version number from that paths now.

Postur commented 3 years ago

Nice, that's great turnaround time, very fast. Thank you.