diff --git a/.github/workflows/read-only.yml b/.github/workflows/read-only.yml new file mode 100644 index 000000000000..9db9822384c2 --- /dev/null +++ b/.github/workflows/read-only.yml @@ -0,0 +1,39 @@ +name: read-only + +on: + pull_request: + + push: + branches: + - master + +concurrency: + group: ci-${{ github.ref }}-${{ github.workflow }} + cancel-in-progress: true + +permissions: # added using https://github.com/step-security/secure-workflows + contents: read + +defaults: + run: + shell: bash + +jobs: + read-only: + name: Bundler on read-only system (${{ matrix.ruby.name }}) + runs-on: ubuntu-24.04 + strategy: + fail-fast: false + matrix: + ruby: + - { name: ruby-3.1, value: 3.1.6 } + - { name: ruby-3.2, value: 3.2.6 } + - { name: ruby-3.3, value: 3.3.6 } + - { name: ruby-3.4, value: 3.4.1 } + + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + - name: Basic usage on a read-only filesystem + run: docker run --mount type=bind,source=.,target=/rubygems --rm --read-only ruby:${{ matrix.ruby.value }} ruby -I/rubygems/bundler/lib -r'bundler/inline' -e 'gemfile {}; puts :ok' + + timeout-minutes: 15 diff --git a/bundler/lib/bundler/plugin/index.rb b/bundler/lib/bundler/plugin/index.rb index c2ab8f90da4f..0b1234bbf3ad 100644 --- a/bundler/lib/bundler/plugin/index.rb +++ b/bundler/lib/bundler/plugin/index.rb @@ -34,6 +34,10 @@ def initialize rescue GenericSystemCallError # no need to fail when on a read-only FS, for example nil + rescue ArgumentError => e + # ruby 3.4 checks writability in Dir.tmpdir + raise unless e.message&.include?("could not find a temporary directory") + nil end load_index(local_index_file) if SharedHelpers.in_bundle? end diff --git a/bundler/spec/bundler/plugin/index_spec.rb b/bundler/spec/bundler/plugin/index_spec.rb index e1f10a0db7d2..565fc9b088e3 100644 --- a/bundler/spec/bundler/plugin/index_spec.rb +++ b/bundler/spec/bundler/plugin/index_spec.rb @@ -193,12 +193,4 @@ include_examples "it cleans up" end end - - describe "readonly disk without home" do - it "ignores being unable to create temp home dir" do - expect_any_instance_of(Bundler::Plugin::Index).to receive(:global_index_file). - and_raise(Bundler::GenericSystemCallError.new("foo", "bar")) - Bundler::Plugin::Index.new - end - end end