Rubocop doesn't work

Please teach me how to make rubocop work in Tumbleweed… I’m surprised, really:


$ rubocop -a app/controllers/contacts_controller.rb  
If 'rubocop' is not a typo you can use command-not-found to lookup the package that contains it, like this:
    cnf rubocop


cat /etc/os-release
NAME="openSUSE Tumbleweed"
# VERSION="20220801"
ID="opensuse-tumbleweed"
ID_LIKE="opensuse suse"
VERSION_ID="20220801"
PRETTY_NAME="openSUSE Tumbleweed"
ANSI_COLOR="0;32"
CPE_NAME="cpe:/o:opensuse:tumbleweed:20220801"
BUG_REPORT_URL="https://bugs.opensuse.org"
HOME_URL="https://www.opensuse.org/"
DOCUMENTATION_URL="https://en.opensuse.org/Portal:Tumbleweed"
LOGO="distributor-logo-Tumbleweed"


gem env
RubyGems Environment:
  - RUBYGEMS VERSION: 3.3.7
  - RUBY VERSION: 3.1.2 (2022-04-12 patchlevel 20) [x86_64-linux-gnu]
  - INSTALLATION DIRECTORY: /usr/lib64/ruby/gems/3.1.0
  - USER INSTALLATION DIRECTORY: /home/alex/.local/share/gem/ruby/3.1.0
  - RUBY EXECUTABLE: /usr/bin/ruby.ruby3.1
  - GIT EXECUTABLE: /usr/bin/git
  - EXECUTABLE DIRECTORY: /usr/bin
  - SPEC CACHE DIRECTORY: /home/alex/.local/share/gem/specs
  - SYSTEM CONFIGURATION DIRECTORY: /etc
  - RUBYGEMS PLATFORMS:
     - ruby
     - x86_64-linux
  - GEM PATHS:
     - /usr/lib64/ruby/gems/3.1.0
     - /home/alex/.local/share/gem/ruby/3.1.0
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => true
     - :bulk_threshold => 1000
     - :benchmark => false
     - :install => "--format-executable --no-user-install"
     - "install" => "--format-executable --no-user-install"
     - :format_executable => true
     - :update => "--format-executable --no-user-install"
     - "update" => "--format-executable --no-user-install"
     - :sources => "https://rubygems.org"]
  - REMOTE SOURCES:
     - https://rubygems.org
  - SHELL PATH:
     - /home/alex/bin
     - /usr/local/bin
     - /usr/bin
     - /bin
     - /snap/bin



gem list

*** LOCAL GEMS ***

abbrev (default: 0.1.0)
abstract_method (1.2.1)
actioncable (7.0.3.1)
actionmailbox (7.0.3.1)
actionmailer (7.0.3.1)
actionpack (7.0.3.1, 7.0.3)
actiontext (7.0.3.1)
actionview (7.0.3.1, 7.0.3)
activejob (7.0.3.1)
activemodel (7.0.3.1)
activerecord (7.0.3.1)
activestorage (7.0.3.1)
activesupport (7.0.3.1, 7.0.3)
ast (2.4.2)
base64 (default: 0.1.1)
benchmark (default: 0.2.0)
bigdecimal (default: 3.1.1)
builder (3.2.4)
bundler (2.3.19, 2.3.13, 2.3.9, default: 2.3.7)
cfa (1.0.2)
cfa_grub2 (2.0.0)
cgi (default: 0.3.1)
cheetah (1.0.0)
concurrent-ruby (1.1.10)
crass (1.0.6)
csv (default: 3.2.2)
date (default: 3.2.2)
debug (1.4.0)
delegate (default: 0.2.0)
did_you_mean (default: 1.6.1)
digest (default: 3.1.0)
dotenv (2.8.1)
drb (default: 2.1.0)
english (default: 0.7.1)
erb (default: 2.2.3)
error_highlight (default: 0.3.0)
erubi (1.10.0)
etc (default: 1.3.0)
ethon (0.15.0)
fast_gettext (2.2.0)
fcntl (default: 1.0.1)
ffi (1.15.5)
fiddle (default: 1.1.0)
fileutils (default: 1.6.0)
find (default: 0.1.1)
forwardable (default: 1.3.2)
gem2rpm (0.10.1)
getoptlong (default: 0.1.1)
globalid (1.0.0)
highline (2.0.3)
i18n (1.12.0, 1.10.0)
io-console (default: 0.5.11)
io-nonblock (default: 0.1.0)
io-wait (default: 0.2.1)
ipaddr (default: 1.2.4)
irb (default: 1.4.1)
json (default: 2.6.1)
logger (default: 1.5.0)
loofah (2.18.0)
mail (2.7.1)
marcel (1.0.2)
matrix (0.4.2)
method_source (1.0.0)
mini_mime (1.1.2)
minitest (5.15.0)
mutex_m (default: 0.1.1)
net-ftp (0.1.3)
net-http (default: 0.2.0)
net-imap (0.2.3)
net-pop (0.1.1)
net-protocol (default: 0.1.2)
net-smtp (0.3.1)
nio4r (2.5.8)
nkf (default: 0.1.1)
nokogiri (1.13.6)
observer (default: 0.1.1)
open-uri (default: 0.2.0)
open3 (default: 0.1.1)
openssl (default: 3.0.0)
options (2.3.2)
optparse (default: 0.2.0)
ostruct (default: 0.5.2)
parallel (1.22.1)
parser (3.1.2.0)
pastel (0.8.0)
pathname (default: 0.2.0)
pg (1.4.2)
power_assert (2.0.1)
pp (default: 0.3.0)
prettyprint (default: 0.1.1)
prime (0.1.2)
progress_bar (1.3.3)
pstore (default: 0.1.1)
psych (default: 4.0.3)
racc (default: 1.6.0)
rack (2.2.4)
rack-test (2.0.2, 0.6.3)
rails (7.0.3.1)
rails-dom-testing (2.0.3)
rails-html-sanitizer (1.4.3)
railties (7.0.3.1, 7.0.3)
rainbow (3.1.1)
rake (13.0.6)
rbs (2.1.0)
rdoc (default: 6.4.0)
readline (default: 0.0.3)
readline-ext (default: 0.1.4)
regexp_parser (2.5.0)
reline (default: 0.3.0)
resolv (default: 0.2.1)
resolv-replace (default: 0.1.0)
rexml (3.2.5)
rinda (default: 0.1.1)
rss (0.2.9)
rubocop (1.26.0)
rubocop-ast (1.19.1)
ruby-augeas (0.5.0)
ruby-dbus (0.18.1)
ruby-fann (1.3.2)
ruby-progressbar (1.11.0)
ruby2_keywords (default: 0.0.5)
rubygems-update (3.3.19)
securerandom (default: 0.1.1)
set (default: 1.0.2)
shellwords (default: 0.1.0)
simpleidn (0.2.1)
singleton (default: 0.1.1)
stringio (default: 3.0.1)
strscan (default: 3.0.1)
syslog (default: 0.1.0)
tempfile (default: 0.1.2)
terminal-table (3.0.2)
test-unit (3.5.3)
thor (1.2.1)
time (default: 0.2.0)
timeout (default: 0.2.0)
tmpdir (default: 0.1.2)
tsort (default: 0.1.0)
tty-color (0.6.0)
tty-cursor (0.7.1)
tty-pie (0.4.0)
typeprof (0.21.2)
typhoeus (1.4.0)
tzinfo (2.0.5, 2.0.4)
un (default: 0.2.0)
unf (0.1.4)
unf_ext (0.0.8.2)
unicode-display_width (2.2.0)
uri (default: 0.11.0)
weakref (default: 0.1.1)
websocket-driver (0.7.5)
websocket-extensions (0.1.5)
yaml (default: 0.2.0)
zeitwerk (2.6.0)
zlib (default: 2.1.1)

I have tried installing different versions of rubocop. But it doesn’t help. :frowning:

So - did you run suggested command? What is the output?

It’s in package ruby3.1-rubygem-rubocop.

Your gem list shows that you are not using the actual ruby3.1-rubygem-rubocop-1.31.2-1.1. but an older version (1.26.0).
Did you also try to use the full path for the command (shouldn’t normaly matter):

|/usr/bin/rubocop|
|---|
|/usr/bin/rubocop-1.31.2[TABLE]
[TR]
[TD]/usr/bin/rubocop.ruby3.1|
|/usr/bin/rubocop.ruby3.1-1.31.2|


[/TD]
[/TR]
[/TABLE]

As you are using an older version you have to adapt the version number…

I think the version doesn’t matter. The result of gem install rubocop is not successful.

Right. Indeed:


cnf rubocop
                          
The program 'rubocop' can be found in the following package:
  * ruby3.1-rubygem-rubocop  path: /usr/bin/rubocop, repository: zypp (repo-oss) ]

Try installing with:
    sudo zypper install ruby3.1-rubygem-rubocop


But this is really the first time I’ve seen it. This is contrary to the rubocop installation instructions.
As far as I remember, on Fedora the installation of rubocop is done in the classic way, this misled me…

Thank you!