Undefined Method error has a single backtick, producing failed output when used in string interpolation
gregorskii opened this issue · comments
New Issue Checklist
- Updated fastlane to the latest version
- I read the Contribution Guidelines
- I read docs.fastlane.tools
- I searched for existing GitHub issues
Issue Description
Using a rescue on a step to save the ruby exception message as a string exported to a text file fails due to inconsistent use of backticks and quotes. See example code:
begin
produce(...)
rescue => ex
UI.important("BEGIN RESCUE")
UI.error(ex.message)
sh "$(echo \"#{ex.message}\" > ../build_logs/fastlane.error)"
spaceship_logs(
copy_to_path: "./build_logs/spaceship.logs"
)
raise ex
end
Produces this error in bash:
[14:52:26]: Exit status of command '$(echo "undefined method `sort_by' for nil:NilClass" > ../build_logs/fastlane.error)' was 2 instead of 0.
sh: -c: line 0: unexpected EOF while looking for matching ``'
sh: -c: line 1: syntax error: unexpected end of file
As the message includes "undefined method `sort_by' for nil:NilClass" the errant backtick.
See source code:
fastlane/spaceship/lib/spaceship/base.rb
Line 183 in ec629c1
Command executed
produce, ruby rescue
Complete output when running Fastlane, including the stack trace and command used
fastlane run (fastfile)
Environment
<details><summary>✅ fastlane environment ✅</summary>
### Stack
| Key | Value |
| --------------------------- | -------------------------------------------------------------- |
| OS | 12.3.1 |
| Ruby | 2.6.8 |
| Bundler? | false |
| Git | git version 2.32.0 (Apple Git-132) |
| Installation Source | /usr/local/bin/fastlane |
| Host | macOS 12.3.1 (21E258) |
| Ruby Lib Dir | /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib |
| OpenSSL Version | LibreSSL 2.8.3 |
| Is contained | false |
| Is homebrew | false |
| Is installed via Fabric.app | false |
| Xcode Path | /Applications/Xcode.app/Contents/Developer/ |
| Xcode Version | 13.3 |
| Swift Version | 5.6 |
### System Locale
| Variable | Value | |
| -------- | ----------- | - |
| LANG | en_US.UTF-8 | ✅ |
| LC_ALL | en_US.UTF-8 | ✅ |
| LANGUAGE | | |
### fastlane files:
**No Fastfile found**
**No Appfile found**
### fastlane gems
| Gem | Version | Update-Status |
| -------- | ------- | ------------- |
| fastlane | 2.206.2 | ✅ Up-To-Date |
### Loaded fastlane plugins:
**No plugins Loaded**
<details><summary><b>Loaded gems</b></summary>
| Gem | Version |
| ------------------------------- | ------------ |
| atomos | 0.1.3 |
| CFPropertyList | 2.3.6 |
| claide | 1.1.0 |
| colored2 | 3.1.2 |
| nanaimo | 0.3.0 |
| rexml | 3.2.5 |
| xcodeproj | 1.21.0 |
| rouge | 2.0.7 |
| xcpretty | 0.3.0 |
| terminal-notifier | 2.0.0 |
| unicode-display_width | 1.8.0 |
| terminal-table | 1.8.0 |
| plist | 3.6.0 |
| public_suffix | 4.0.7 |
| addressable | 2.8.0 |
| multipart-post | 2.0.0 |
| word_wrap | 1.0.0 |
| optparse | 0.1.1 |
| tty-screen | 0.8.1 |
| tty-cursor | 0.7.1 |
| tty-spinner | 0.9.3 |
| artifactory | 3.0.15 |
| babosa | 1.0.4 |
| colored | 1.2 |
| highline | 2.0.3 |
| commander | 4.6.0 |
| excon | 0.92.3 |
| faraday-em_http | 1.0.0 |
| faraday-em_synchrony | 1.0.0 |
| faraday-excon | 1.1.0 |
| faraday-httpclient | 1.0.1 |
| faraday-multipart | 1.0.3 |
| faraday-net_http | 1.0.1 |
| faraday-net_http_persistent | 1.2.0 |
| faraday-patron | 1.0.0 |
| faraday-rack | 1.0.0 |
| faraday-retry | 1.0.3 |
| ruby2_keywords | 0.0.5 |
| faraday | 1.10.0 |
| unf_ext | 0.0.8.2 |
| unf | 0.1.4 |
| domain_name | 0.5.20190701 |
| http-cookie | 1.0.5 |
| faraday-cookie_jar | 0.0.7 |
| faraday_middleware | 1.2.0 |
| fastimage | 2.2.6 |
| gh_inspector | 1.1.3 |
| json | 2.6.2 |
| mini_magick | 4.11.0 |
| naturally | 2.2.1 |
| rubyzip | 2.3.2 |
| security | 0.1.3 |
| xcpretty-travis-formatter | 1.0.1 |
| dotenv | 2.7.6 |
| bundler | 2.3.14 |
| simctl | 1.6.8 |
| jwt | 2.3.0 |
| uber | 0.1.0 |
| declarative | 0.0.20 |
| trailblazer-option | 0.1.2 |
| representable | 3.2.0 |
| retriable | 3.1.2 |
| mini_mime | 1.1.2 |
| memoist | 0.16.2 |
| multi_json | 1.15.0 |
| os | 1.1.4 |
| signet | 0.16.1 |
| googleauth | 1.1.3 |
| httpclient | 2.8.3 |
| webrick | 1.7.0 |
| google-apis-core | 0.5.0 |
| google-apis-playcustomapp_v1 | 0.7.0 |
| google-apis-androidpublisher_v3 | 0.21.0 |
| google-cloud-env | 1.6.0 |
| google-cloud-errors | 1.2.0 |
| google-cloud-core | 1.6.0 |
| google-apis-iamcredentials_v1 | 0.10.0 |
| google-apis-storage_v1 | 0.14.0 |
| rake | 13.0.6 |
| digest-crc | 0.6.4 |
| google-cloud-storage | 1.36.2 |
| emoji_regex | 3.2.3 |
| jmespath | 1.6.1 |
| aws-partitions | 1.593.0 |
| aws-eventstream | 1.2.0 |
| aws-sigv4 | 1.5.0 |
| aws-sdk-core | 3.131.1 |
| aws-sdk-kms | 1.57.0 |
| aws-sdk-s3 | 1.114.0 |
| libxml-ruby | 3.2.1 |
</details>
*generated on:* **2022-06-07**
</details>
It seems like you have not included the output of fastlane env
To make it easier for us help you resolve this issue, please update the issue to include the output of fastlane env
Ruby is not my first language, but it seems this could be mitigated with:
${Shellwords.escape()}
But curious about the single tick, if it matters or should be fixed.
I'm seeing a potentially similar error message
[!] undefined method `sort_by' for nil:NilClass
This is the stack trace I seemingly randomly get:
/Library/Ruby/Gems/2.6.0/gems/fastlane-2.206.2/spaceship/lib/spaceship/client.rb:73:in `teams': [!] undefined method `sort_by' for nil:NilClass (NoMethodError)
from /Library/Ruby/Gems/2.6.0/gems/fastlane-2.206.2/spaceship/lib/spaceship/tunes/tunes_client.rb:73:in `select_team'
from /Library/Ruby/Gems/2.6.0/gems/fastlane-2.206.2/spaceship/lib/spaceship/tunes/spaceship.rb:35:in `select_team'
from Fastfile_helpers.rb:271:in `has_app_store_program_license_message_that_are_blocking_new_release'
from Fastfile_helpers.rb:133:in `deploy'
from Fastfile:613:in `block in parsing_binding'
from /Library/Ruby/Gems/2.6.0/gems/fastlane-2.206.2/fastlane/lib/fastlane/lane.rb:33:in `call'
from /Library/Ruby/Gems/2.6.0/gems/fastlane-2.206.2/fastlane/lib/fastlane/runner.rb:204:in `try_switch_to_lane'
from /Library/Ruby/Gems/2.6.0/gems/fastlane-2.206.2/fastlane/lib/fastlane/runner.rb:146:in `trigger_action_by_name'
from /Library/Ruby/Gems/2.6.0/gems/fastlane-2.206.2/fastlane/lib/fastlane/fast_file.rb:159:in `method_missing'
from Fastfile:109:in `block in parsing_binding'
from /Library/Ruby/Gems/2.6.0/gems/fastlane-2.206.2/fastlane/lib/fastlane/lane.rb:33:in `call'
from /Library/Ruby/Gems/2.6.0/gems/fastlane-2.206.2/fastlane/lib/fastlane/runner.rb:49:in `block in execute'
from /Library/Ruby/Gems/2.6.0/gems/fastlane-2.206.2/fastlane/lib/fastlane/runner.rb:45:in `chdir'
from /Library/Ruby/Gems/2.6.0/gems/fastlane-2.206.2/fastlane/lib/fastlane/runner.rb:45:in `execute'
from /Library/Ruby/Gems/2.6.0/gems/fastlane-2.206.2/fastlane/lib/fastlane/lane_manager.rb:47:in `cruise_lane'
from /Library/Ruby/Gems/2.6.0/gems/fastlane-2.206.2/fastlane/lib/fastlane/command_line_handler.rb:36:in `handle'
from /Library/Ruby/Gems/2.6.0/gems/fastlane-2.206.2/fastlane/lib/fastlane/commands_generator.rb:110:in `block (2 levels) in run'
from /Library/Ruby/Gems/2.6.0/gems/commander-4.6.0/lib/commander/command.rb:187:in `call'
from /Library/Ruby/Gems/2.6.0/gems/commander-4.6.0/lib/commander/command.rb:157:in `run'
from /Library/Ruby/Gems/2.6.0/gems/commander-4.6.0/lib/commander/runner.rb:444:in `run_active_command'
from /Library/Ruby/Gems/2.6.0/gems/fastlane-2.206.2/fastlane_core/lib/fastlane_core/ui/fastlane_runner.rb:124:in `run!'
from /Library/Ruby/Gems/2.6.0/gems/commander-4.6.0/lib/commander/delegates.rb:18:in `run!'
from /Library/Ruby/Gems/2.6.0/gems/fastlane-2.206.2/fastlane/lib/fastlane/commands_generator.rb:354:in `run'
from /Library/Ruby/Gems/2.6.0/gems/fastlane-2.206.2/fastlane/lib/fastlane/commands_generator.rb:43:in `start'
from /Library/Ruby/Gems/2.6.0/gems/fastlane-2.206.2/fastlane/lib/fastlane/cli_tools_distributor.rb:123:in `take_off'
from /Library/Ruby/Gems/2.6.0/gems/fastlane-2.206.2/bin/fastlane:23:in `<top (required)>'
from /usr/local/bin/fastlane:23:in `load'
from /usr/local/bin/fastlane:23:in `<main>'
I am now seeing a similar issue:
"$(echo “(<unknown>):"
"(<unknown>): could not find expected ':' while scanning a simple key at line 39 column 1"