How to require a user-installed gem in ruby when system-wide gem with higher version is also available?

StackOverflow https://stackoverflow.com/questions/21825349

  •  12-10-2022
  •  | 
  •  

Вопрос

I have two versions of a gem installed: system-wide 1.3.2, and user-installed 1.0.0.

I need to use only version 1.0.0, which is installed in my home dir. Is there a way to tell gem to prefer user-installed gems?

Это было полезно?

Решение

You can specify which gem version to use by using the gem command before you require it.

gem 'foo', '1.0.0'
require 'foo'

Другие советы

  1. You can specify the GEM_PATH variable, pointing to the version 2, GEM_HOME to path to gems for the selected interpreter, and specify PATH to binary folder at the beginning of all PATHs, which contains the version.

  2. Use , or apps to control / apps per project.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top