Skip to content

Container: BUNDLE_PATH=/usr/local/bundle envvar overrides project's .bundle/config #42

@matthew-on-git

Description

@matthew-on-git

Problem

The dev-toolchain container image sets `BUNDLE_PATH=/usr/local/bundle` as an environment variable. Per Bundler's config precedence, envvars beat the project's `.bundle/config` file — so even with `BUNDLE_APP_CONFIG=/workspace/.bundle` (set by the Makefile's `RUBY_DOCKER_ENV`), the project's `BUNDLE_PATH: vendor/bundle` is silently ignored.

Result: `bundle exec` for project-pinned tools (rubocop, rspec) hits `Bundler::GemNotFound` because it's looking at `/usr/local/bundle` instead of the project's `vendor/bundle`.

Repro

```bash
docker run --rm -v "$PWD":/workspace -w /workspace \
-e BUNDLE_APP_CONFIG=/workspace/.bundle \
ghcr.io/devrail-dev/dev-toolchain:1.11.0 \
bash -c "bundle config | grep -E 'path|app_config'"

Output shows:

path Set for your local app (/workspace/.bundle/config): "vendor/bundle"

Set via BUNDLE_PATH: "/usr/local/bundle" ← envvar wins

```

Fix

Two options:

  1. Unset BUNDLE_PATH in the container's entrypoint or env config so the project's `.bundle/config` wins. Conceptually cleanest.

  2. Have the Makefile's RUBY_DOCKER_ENV explicitly override `BUNDLE_PATH` to a path consistent with the project config. Adds noise to RUBY_DOCKER_ENV but works:

```make
RUBY_DOCKER_ENV := $(if $(HAS_RUBY),-e BUNDLE_APP_CONFIG=/workspace/.bundle -e BUNDLE_PATH=vendor/bundle,)
```

Filed from a downstream tipsyhive Makefile sync to v1.11.0. Project-side patch applied with option 2.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions