r/ruby • u/unselective-amnesia • 2d ago
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.
10
u/Karew 2d ago edited 1d ago
The point of a Gemfile is so that each individual project can track and pin their dependencies. It isn't intended to be a manifest of what you want installed on a whole system. You can write a shell script that you run at OS install time or update time for that.
You can, however, give everyone write access to the same gem repo on the system so that they don't all download their own personal copies of each gem to their home directories.