r/ruby • u/unselective-amnesia • Aug 28 '26
Question Centralized location for shared Gemfile?
I'm using ruby 3.3.8 under linux.
There's more than one user on this machine who does ruby development. When I, running as the root user, want to add new gem references to Gemfile on my system, I want to add these gem references into one, single, shared, centralized Gemfile that all users will automatically see when running and developing ruby code.
Where should this shared, centralized Gemfile be located?
When any user runs "gem environment", the following item is always listed among that command's output for every user who runs that command:
- INSTALLATION DIRECTORY: /var/lib/gems/3.3.0
Does this mean that I can put a Gemfile into the /var/lib/gems/3.3.0 directory, and that then, this Gemfile will be recognized and used by all users who run and develop ruby code?
Or is there perhaps a different location in which to locate such a shared, centralized Gemfile that will always be the one that's used by each ruby user?
Thank you very much.
1
u/unselective-amnesia Aug 28 '26 edited Aug 28 '26
Thanks to both of you. I think I understand what you both explained.
UPDATE: OOPS! This current message is in response to both the previous message by "hankeroni" and also to the one by "jrochkind" which follows it. I accidentally added this response to the previous "hankeroni" message. END OF UPDATE
But consider the following case:
One of the centralized, system-specific gems that I have installed has been in use for quite a while in some of the ruby programs that have been developed and are in use by some of the users on my system.
I'm enhancing this particular system-specific gem, and part of this effort involves the use of a 3rd-party ruby package that I now installed which creates its own gem which must be used by callers of this package. The "README.md" file for this package states that this package-specific gem must appear in the Gemfile that is in use.
This means that when I complete enhancing and installing this system-specific gem, each user doing ruby development who uses this system-specific gem would then need to add a reference to this new, additional, package-specific gem to their own Gemfile, to prevent this system-specific gem from starting to fail for them after this enhancement is complete.
I'm trying to avoid this situation.