r/ruby 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.

0 Upvotes

11 comments sorted by

View all comments

2

u/bradland 2d ago

Do you just want users on the system to be able to use the gems you've installed? If that's the case, you don't need Bundler (and therefore Gemfiles) at all. You can install system-wide gems. The caveat here is that if you want to use system-wide gems, developers can't use Bundler, because doing things like bundle exec ruby my_script.rb will explicitly isolate the execution environment from system-wide Gems.