Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linemapped command output indents the trailing newline #582

Open
schneems opened this issue Jun 27, 2023 · 1 comment
Open

Linemapped command output indents the trailing newline #582

schneems opened this issue Jun 27, 2023 · 1 comment
Labels
bug Something isn't working libherokubuildpack

Comments

@schneems
Copy link
Contributor

schneems commented Jun 27, 2023

This code:

    const CMD_INDENT: &'static str = "      ";
//...
            let result = command
                .output_and_write_streams(
                    line_mapped(std::io::stdout(), add_prefix(CMD_INDENT)),
                    line_mapped(std::io::stderr(), add_prefix(CMD_INDENT)),
                )

Expected: That it only affects the outputlines of the command being run.
Actual: It adds indentation to the trailing newline which affects the next output.

Example:

- Bundle install
  - Running `BUNDLE_BIN="/layers/heroku_ruby/gems/bin" BUNDLE_CLEAN="1" BUNDLE_DEPLOYMENT="1" BUNDLE_GEMFILE="/workspace/Gemfile" BUNDLE_PATH="/layers/heroku_ruby/gems" BUNDLE_WITHOUT="development:test" bundle install`
      Fetching gem metadata from https://rubygems.org/..
      Fetching rake 13.0.6
      Installing rake 13.0.6
      Fetching rack 2.2.3
      Fetching webrick 1.7.0
      Using bundler 2.4.5
      Installing webrick 1.7.0
      Installing rack 2.2.3
      Bundle complete! 3 Gemfile dependencies, 4 gems now installed.
      Gems in the groups 'development' and 'test' were not installed.
      Bundled gems are installed into `/layers/heroku_ruby/gems`
              - Done (5.733s)

The bundle install command returns a newline as the very last character and the line_mapped prefix of is added to it and then the next line is appended with additional indentation.

The short term workaround is to add a println!() afterwards so it looks like this:

- Bundle install
  - Running `BUNDLE_BIN="/layers/heroku_ruby/gems/bin" BUNDLE_CLEAN="1" BUNDLE_DEPLOYMENT="1" BUNDLE_GEMFILE="/workspace/Gemfile" BUNDLE_PATH="/layers/heroku_ruby/gems" BUNDLE_WITHOUT="development:test" bundle install`
      Fetching gem metadata from https://rubygems.org/..
      Fetching rake 13.0.6
      Installing rake 13.0.6
      Fetching rack 2.2.3
      Fetching webrick 1.7.0
      Using bundler 2.4.5
      Installing webrick 1.7.0
      Installing rack 2.2.3
      Bundle complete! 3 Gemfile dependencies, 4 gems now installed.
      Gems in the groups 'development' and 'test' were not installed.
      Bundled gems are installed into `/layers/heroku_ruby/gems`

  - Done (5.733s)

However long term it would be nice to: not indent the final trailing newline or introduce a new method with that behavior

@edmorley
Copy link
Member

@schneems Is this issue fixed by the new build_output module? Or will it need a separate fix? Do we need any new tests in this repo for it, or is it covered by the tests added in #721?

@edmorley edmorley added the bug Something isn't working label Feb 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working libherokubuildpack
Projects
None yet
Development

No branches or pull requests

2 participants