bleskodev / rubyripper

Fork of the original rubyripper from code.google.com/p/rubyripper + some bugs fixes
125 stars 21 forks source link

Ruby 3.2.0 removes two deprecated methods, "Dir.exists?" and "File.exists?" #639

Closed HeWhoWatches closed 9 months ago

HeWhoWatches commented 1 year ago

After cloning from current master from and running "./configure --enable-gtk3" and "sudo make install", running rrip_gui in a terminal returns the following:

/usr/local/lib/rubyripper/preferences/load.rb:40:in `validateCustomFilename': undefined method `exists?' for File:Class (NoMethodError)

      @prefs.filename = customFilename if File.exists?(customFilename)
                                              ^^^^^^^^
Did you mean?  exist?
    from /usr/local/lib/rubyripper/preferences/load.rb:31:in `initialize'
    from /usr/local/lib/rubyripper/preferences/main.rb:43:in `new'
    from /usr/local/lib/rubyripper/preferences/main.rb:43:in `load'
    from /usr/local/bin/rrip_gui:66:in `start'
    from /usr/local/bin/rrip_gui:441:in `<main>'

It seems that there are two deprecated methods, "Dir.exists?" and "File.exists?", which have been removed in Ruby 3.2.0 https://www.ruby-lang.org/en/news/2022/12/25/ruby-3-2-0-released/ https://bugs.ruby-lang.org/issues/17391

Simply replacing "exists?" with "exist?" in the following files seems to do the job, to the untrained eye at least:

./lib/rubyripper/disc/scanDiscCdrdao.rb:    return false unless @fileAndDir.exists?(@tempfile)
./lib/rubyripper/preferences/load.rb:      readPreferencesFromFile() if File.exists?(@prefs.filename)
./lib/rubyripper/preferences/load.rb:      @prefs.filename = customFilename if File.exists?(customFilename)
./lib/rubyripper/preferences/load.rb:      if not @file.exists?(@prefs.cdrom)
./lib/rubyripper/system/fileAndDir.rb:  def exists?(filename)
./lib/rubyripper/system/fileAndDir.rb:    if File.exists?(file = File.expand_path(filename))
./lib/rubyripper/system/execute.rb:    return File.read(@filename) if File.exists?(@filename)
./lib/rubyripper/rubyripper.rb:    @fileScheme.dir.values.each{|dir| return false if @file.exists?(dir) }

Not sure if it's useful to anyone, but this is my cobbled together method for installing on OpenSUSE Tumbleweed:

## If using zypper:
sudo zypper install ruby3.2-rubygem-gettext.x86_64 cd-discid cdparanoia flac mp3gain vorbisgain
sudo zypper addrepo https://download.opensuse.org/repositories/multimedia:apps/openSUSE_Tumbleweed/multimedia:apps.repo
sudo zypper refresh
sudo zypper install wavegain

## If using DNF: https://en.opensuse.org/SDB:DNF
sudo dnf install ruby3.2-rubygem-gettext.x86_64 cd-discid cdparanoia flac mp3gain vorbisgain
sudo dnf config-manager --add-repo https://download.opensuse.org/repositories/multimedia:apps/openSUSE_Tumbleweed/multimedia:apps.repo
sudo dnf refresh
sudo dnf install wavegain

sudo gem install gtk3

mkdir ~/Projects/normalize
cd ~/Projects/normalize
wget http://savannah.nongnu.org/download/normalize/normalize-0.7.7.tar.gz
tar -xvf normalize-0.7.7.tar.gz
rm normalize-0.7.7.tar.gz
cd normalize-0.7.7
./configure
make
sudo make install
which normalize

cd ~/Projects
git clone https://github.com/bleskodev/rubyripper.git
cd ~/Projects/rubyripper/
./configure --enable-gtk3
## "NOT OK": discid cd-info diskutil
sudo make install
which rrip_gui
bleskodev commented 9 months ago

Thanks for all the details! I applied the fix. Do not hesitate to reply if the problem is not fixed.