Closed thestelz closed 2 years ago
I think this problem is in Ruby 2.5. Please use v2.6 or higher:
$ ruby25 -r pathname -e 'p Pathname.new("/usr/bin/cc").relative_path_from("/usr/bin")'
Traceback (most recent call last):
1: from -e:1:in `<main>'
/usr/local/lib/ruby/2.5/pathname.rb:508:in `relative_path_from': undefined method `cleanpath' for "/usr/bin":String (NoMethodError)
$ ruby26 -r pathname -e 'p Pathname.new("/usr/bin/cc").relative_path_from("/usr/bin")'
#<Pathname:cc>
@mgrachev Thanks for the update! I didn't know that was an issue. We do have it on our list to get our app updated to at least ruby 2.7
(shooting for 3.1
) this year.
@thestelz were you able to confirm that upgrading to ruby 2.7
fixed this issue?
@daviscale We haven't made it to our upgrade cycle just yet (had other issues bump this down in priority). I know that my colleague is working in ruby 3.0.1
and doesn't have this issue.
@daviscale I was able to update my application to ruby 2.7.5
(rails 5.2.8
) and that fixed the cleanpath
issue, but now I'm getting the following error:
ERROR: Error installing rubocop:
The last version of rubocop-ast (< 2.0, >= 1.17.0) to support your Ruby & RubyGems was 1.17.0. Try installing it with `gem install rubocop-ast -v 1.17.0` and then running the current command again
rubocop-ast requires Ruby version >= 2.6.0. The current ruby version is 2.5.0.
My gemfile for rubocop:
gem 'rubocop', '~> 1.29.1', require: false
Gemfile.lock
:
rubocop (1.29.1)
parallel (~> 1.10)
parser (>= 3.1.0.0)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.17.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 3.0)
Is this an issue with rubocop itself or is there something else going on that I can't think of?
@daviscale Nvm. I'm dumb and forgot to update the reviewdog.yml
file to use ruby 2.7.5
-ruby-version: 2.5.3
+ruby-version: 2.7.5
Everything is now working as expected. Thank you for your help!
I'm not sure if this is the right repo to post this issue, but we've been getting the following error:
undefined method 'cleanpath' for "/home/runner/work/NAME/NAME":String
(whereNAME
is the name of our project).Rails:
5.2.4.4
Ruby:
2.5.3
RuboCop:
1.22.2
config file:
stacktrace
undefined method 'cleanpath' for "/home/runner/work/NAME/NAME":String /opt/hostedtoolcache/Ruby/2.5.3/x64/lib/ruby/2.5.0/pathname.rb:508:in `relative_path_from' /home/runner/work/_actions/reviewdog/action-rubocop/v2/rdjson_formatter/rdjson_formatter.rb:117:in `convert_path' /home/runner/work/_actions/reviewdog/action-rubocop/v2/rdjson_formatter/rdjson_formatter.rb:40:in `build_diagnostic' /home/runner/work/_actions/reviewdog/action-rubocop/v2/rdjson_formatter/rdjson_formatter.rb:21:in `block in file_finished' /home/runner/work/_actions/reviewdog/action-rubocop/v2/rdjson_formatter/rdjson_formatter.rb:18:in `each' /home/runner/work/_actions/reviewdog/action-rubocop/v2/rdjson_formatter/rdjson_formatter.rb:18:in `file_finished' /opt/hostedtoolcache/Ruby/2.5.3/x64/lib/ruby/gems/2.5.0/gems/rubocop-1.22.2/lib/rubocop/formatter/formatter_set.rb:50:in `block in file_finished' /opt/hostedtoolcache/Ruby/2.5.3/x64/lib/ruby/gems/2.5.0/gems/rubocop-1.22.2/lib/rubocop/formatter/formatter_set.rb:50:in `each' /opt/hostedtoolcache/Ruby/2.5.3/x64/lib/ruby/gems/2.5.0/gems/rubocop-1.22.2/lib/rubocop/formatter/formatter_set.rb:50:in `file_finished' /opt/hostedtoolcache/Ruby/2.5.3/x64/lib/ruby/gems/2.5.0/gems/rubocop-1.22.2/lib/rubocop/runner.rb:213:in `file_finished' /opt/hostedtoolcache/Ruby/2.5.3/x64/lib/ruby/gems/2.5.0/gems/rubocop-1.22.2/lib/rubocop/runner.rb:125:in `process_file' /opt/hostedtoolcache/Ruby/2.5.3/x64/lib/ruby/gems/2.5.0/gems/rubocop-1.22.2/lib/rubocop/runner.rb:101:in `block in each_inspected_file' /opt/hostedtoolcache/Ruby/2.5.3/x64/lib/ruby/gems/2.5.0/gems/rubocop-1.22.2/lib/rubocop/runner.rb:100:in `each' /opt/hostedtoolcache/Ruby/2.5.3/x64/lib/ruby/gems/2.5.0/gems/rubocop-1.22.2/lib/rubocop/runner.rb:100:in `reduce' /opt/hostedtoolcache/Ruby/2.5.3/x64/lib/ruby/gems/2.5.0/gems/rubocop-1.22.2/lib/rubocop/runner.rb:100:in `each_inspected_file' /opt/hostedtoolcache/Ruby/2.5.3/x64/lib/ruby/gems/2.5.0/gems/rubocop-1.22.2/lib/rubocop/runner.rb:86:in `inspect_files' /opt/hostedtoolcache/Ruby/2.5.3/x64/lib/ruby/gems/2.5.0/gems/rubocop-1.22.2/lib/rubocop/runner.rb:47:in `run' /opt/hostedtoolcache/Ruby/2.5.3/x64/lib/ruby/gems/2.5.0/gems/rubocop-1.22.2/lib/rubocop/cli/command/execute_runner.rb:26:in `block in execute_runner' /opt/hostedtoolcache/Ruby/2.5.3/x64/lib/ruby/gems/2.5.0/gems/rubocop-1.22.2/lib/rubocop/cli/command/execute_runner.rb:52:in `with_redirect' /opt/hostedtoolcache/Ruby/2.5.3/x64/lib/ruby/gems/2.5.0/gems/rubocop-1.22.2/lib/rubocop/cli/command/execute_runner.rb:25:in `execute_runner' /opt/hostedtoolcache/Ruby/2.5.3/x64/lib/ruby/gems/2.5.0/gems/rubocop-1.22.2/lib/rubocop/cli/command/execute_runner.rb:17:in `run' /opt/hostedtoolcache/Ruby/2.5.3/x64/lib/ruby/gems/2.5.0/gems/rubocop-1.22.2/lib/rubocop/cli/command.rb:11:in `run' /opt/hostedtoolcache/Ruby/2.5.3/x64/lib/ruby/gems/2.5.0/gems/rubocop-1.22.2/lib/rubocop/cli/environment.rb:18:in `run' /opt/hostedtoolcache/Ruby/2.5.3/x64/lib/ruby/gems/2.5.0/gems/rubocop-1.22.2/lib/rubocop/cli.rb:71:in `run_command' /opt/hostedtoolcache/Ruby/2.5.3/x64/lib/ruby/gems/2.5.0/gems/rubocop-1.22.2/lib/rubocop/cli.rb:78:in `execute_runners' /opt/hostedtoolcache/Ruby/2.5.3/x64/lib/ruby/gems/2.5.0/gems/rubocop-1.22.2/lib/rubocop/cli.rb:47:in `run' /opt/hostedtoolcache/Ruby/2.5.3/x64/lib/ruby/gems/2.5.0/gems/rubocop-1.22.2/exe/rubocop:12:in `block in'
/opt/hostedtoolcache/Ruby/2.5.3/x64/lib/ruby/2.5.0/benchmark.rb:308:in `realtime'
/opt/hostedtoolcache/Ruby/2.5.3/x64/lib/ruby/gems/2.5.0/gems/rubocop-1.22.2/exe/rubocop:12:in `'
/opt/hostedtoolcache/Ruby/2.5.3/x64/bin/rubocop:23:in `load'
/opt/hostedtoolcache/Ruby/2.5.3/x64/bin/rubocop:23:in `'