zdavatz / spreadsheet

The Ruby Spreadsheet by ywesee GmbH
http://spreadsheet.ch
GNU General Public License v3.0
1.13k stars 240 forks source link

Move declaration of VERSION to an individual file #231

Closed taichi-ishitani closed 5 years ago

taichi-ishitani commented 5 years ago

Hi,

To use my forked spreadsheet and ruby-ole gems, I add dependencies to my GEMFILE like below.

if !ENV['USE_ORIGINAL_DEPENDENCIES']
  ['spreadsheet', 'rubyzip', 'ruby-ole'].each do |library|
    library_path = File.expand_path("../#{library}", __dir__)
    if Dir.exist?(library_path) && !ENV['USE_GITHUB_REPOSITORY']
      gem library, path: library_path
    else
      gem library, git: "https://github.com/taichi-ishitani/#{library}.git"
    end
  end
end

However, gem installation failed due to following error: https://travis-ci.org/rggen/rggen-spreadsheet-loader/jobs/499367300#L904

[!] There was an error while loading `spreadsheet.gemspec`: cannot load such file -- ole/storage
Does it try to require a relative path? That's been removed in Ruby 1.9. Bundler cannot continue.
 #  from /home/travis/build/rggen/rggen-spreadsheet-loader/vendor/bundle/ruby/2.4.0/bundler/gems/spreadsheet-576264365474/spreadsheet.gemspec:4
 #  -------------------------------------------
 #  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
 >  require 'spreadsheet'
 #  
 #  -------------------------------------------

The spreadsheet.gemspec file loads spreadsheet.rb file to get Spreadsheet::VERSION constant. The ruby-ole gem is loaded while loading spreadsheet.rb file and then this above error happened.

To fix above error, I created a new file named spreadsheet/version.rb and moved Spreadsheet::VERSION constant from spreadsheet.rb to spreadsheet/version.rb. Also, I edited spreadsheet.gemspec to load spreadsheet/version.rb instead of spreadsheet.rb.

zdavatz commented 5 years ago

Aligatoo!