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

screengrab exiting with status 127 (FastlaneCore::Interface::FastlaneShellError) #15981

Closed
4 tasks done
Jeehut opened this issue Feb 6, 2020 · 2 comments · Fixed by #15986
Closed
4 tasks done

screengrab exiting with status 127 (FastlaneCore::Interface::FastlaneShellError) #15981

Jeehut opened this issue Feb 6, 2020 · 2 comments · Fixed by #15986

Comments

@Jeehut
Copy link
Contributor

Jeehut commented Feb 6, 2020

New Issue Checklist

Issue Description

When I run fastlane screengrab in my Android project directory, I get an error stating FastlaneCore::Interface::FastlaneShellError with exit status 127. While I will post my complete env and output below, please note that I also downloaded the latest master of this repository as a ZIP file and have the same issue when I run fastlane screengrab in the example directory.

I also followed all the other steps to configure fastlane in my project according to the docs. Should be correct as it's also failing in the example project.

Here's my fastlane/Screengrabfile contents:

locales(['en-US', 'de-DE'])
clear_previous_screenshots(true)
tests_apk_path 'app/build/outputs/apk/androidTest/debug/app-debug-androidTest.apk'
app_apk_path 'app/build/outputs/apk/debug/app-debug.apk'
Command executed

fastlane screengrab (before, I had successfully run ./gradlew assembleDebug assembleAndroidTest and/or fastlane build_for_screengrab)

Complete output when running fastlane, including the stack trace and command used
 DscheeBook-Pro:FitnessTracker-Android cihat$ fastlane screengrab
[✔] 🚀
[11:52:22]: Get started using a Gemfile for fastlane https://docs.fastlane.tools/getting-started/ios/setup/#use-a-gemfile
[11:52:22]: Successfully loaded '/Users/Cihat/Code/FitnessTracker-Android/fastlane/Screengrabfile' 📄

+----------------------------+-----------------------------------------------------------------+
| Detected Values from './fastlane/Screengrabfile' |
+----------------------------+-----------------------------------------------------------------+
| locales | ["en-US", "de-DE"] |
| clear_previous_screenshots | true |
| tests_apk_path | app/build/outputs/apk/androidTest/debug/app-debug-androidTest. |
| | apk |
| app_apk_path | app/build/outputs/apk/debug/app-debug.apk |
+----------------------------+-----------------------------------------------------------------+

[11:52:22]: Using adb found at /Users/Cihat/Library/Android/sdk/platform-tools/adb which is not within the specified ANDROID_HOME at ~/Library/Android/sdk/
[11:52:22]: The aapt command could not be found relative to your provided ANDROID_HOME at ~/Library/Android/sdk/
[11:52:22]: Please ensure that the Android SDK is installed and you have the build tools downloaded

+-----------------------------+-----------------------------------------------------------------+
| Summary for screengrab 2.141.0 |
+-----------------------------+-----------------------------------------------------------------+
| tests_package_name | com.flinesoft.fitnesstracker.test |
| android_home | ~/Library/Android/sdk/ |
| locales | ["en-US", "de-DE"] |
| clear_previous_screenshots | true |
| output_directory | fastlane/metadata/android |
| skip_open_summary | false |
| app_package_name | com.flinesoft.fitnesstracker |
| test_instrumentation_runner | androidx.test.runner.AndroidJUnitRunner |
| ending_locale | en-US |
| use_adb_root | false |
| app_apk_path | app/build/outputs/apk/debug/app-debug.apk |
| tests_apk_path | app/build/outputs/apk/androidTest/debug/app-debug-androidTest. |
| | apk |
| device_type | phone |
| exit_on_test_failure | true |
| reinstall_app | false |
| use_timestamp_suffix | true |
+-----------------------------+-----------------------------------------------------------------+

[11:52:22]: Limiting the test classes run by screengrab to just those that generate screenshots can make runs faster.
[11:52:22]: Consider using the :use_tests_in_classes or :use_tests_in_packages option, and organize your tests accordingly.
[11:52:22]: Clearing phoneScreenshots within fastlane/metadata/android

Looking for related GitHub issues on fastlane/fastlane...

➡️ Increment build number
#127 [closed] 2 💬
04 Feb 2017

➡️ Instead of FASTLANE_APPLE_APPLICATION_SPECIFIC_PASSWORD, fastlane asks for FASTLANE_PASSWORD
#15038 [closed] 2 💬
21 Sep 2019

➡️ Can't upload Android app to Crashlytics Beta
#9389 [closed] 25 💬
23 Jul 2018

and 7 more at: https://github.com/fastlane/fastlane/search?q=Shell%20command%20exited%20with%20exit%20status%20127%20instead%20of%200.&type=Issues&utf8=✓

🔗 You can ⌘ + double-click on links to open them directly in your browser.
Traceback (most recent call last):
18: from /Users/Cihat/.rvm/gems/ruby-2.6.3/bin/fastlane:23:in <main>' 17: from /Users/Cihat/.rvm/gems/ruby-2.6.3/bin/fastlane:23:in load'
16: from /Users/Cihat/.rvm/gems/ruby-2.6.3/gems/fastlane-2.141.0/bin/fastlane:23:in <top (required)>' 15: from /Users/Cihat/.rvm/gems/ruby-2.6.3/gems/fastlane-2.141.0/fastlane/lib/fastlane/cli_tools_distributor.rb:111:in take_off'
14: from /Users/Cihat/.rvm/gems/ruby-2.6.3/gems/fastlane-2.141.0/screengrab/lib/screengrab/commands_generator.rb:19:in start' 13: from /Users/Cihat/.rvm/gems/ruby-2.6.3/gems/fastlane-2.141.0/screengrab/lib/screengrab/commands_generator.rb:67:in run'
12: from /Users/Cihat/.rvm/gems/ruby-2.6.3/gems/commander-fastlane-4.4.6/lib/commander/delegates.rb:15:in run!' 11: from /Users/Cihat/.rvm/gems/ruby-2.6.3/gems/fastlane-2.141.0/fastlane_core/lib/fastlane_core/ui/fastlane_runner.rb:76:in run!'
10: from /Users/Cihat/.rvm/gems/ruby-2.6.3/gems/commander-fastlane-4.4.6/lib/commander/runner.rb:476:in run_active_command' 9: from /Users/Cihat/.rvm/gems/ruby-2.6.3/gems/commander-fastlane-4.4.6/lib/commander/command.rb:153:in run'
8: from /Users/Cihat/.rvm/gems/ruby-2.6.3/gems/commander-fastlane-4.4.6/lib/commander/command.rb:178:in call' 7: from /Users/Cihat/.rvm/gems/ruby-2.6.3/gems/fastlane-2.141.0/screengrab/lib/screengrab/commands_generator.rb:49:in block (2 levels) in run'
6: from /Users/Cihat/.rvm/gems/ruby-2.6.3/gems/fastlane-2.141.0/screengrab/lib/screengrab/runner.rb:57:in run' 5: from /Users/Cihat/.rvm/gems/ruby-2.6.3/gems/fastlane-2.141.0/screengrab/lib/screengrab/runner.rb:89:in select_device'
4: from /Users/Cihat/.rvm/gems/ruby-2.6.3/gems/fastlane-2.141.0/fastlane/lib/fastlane/helper/adb_helper.rb:56:in load_all_devices' 3: from /Users/Cihat/.rvm/gems/ruby-2.6.3/gems/fastlane-2.141.0/fastlane/lib/fastlane/helper/sh_helper.rb:12:in sh'
2: from /Users/Cihat/.rvm/gems/ruby-2.6.3/gems/fastlane-2.141.0/fastlane/lib/fastlane/helper/sh_helper.rb:80:in sh_control_output' 1: from /Users/Cihat/.rvm/gems/ruby-2.6.3/gems/fastlane-2.141.0/fastlane_core/lib/fastlane_core/ui/ui.rb:17:in method_missing'
/Users/Cihat/.rvm/gems/ruby-2.6.3/gems/fastlane-2.141.0/fastlane_core/lib/fastlane_core/ui/interface.rb:153:in shell_error!': Shell command exited with exit status 127 instead of 0. (FastlaneCore::Interface::FastlaneShellError) 18: from /Users/Cihat/.rvm/gems/ruby-2.6.3/bin/fastlane:23:in

'
17: from /Users/Cihat/.rvm/gems/ruby-2.6.3/bin/fastlane:23:in load' 16: from /Users/Cihat/.rvm/gems/ruby-2.6.3/gems/fastlane-2.141.0/bin/fastlane:23:in <top (required)>'
15: from /Users/Cihat/.rvm/gems/ruby-2.6.3/gems/fastlane-2.141.0/fastlane/lib/fastlane/cli_tools_distributor.rb:111:in take_off' 14: from /Users/Cihat/.rvm/gems/ruby-2.6.3/gems/fastlane-2.141.0/screengrab/lib/screengrab/commands_generator.rb:19:in start'
13: from /Users/Cihat/.rvm/gems/ruby-2.6.3/gems/fastlane-2.141.0/screengrab/lib/screengrab/commands_generator.rb:67:in run' 12: from /Users/Cihat/.rvm/gems/ruby-2.6.3/gems/commander-fastlane-4.4.6/lib/commander/delegates.rb:15:in run!'
11: from /Users/Cihat/.rvm/gems/ruby-2.6.3/gems/fastlane-2.141.0/fastlane_core/lib/fastlane_core/ui/fastlane_runner.rb:76:in run!' 10: from /Users/Cihat/.rvm/gems/ruby-2.6.3/gems/commander-fastlane-4.4.6/lib/commander/runner.rb:476:in run_active_command'
9: from /Users/Cihat/.rvm/gems/ruby-2.6.3/gems/commander-fastlane-4.4.6/lib/commander/command.rb:153:in run' 8: from /Users/Cihat/.rvm/gems/ruby-2.6.3/gems/commander-fastlane-4.4.6/lib/commander/command.rb:178:in call'
7: from /Users/Cihat/.rvm/gems/ruby-2.6.3/gems/fastlane-2.141.0/screengrab/lib/screengrab/commands_generator.rb:49:in block (2 levels) in run' 6: from /Users/Cihat/.rvm/gems/ruby-2.6.3/gems/fastlane-2.141.0/screengrab/lib/screengrab/runner.rb:57:in run'
5: from /Users/Cihat/.rvm/gems/ruby-2.6.3/gems/fastlane-2.141.0/screengrab/lib/screengrab/runner.rb:89:in select_device' 4: from /Users/Cihat/.rvm/gems/ruby-2.6.3/gems/fastlane-2.141.0/fastlane/lib/fastlane/helper/adb_helper.rb:56:in load_all_devices'
3: from /Users/Cihat/.rvm/gems/ruby-2.6.3/gems/fastlane-2.141.0/fastlane/lib/fastlane/helper/sh_helper.rb:12:in sh' 2: from /Users/Cihat/.rvm/gems/ruby-2.6.3/gems/fastlane-2.141.0/fastlane/lib/fastlane/helper/sh_helper.rb:80:in sh_control_output'
1: from /Users/Cihat/.rvm/gems/ruby-2.6.3/gems/fastlane-2.141.0/fastlane_core/lib/fastlane_core/ui/ui.rb:17:in method_missing' /Users/Cihat/.rvm/gems/ruby-2.6.3/gems/fastlane-2.141.0/fastlane_core/lib/fastlane_core/ui/interface.rb:153:in shell_error!': [!] Shell command exited with exit status 127 instead of 0. (FastlaneCore::Interface::FastlaneShellError)

Environment

 
✅ fastlane environment ✅

Stack

Key Value
OS 10.15.3
Ruby 2.6.3
Bundler? false
Git git version 2.21.0 (Apple Git-122.2)
Installation Source ~/.rvm/gems/ruby-2.6.3/bin/fastlane
Host Mac OS X 10.15.3 (19D76)
Ruby Lib Dir ~/.rvm/rubies/ruby-2.6.3/lib
OpenSSL Version OpenSSL 1.1.1c 28 May 2019
Is contained false
Is homebrew false
Is installed via Fabric.app false
Xcode Path /Applications/Xcode.app/Contents/Developer/
Xcode Version 11.2.1

System Locale

Variable Value
LANG de_DE.UTF-8
LC_ALL
LANGUAGE

fastlane files:

`./fastlane/Fastfile`
update_fastlane

default_platform(:android)

platform :android do
  desc "Build debug and test APK for screenshots"
  lane :build_for_screengrab do
    build_android_app(
      task: 'assemble',
      build_type: 'Debug'
    )
    build_android_app(
      task: 'assemble',
      build_type: 'AndroidTest'
    )
  end
end
`./fastlane/Appfile`
package_name("com.flinesoft.fitnesstracker")

fastlane gems

Gem Version Update-Status
fastlane 2.141.0 ✅ Up-To-Date

Loaded fastlane plugins:

No plugins Loaded

Loaded gems
Gem Version
did_you_mean 1.3.0
slack-notifier 2.3.2
rouge 2.0.7
xcpretty 0.3.0
terminal-notifier 2.0.0
terminal-table 1.8.0
plist 3.5.0
public_suffix 2.0.5
addressable 2.7.0
multipart-post 2.0.0
word_wrap 1.0.0
babosa 1.0.3
colored 1.2
highline 1.7.10
commander-fastlane 4.4.6
faraday 0.17.3
unf_ext 0.0.7.6
unf 0.1.4
domain_name 0.5.20190701
http-cookie 1.0.3
faraday-cookie_jar 0.0.6
faraday_middleware 0.13.1
fastimage 2.1.7
gh_inspector 1.1.3
mini_magick 4.10.1
multi_xml 0.6.0
rubyzip 1.3.0
security 0.1.3
xcpretty-travis-formatter 1.0.0
dotenv 2.7.5
bundler 1.17.3
naturally 2.2.0
simctl 1.6.7
jwt 2.1.0
uber 0.1.0
declarative 0.0.10
declarative-option 0.1.0
representable 3.0.4
retriable 3.1.2
mini_mime 1.0.2
multi_json 1.14.1
signet 0.12.0
memoist 0.16.2
os 1.0.1
googleauth 0.10.0
httpclient 2.8.3
google-api-client 0.36.4
google-cloud-env 1.3.0
google-cloud-errors 1.0.0
google-cloud-core 1.5.0
digest-crc 0.4.1
google-cloud-storage 1.25.1
emoji_regex 1.0.1
nanaimo 0.2.6
colored2 3.1.2
claide 1.0.3
CFPropertyList 3.0.2
atomos 0.1.3
xcodeproj 1.15.0
unicode-display_width 1.6.1
tty-screen 0.7.1
tty-cursor 0.7.1
tty-spinner 0.9.3
excon 0.72.0
json 2.3.0
forwardable 1.2.0
logger 1.3.0
stringio 0.0.2
ipaddr 1.2.2
openssl 2.1.2
ostruct 0.1.0
strscan 1.0.0
date 2.0.0
fileutils 1.1.0
etc 1.0.1
io-console 0.4.7
zlib 1.0.0
rexml 3.1.9
psych 3.1.0
mutex_m 0.1.0

generated on: 2020-02-06

@Jeehut
Copy link
Contributor Author

Jeehut commented Feb 7, 2020

I just debugged this and it appears the issue is a backslash added to the adb devices command in adp_helper.r:56 resulting in \~/Library/Android/sdk/platform-tools/adb devices -l (note the \ at the beginning which causes the issue).

I will further investigate how to fix it properly (probably in shellescape somewhere) and will post a PR with a fix once finished.

Update 1:
Okay, I found the issue, it's in Rubys Shellwords module, specifically:

Shellwords.escape('~/Library/Android/sdk/platform-tools/adb')
=> "\\~/Library/Android/sdk/platform-tools/adb"

Update 2:
Okay, after thinking about how to resolve this, I think the best approach is to not shellescape adb_path at all as it's not a collection of words, which Shellwords seems to be designed for, at least that's what all the examples and documentation pages are showing as well. No need for file paths AFAIK.

@janpio
Copy link
Member

janpio commented Feb 8, 2020

I think your problem could be caused by your ANDROID_HOME which seems to be set to ~/Library/Android/sdk/:

[11:52:22]: The aapt command could not be found relative to your provided ANDROID_HOME at ~/Library/Android/sdk/

Seems to me there is a bug when you use ~ in that env var:

[11:52:22]: Using adb found at /Users/Cihat/Library/Android/sdk/platform-tools/adb which is not within the specified ANDROID_HOME at ~/Library/Android/sdk/

Probably we should expand that path before using it or something... that would avoid having the problem you describe with ~ being escaped to \~.

Jeehut added a commit to Jeehut/fastlane that referenced this issue Feb 15, 2020
joshdholtz pushed a commit that referenced this issue Feb 17, 2020
* [screengrab] Fix escaping issue with `adb` path (#15981)

* Feedback addressed @janpio

* [screengrab] Fix an issue with tests after expanding adb_path

* Feedback addressed @janpio

* [screengrab] Update tests to use absolute path

* [screengrab] Fix issue with relativ paths in tests

* [screengrab] Also fix tests on Windows

* [screengrab] Fix wrong order of expanding path in tests
@fastlane fastlane locked and limited conversation to collaborators Apr 18, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants