[core] Skip repeating the output again when an sh command fails#19545
Conversation
If print_command_output is being set then the output was already printed while the command was running. This only spams the logs too much, and when fastlane is used via bundler and an exception is being raised, the output is even repeated a 3rd time.
joshdholtz
left a comment
There was a problem hiding this comment.
I'm so torn on this 😱 I've totally seen what you saw with large outputs that is very overwhelming but I also like how this error would print out as red (vs the purple/pink) so it was very easy to find the error 🤔
I almost think I'd like this output to be truncated to some length and then maybe have the full output stored somewhere so that it can be seen a bit easier? 🤔
I know this is kind of asking a lot 😅 So I wouldn't mind helping more if you noodle on ideas or by adding some commits but I'd love to know your thoughts!
I really appreciate the effort on this though ❤️
|
Yeah, I feel your "pain" when you say you were torn. I also wasn't sure which approach is the better and kept jumping between "let's just omit it" and "let's add a new parameter so people can control this behaviour!" My internal argumentation as for why I went with option a) (omitting) was that I had a hard time seeing actual value in duplicating the output. And based on that I thought not keeping it around as a default case would benefit more users than adding a customisation option that nobody would even see 😅
Yeah, I guess that makes sense, especially if your output isn't as bad as mine.
That is more or less available, right? Once you pass a callback, of course. Another thought I had while looking at it, but got afraid as that feels like a bigger change, is that I could change from What do you think? |
|
Friendly reminder to @joshdholtz, if you have some time please don't forget this small PR ;) Also, warm welcome to the newcomer 👶 👋 |
|
@tutipeti Ahhhh, I missed your response! Thank you for the friendly ping ❤️ |
…st 500 characters
|
@joshdholtz I didn't really have a better idea so ended up placing back the repeated output, but shortened it to the last 500 characters. If you have another wish please do tell me :) and happy new year 😅 |
|
Hey @joshdholtz, fyi I'm still waiting for an approval here. And the fastlane bot keeps trying to close the issue related to this change request ;) |
|
Any chance we can get this approved? |
iBotPeaches
left a comment
There was a problem hiding this comment.
This bugs me to no end. You get a single failure on a RN build and it spews out another 30-50k lines and it takes forever to find the error among the mess.
I don't know if this is the right fix, but I'm trying it out and will iterate. I'm set on changing this before next release since I have a strong opinion as it exists now is extremely annoying.
There was a problem hiding this comment.
Pull request overview
This pull request aims to reduce log spam when Fastlane::Actions.sh fails by avoiding re-printing large command output in the error path (motivated by output-heavy tools like Unity).
Changes:
- Truncates the command output appended to the failure message to the last 500 characters.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Hey @tutipeti 👋
Thank you for your contribution to fastlane and congrats on getting this pull request merged 🎉
The code change now lives in the master branch, however it wasn't released to RubyGems yet.
We usually ship about once a month, and your PR will be included in the next one.
Please let us know if this change requires an immediate release by adding a comment here 👍
We'll notify you once we shipped a new release with your changes 🚀"
There was a problem hiding this comment.
Congratulations! 🎉 This was released as part of fastlane 2.237.0 🚀
Checklist
bundle exec rspecfrom the root directory to see all new and existing tests passbundle exec rubocop -ato ensure the code style is validMotivation and Context
Resolves #19416
Resolves #11140
Description
I'm changing
shnot to repeat the command output again when an error happens.On output-heavy shell calls (in our case running Unity) this causes the entire output of Unity being repeated for absolutely no gain.
To make matters worse, without passing an
error_callbackthere's even an exception raised thatbundlerpicks up then and decides to repeat the output yet again. Yikes. :)I've tested my changes both by running the rspec tests (which is also the reason why I had to change the tests) and by calling a script that fails through
shfrom my own project.Testing Steps
Simply call any script that should fail and observe the output only appearing once.