athityakumar/colorls

Cannot override icons - "undefined method `gsub' for nil (NoMethodError)"

Closed this issue · 1 comments

BACKGROUND: I just installed colorls a day or two ago, via gem install colorls, although I had to install a newer Ruby first, using homebrew. After the install completed, I couldn't run the command though; I ended up adding a symlink to /opt/homebrew/lib/ruby/gems/3.3.0/gems/colorls-1.4.6/exe/colorls in a directory on my path, and now it's working fine.

ISSUE: I'd like to customize some icons. Following the Customizations section of the README, I copied the yaml files to the prescribed location, and tried to change icons. After a few failures, I just tried to use the icon from the example in the README:

cls:              "\uF179"

Now, when I run colorls in a directory containing .cls files, I get an error:

/opt/homebrew/lib/ruby/gems/3.3.0/gems/colorls-1.4.6/lib/colorls/core.rb:341:in `fetch_string': undefined method `gsub' for nil (NoMethodError)

      logo  = value.gsub(/\\u[\da-f]{4}/i) { |m| [m[-4..].to_i(16)].pack('U') }
                   ^^^^^
        from /opt/homebrew/lib/ruby/gems/3.3.0/gems/colorls-1.4.6/lib/colorls/core.rb:354:in `block in ls_line'
        from /opt/homebrew/lib/ruby/gems/3.3.0/gems/colorls-1.4.6/lib/colorls/core.rb:353:in `each'
        from /opt/homebrew/lib/ruby/gems/3.3.0/gems/colorls-1.4.6/lib/colorls/core.rb:353:in `each_with_index'
        from /opt/homebrew/lib/ruby/gems/3.3.0/gems/colorls-1.4.6/lib/colorls/core.rb:353:in `ls_line'
        from /opt/homebrew/lib/ruby/gems/3.3.0/gems/colorls-1.4.6/lib/colorls/core.rb:119:in `block in ls'
        from /opt/homebrew/lib/ruby/gems/3.3.0/gems/colorls-1.4.6/lib/colorls/layout.rb:14:in `block in each_line'
        from /opt/homebrew/lib/ruby/gems/3.3.0/gems/colorls-1.4.6/lib/colorls/layout.rb:14:in `each'
        from /opt/homebrew/lib/ruby/gems/3.3.0/gems/colorls-1.4.6/lib/colorls/layout.rb:14:in `each_slice'
        from /opt/homebrew/lib/ruby/gems/3.3.0/gems/colorls-1.4.6/lib/colorls/layout.rb:14:in `each'
        from /opt/homebrew/lib/ruby/gems/3.3.0/gems/colorls-1.4.6/lib/colorls/layout.rb:14:in `each_line'
        from /opt/homebrew/lib/ruby/gems/3.3.0/gems/colorls-1.4.6/lib/colorls/core.rb:118:in `ls'
        from /opt/homebrew/lib/ruby/gems/3.3.0/gems/colorls-1.4.6/lib/colorls/core.rb:75:in `ls_dir'
        from /opt/homebrew/lib/ruby/gems/3.3.0/gems/colorls-1.4.6/lib/colorls/flags.rb:86:in `block in process_args'
        from /opt/homebrew/lib/ruby/gems/3.3.0/gems/colorls-1.4.6/lib/colorls/flags.rb:83:in `each'
        from /opt/homebrew/lib/ruby/gems/3.3.0/gems/colorls-1.4.6/lib/colorls/flags.rb:83:in `process_args'
        from /opt/homebrew/lib/ruby/gems/3.3.0/gems/colorls-1.4.6/lib/colorls/flags.rb:31:in `process'
        from /Users/jclark/bin/colorls:26:in `<main>'

Running in directories without .cls files works fine.

I'm running Mac OS Sonoma 14.3.1. Other version info:

❯ which ruby
/opt/homebrew/opt/ruby/bin/ruby
❯ ruby --version
ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [arm64-darwin23]
❯ colorls --version
1.4.6

...and you can ignore this. I just realized I was editing file_aliases.yaml, not files.yaml. Sorry for the noise.