Why are gems installed in a directory with a different Ruby version than I’m running?

前端 未结 2 1798
[愿得一人]
[愿得一人] 2020-11-27 07:22

When I install a gem, it gets installed in a directory named 1.9.1, despite that not being the version of Ruby I have installed:

$ ruby -v
ruby 1.9.3p327 (20         


        
2条回答
  •  庸人自扰
    2020-11-27 07:33

    Note that the following is also for all later Ruby versions as of this writing, not just 1.9.2.


    Per the 1.9.2 release announcement:

    Standard library is installed in /usr/local/lib/ruby/1.9.1

    This version is a "library compatible version." Ruby 1.9.2 is almost 1.9.1 compatible, so the library is installed in the 1.9.1 directory.

    Even though it is installed in a differently-numbered directory, it is using 1.9.2. RubyGems can show all the directories it’s using via gem env.

    This ensures that a set of installed gems is only used by versions that they can actually run with (especially due to compiled C extensions), and that when upgrading to a newer, but “library compatible”, version, one doesn’t have to reinstall all gems.

提交回复
热议问题