How do I require a specific version of a ruby gem?

前端 未结 2 778
自闭症患者
自闭症患者 2021-01-30 16:56

Specifically, the ruby-oci8 gem. I have both 1.0.7 and 2.0.4 installed. I want 1.0.7.

I can just require oci8, but I don\'t get the version I want.

irb         


        
相关标签:
2条回答
  • 2021-01-30 17:00

    My problem was twofold:

    1) confusing gem command syntax with that used in config.gem lines in a rails environment.rb configuration file.

    2) failing to issue a require command after the gem command.

    Proper usage in a script is:

    gem 'ruby-oci8', '=1.0.7'
    require 'oci8'           # example is confusing; file required (oci8.rb) is not 
                             # same name as gem, as is frequently the case
    

    Proper usage in a rails 2.3.x environment.rb file is:

    config.gem "ruby-oci8", :version=>'1.0.7'
    

    Thanks to the folks at http://www.ruby-forum.com/topic/109100

    0 讨论(0)
  • 2021-01-30 17:16

    Try the following syntax (instead of require):

    require_gem 'RMagick' , '=1.10'
    require_gem 'RMagick' , '>=1.10'
    require_gem 'rake', '>=0.7.0', '<0.9.0'
    
    0 讨论(0)
提交回复
热议问题