-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Postinstall script fails when just command line tools are installed #897
Comments
Xcode is required. Detox is built on the client machine, and the iOS SDK must be present on the machine (it comes with Xcode). Indeed, it should fail postinstall as Xcode is a hard requirement. |
Prerequisites in the getting started documentation clearly states that Xcode is required. I’m not sure what the problem is here. |
I understand that, but my implied point was that I'd rather not have to mark The postinstall script exits with code 1, indicating an internal error with the postinstall script, not something missing on the platform. The question in my mind is not whether Xcode should be required, (because it should be, and I'm fine with not having functionality if I don't have it) but rather whether the postinstall script should be a noop if XCode is not installed. I would argue that the postinstall script should always exit with status code 0 unless something actually went wrong. |
We’ll discuss internally. What would the expected behavior be if a user attempts to test an iOS configuration? |
Sounds good—thanks for the reconsideration. I'd say either doing nothing, or printing an error message and doing nothing, would be behaviors I'd expect in this case. Like I say, I wouldn't expect anything to work without XCode installed. |
@rye What does the |
Fixed. |
@LeoNatan thanks for the fix! I realize it's a bit strange for someone who does RN work to not want to install Xcode but still. For reference, $ xcode-select --print-path
/Library/Developer/CommandLineTools Note that [snip]
> detox@8.2.1 postinstall /usr/local/lib/node_modules/detox
> node scripts/postinstall.js
+ xcodebuild -version
+ echo 'WARNING: Xcode is not installed on this machine. Skipping iOS framework build phase'
WARNING: Xcode is not installed on this machine. Skipping iOS framework build phase
+ return 0
/usr/local/lib/node_modules/detox/scripts/build_framework.ios.sh: line 4: return: can only `return' from a function or sourced script
child_process.js:621
throw err;
^
Error: Command failed: /usr/local/lib/node_modules/detox/scripts/build_framework.ios.sh
at checkExecSyncError (child_process.js:600:11)
at Object.execFileSync (child_process.js:618:13)
at Object.<anonymous> (/usr/local/lib/node_modules/detox/scripts/postinstall.js:2:27)
at Module._compile (internal/modules/cjs/loader.js:689:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
at startup (internal/bootstrap/node.js:266:19)
[snip] |
🤦♂️ |
Description
When I install
detox
on macOS with just the XCode command line tools installed,detox
's postinstall script fails with the following output:The behavior I would expect here is an error message to indicate to me that Detox will be practically useless in my environment, not a failed postinstall. I believe that this error message is just because this condition is not checked for. Because the subprocess (
xcodebuild -version
) exits with status 1, this unhandled exception propagates out and results in a postinstall script failure.Note that Line 6 of
detox/scripts/build_framework.ios.sh
, https://github.com/wix/detox/blob/234d611d565e4d9a75027fb57835727435f4c4e4/detox/scripts/build_framework.ios.sh#L6 does not capture the output ofxcodebuild -version
or handle this case; instead, it SHAsums partial output from a process which exited with code 1. In this case,xcodebuild -version
outputs its error message tostderr
, which is not caught by this pipe. (I would recommend using2>&1
before the pipe to accomplish this, if that is desired.)My idea for a "fix" for this behavior would be to check and see if
xcodebuild
exited with code 1, or also to redirect stderr to stdout for the purposes of guaranteeing that it makes it to the pipe which then gets sent toshasum
.Steps to Reproduce
xcodebuild -version
produces an error message that XCode is not installed, and exits with code 1.node
via Homebrew.detox
vianpm i -g detox
and observe the ELIFECYCLE fromnpm
.Detox, Node, Device, Xcode and macOS Versions
Device and verbose Detox logs
Not applicable.
See also StoDevX/AAO-React-Native#2842, which is my downstream tracking issue for this one.
The text was updated successfully, but these errors were encountered: