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

The generate function grabs stderr #9517

Closed
acco93 opened this issue Nov 11, 2024 · 3 comments
Closed

The generate function grabs stderr #9517

acco93 opened this issue Nov 11, 2024 · 3 comments
Labels
bug Something isn't working triaged Jira issue has been created for this

Comments

@acco93
Copy link

acco93 commented Nov 11, 2024

Describe the Bug

The generate function grabs stderr.

Expected Behavior

I would expect only stdout to be retrieved.

Steps to Reproduce

$output = generate(command, arg1, arg2, ..., argN)

Environment

  • Puppet 8
  • Debian 12

Additional Context

Probably related to combine: true introduced in ee46e78

@acco93 acco93 added the bug Something isn't working label Nov 11, 2024
@cthorn42 cthorn42 added the triaged Jira issue has been created for this label Nov 19, 2024
Copy link

Migrated issue to PUP-12086

@joshcooper
Copy link
Contributor

@acco93 The generate function has always combined stdout and stderr

❯ cat /tmp/combine.sh 
#!/bin/bash

echo "Write to stdout" >&1
echo "Write to stderr" >&2 

❯ git checkout 8.6.0 && bundle update
...

❯ bundle exec puppet apply -e 'notice(generate("/tmp/combine.sh", "one", "two"))' 
Info: Loading facts
Info: Loading facts
Notice: Scope(Class[main]): Write to stdout
Write to stderr

Notice: Compiled catalog for localhost in environment production in 0.01 seconds
...

❯ git checkout main && bundle update
...

❯ bundle exec puppet apply -e 'notice(generate("/tmp/combine.sh", "one", "two"))'
Info: Loading facts
Info: Loading facts
Notice: Scope(Class[main]): Write to stdout
Write to stderr

Notice: Compiled catalog for localhost in environment production in 0.01 seconds
...

Note this is using puppet's execution implementation. Puppetserver uses a different implementation. If you're seeing the behavior in puppetserver, then I'd recommend enabling debug and you should see this message about them being combined before and after: https://github.com/puppetlabs/clj-shell-utils/blob/8a8ac4d60d3d65911a459b2af1df04684b31e5a4/src/java/com/puppetlabs/puppetserver/ShellUtils.java#L89

@acco93
Copy link
Author

acco93 commented Jan 8, 2025

Got it, thanks for clarifying!

@acco93 acco93 closed this as completed Jan 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triaged Jira issue has been created for this
Projects
None yet
Development

No branches or pull requests

3 participants