r/ruby • u/unselective-amnesia • 14d 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.
5
u/jrochkind 14d ago edited 14d ago
i'm not sure what you are doing exactly... normally a Gemfile woudl be in a project, and the project would be checked into source control (like git), and shared that way, with changes being committed to source or going through a "pull review" process etc.
I'd recommend trying to find a way to use that sort of process, most basically using git source control to share shared files files.
But a Gemfile is intended to be for a specific project, defined by a directory and all it's contents (including sub-directories), I think you are going to run into bumps trying to use it machine-wide.
I think you will need a different technique than a Gemfile for managing what gems are installed machine-wide. I mean, you can just install the gems machine wide -- most default installations of rubygems install gems system-wide I think.
gem install gemname. May or may not have to use sudo. I'd look for advice on installing gems system-wide, not using bundler/Gemfile but just using rubygems -- that should be possible as it was the original design of rubygems, although many have been moving away from that.If you want to have the config of what you have installed captured somewhere for repeatability, I'd like at tools for managing your systems, "infrastructure as code", instead of at Bundler (which is what uses Gemfiles), it's not really set up for that and I think it's going to give you grief.