In the past, Bundler used to respect the way Gentoo Linux sets up Ruby (abridged output):
$ gem env RubyGems Environment: - RUBYGEMS VERSION: 3.1.6 - RUBY VERSION: 2.7.5 (2021-11-24 patchlevel 203) [x86_64-linux] - INSTALLATION DIRECTORY: /usr/lib64/ruby/gems/2.7.0 - USER INSTALLATION DIRECTORY: /home/xhire/.gem/ruby/2.7.0 - GEM CONFIGURATION: - "install" => "--install-dir /home/xhire/.gem/ruby/2.7.0" - "uninstall" => "--install-dir /home/xhire/.gem/ruby/2.7.0" - "update" => "--install-dir /home/xhire/.gem/ruby/2.7.0"
As you can see, it makes gems installed to a user’s directory, not system-wide. However, bundler doesn’t respect that:
$ bundle install Fetching gem metadata from https://rubygems.org/........... Fetching gem metadata from https://rubygems.org/. Resolving dependencies... Using rake 13.0.6 Following files may not be writable, so sudo is needed: /usr/bin /usr/lib64/ruby/gems/2.7.0 /usr/lib64/ruby/gems/2.7.0/build_info /usr/lib64/ruby/gems/2.7.0/cache /usr/lib64/ruby/gems/2.7.0/doc /usr/lib64/ruby/gems/2.7.0/extensions /usr/lib64/ruby/gems/2.7.0/gems /usr/lib64/ruby/gems/2.7.0/specifications Using concurrent-ruby 1.1.10 Using i18n 1.10.0 Using minitest 5.15.0 Using activesupport 126.96.36.199 Using builder 3.2.4 Using erubi 1.10.0 Using mini_portile2 2.8.0 Using racc 1.6.0 Fetching nokogiri 1.13.4 (x86_64-linux) Your user account isn't allowed to install to the system RubyGems. You can cancel this installation and run: bundle install --path vendor/bundle to install the gems into ./vendor/bundle/, or you can enter your password and install the bundled gems to RubyGems using sudo. Password:
Man page bundle-install(1) says:
By default, Bundler installs gems to the same location as gem install.
This is not true.
To fix this misbehaviour, add a line similar to the following one (change your username and the version) to a shell startup script like
~/.bash_profile or similar (depending on the shell you use):
Tagged with: Ruby