Skip to content

heroku local fails to parse Procfile comments (lines starting with #) #3636

@stereoscott

Description

@stereoscott

Bug

heroku local throws a parse error on comment lines in Procfiles, which foreman has always supported.

Error: line 1 parse error: # -t is timeout, -c is concurrency

Procfile

web: bundle exec puma -C config/puma.rb
# -t is timeout, -c is concurrency
worker: bundle exec sidekiq -t 25 -q critical -q default

Cause

In src/lib/local/load-foreman-procfile.ts, the parser throws on any line containing a word character that doesn't match ^\s*\w+:. Comment lines (starting with #) contain word characters but don't match
that pattern.

const lines = content.split(/\r?\n/).filter((line, i) => {
  if (line.match(/\w/)) {
    if (!line.match(/^\s*\w+:/)) {
      throw new Error('line ' + (i + 1) + ' parse error: ' + line)
    }
  }
  return line.match(/\w/)
})

Suggested fix

Skip comment lines before the validation check:

const lines = content.split(/\r?\n/).filter((line, i) => {
  if (line.match(/^\s*#/)) return false
  if (line.match(/\w/)) {
    if (!line.match(/^\s*\w+:/)) {
      throw new Error('line ' + (i + 1) + ' parse error: ' + line)
    }
  }
  return line.match(/\w/)
})

Expected behavior

Comment lines starting with # should be ignored, consistent with the original foreman behavior and the Procfile format.

If this was intentional, it should be listed in the changelog as Procfiles that worked before will now raise an error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions