# dev_container: Expand bare $VAR in addition to $\{VAR\} in Dockerfiles \(\#59280\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/832ab56db84a573468fcf0728ed001ad12e54bcd)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: 832ab56db84a573468fcf0728ed001ad12e54bcd

Requested commit: 832ab56db84a573468fcf0728ed001ad12e54bcd

Commit: 832ab56db84a573468fcf0728ed001ad12e54bcd

Tree: 471fab31c76127d9bbfbbbb7c2c99ef6681669ad

Author: Toru Nayuki

Committer: GitHub

## Message

````
dev_container: Expand bare $VAR in addition to ${VAR} in Dockerfiles (#59280)

When expanding build args in a dev container Dockerfile, only the braced
`${VAR}` form was substituted. The bare `$VAR` form — which is valid
Docker
syntax and common in real-world Dockerfiles — was passed through
verbatim.

For example, the Rails dev container images use:

```dockerfile
ARG RUBY_VERSION=3.4.4
FROM ghcr.io/rails/devcontainer/images/ruby:$RUBY_VERSION
```

This left `$RUBY_VERSION` unexpanded, so the subsequent `docker inspect`
/
build ran against the literal string `ruby:$RUBY_VERSION` and failed
with
an invalid reference format.

This adds `expand_dockerfile_var`, which substitutes both `${VAR}` and
bare
`$VAR`. Bare `$KEY` is only replaced when it is not immediately followed
by
a word character, so expanding `$RUBY_VERSION` does not partially
consume
`$RUBY_VERSION2`.

Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [ ] Unsafe blocks (if any) have justifying comments
- [ ] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Release Notes:

- Fixed dev container Dockerfiles not expanding build args written in
the bare `$VAR` form

Signed-off-by: Toru Nayuki <tnayuki@icloud.com>
````

## Parents

- [cccc7b2d4408ee75d5c2e9dadad2cc0b7f992dd0](https://git.cafe/gitcafe/zed/commit/cccc7b2d4408ee75d5c2e9dadad2cc0b7f992dd0?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/832ab56db84a573468fcf0728ed001ad12e54bcd?format=markdown)
