Skip to content

Confusing behavior when append/prepend to PATH with no delimiter #285

Open
@schneems

Description

@schneems

Context

I was building a simple Ruby CNB when I came across this behavior. I prepended /layers/heroku_ruby/ruby/bin to the PATH, but found that echo $PATH ended up being the whole layer path twice:

$ docker run --entrypoint='/cnb/lifecycle/launcher' my-image 'echo $PATH'
/layers/heroku_ruby/ruby/bin/layers/heroku_ruby/ruby/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

That was confusing. I thought perhaps it was expecting a relative path instead of absolute, so I tried pretending bin and got this output:

$ docker run --entrypoint='/cnb/lifecycle/launcher' my-image 'echo $PATH'
bin/layers/heroku_ruby/ruby/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

That behavior was also confusing. After a lot of debugging, the cause was that I was pretending to PATH without specifying a delimiter.

Observations

Paths forward

  • The specification should state what behavior we expect when there's no delimiter as this behavior is currently undefined (by the spec)

In addition, I would like to propose some possible future changes to the spec:

  • Make env vars using prepend and append an error unless a delimiter is specified.
  • Possibly: Default the delimiter for PATH environment variables when none is present.
  • Possibly: Always place bin of a layer on the PATH even if a CNB modifies the PATH.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions