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

postinstall script fails #889

Closed
rborn opened this issue Aug 15, 2018 · 28 comments
Closed

postinstall script fails #889

rborn opened this issue Aug 15, 2018 · 28 comments

Comments

@rborn
Copy link

rborn commented Aug 15, 2018

Description

Trying to run npm install detox --save-dev will fail with the following error in the detox_ios.log

CodeSign build/Build/Products/Release-iphonesimulator/Detox.framework
    /usr/bin/codesign --force --sign - --timestamp=none /_PROJECT_PATH_/node_modules/detox/ios_src/build/Build/Products/Release-iphonesimulator/Detox.framework
cp: /Users/Dan/Library/Detox/ios/d179a1f7560289c939ae80cc7ba3d338d9fc4b5c/DetoxBuild/Build/Products/Release-iphoneos/Detox.framework: No such file or directory

yarn add [email protected] finishes the detox install without any issue

Steps to Reproduce

Install in a brand new RN project

Detox, Node, Device, Xcode and macOS Versions

  • Detox: latest( 8.1.6)
  • React Native: 0.56.0
  • Node: 10.4.0
  • Device: (didn't get to start the project)
  • Xcode: 9.4.1
  • macOS: 10.13.6

Device and verbose Detox logs

Provided in description

Thank you 🤗

@noomorph
Copy link
Collaborator

I didn't understand from the description, do you mix using yarn and npm in the same project?

@rborn
Copy link
Author

rborn commented Aug 15, 2018

Sorry, using yarn OR npm gives the same result.

@noomorph
Copy link
Collaborator

Okay, so what does that mean?

yarn add [email protected] finishes the detox install without any issue

@noomorph
Copy link
Collaborator

Did you mean that 8.0.0 has no issue whilst 8.1.6 has?

@rborn
Copy link
Author

rborn commented Aug 15, 2018

  • yarn add [email protected] - installs ok, no error
  • yarn add detox - postinstall script fails

@noomorph
Copy link
Collaborator

@rborn , okay, I'll try to look into it tomorrow.

@LeoNatan
Copy link
Contributor

Can you please attach the full log?

@rborn
Copy link
Author

rborn commented Aug 16, 2018

@noomorph
Copy link
Collaborator

@rborn, I could not reproduce on:

  • macOS High Sierra (10.13.6)
  • React Native: 0.56.0
  • Node: 10.9.0
  • Xcode: 9.3.1

That leaves me with two possibilities:

  • if you are using nvm, could you for the sake of the experiment, install brew install node? I remember a weird bug about that and I don't remember whether it was resolved or not.
  • if that does not apply, could you try out the same with Xcode 9.3 and see if it helps?

We need to narrow down why it happens.

@rborn
Copy link
Author

rborn commented Aug 16, 2018

@noomorph I upgraded node to 10.9.0 ( I use n ) not nvm
Sadly I can't downgrade to Xcode 9.3.1 unless you know an non-dangerous way of doing it - I have a setup for another framework that's more fragile and I'm afraid I will break it :(

same result (fails)

@LeoNatan
Copy link
Contributor

@noomorph Check out https://github.com/wix/AppleSimulatorUtils/blob/master/buildForBrew.sh
Here I prepend the export CODE_SIGNING_REQUIRED=NO && env var to disable code-signing requirement. Maybe we can add that to the build script here in Detox too. Unfortunately, I am on Mojave and Xcode 10. Since you are on High Sierra, could you please side-by-side install Xcode 9.4 and try to reproduce? (If you have multiple Xcode versions, you can use sudo xcode-select -s <path_to_xcode> to switch the command-line tools (which Detox uses).

@noomorph
Copy link
Collaborator

@LeoNatan , sure.

@rborn
Copy link
Author

rborn commented Aug 16, 2018

tried this export CODE_SIGNING_REQUIRED=NO && yarn add detox and it still fails, however not sure if it needs to be done in the script itself

@noomorph
Copy link
Collaborator

I was not able to reproduce this, sorry. Maybe I need to install n instead of nvm... dunno.

I upgraded to Xcode 9.4 and uninstalled node from brew, leaving my environment only with nvm node. Of course, I did detox clean-framework-cache before nom install. No luck :/

@LeoNatan
Copy link
Contributor

Node wouldn't have anything to do with a build failing. It is squarely somewhere in the Xcode build process.

@rborn
Copy link
Author

rborn commented Aug 16, 2018

The change happened between version 8.0.0 and 8.1.0 because 8.0.0 is the last one that works.

@LeoNatan
Copy link
Contributor

The build script changed but I'm not sure why the change should introduce such an issue, especially since we cannot reproduce locally.

@dodgecm
Copy link

dodgecm commented Aug 16, 2018

for what it's worth, this is happening on my machine as well

@rborn
Copy link
Author

rborn commented Aug 16, 2018

@dodgecm could you please post the log file? Maybe has more info than mine?

@dodgecm
Copy link

dodgecm commented Aug 16, 2018

NVM, with Node 8.9.0.
Xcode 9.4.1
Build version 9F2000
Project: Detox example project
I see the exact same behavior as OP where v8.0.0 works, but starting with v8.1.0 it breaks.

I've attached my command line output, but it doesn't seem to be very useful. how are you generating the detox_ios.log file?

node node_modules/detox/scripts/postinstall.js
+++ dirname /Users/cdodge/Documents/js/detox-master/detox/test/node_modules/detox/scripts/build_framework.ios.sh
++ dirname /Users/cdodge/Documents/js/detox-master/detox/test/node_modules/detox/scripts
+ detoxRootPath=/Users/cdodge/Documents/js/detox-master/detox/test/node_modules/detox
++ node -p 'require('\''/Users/cdodge/Documents/js/detox-master/detox/test/node_modules/detox/package.json'\'').version'
+ detoxVersion=8.1.6
++ echo 8.1.6
++ xcodebuild -version
++ shasum
++ awk '{print $1}'
+ sha1=d179a1f7560289c939ae80cc7ba3d338d9fc4b5c
+ detoxFrameworkDirPath=/Users/cdodge/Library/Detox/ios/d179a1f7560289c939ae80cc7ba3d338d9fc4b5c
+ detoxFrameworkPath=/Users/cdodge/Library/Detox/ios/d179a1f7560289c939ae80cc7ba3d338d9fc4b5c/Detox.framework
+ main
+ '[' -d /Users/cdodge/Library/Detox/ios/d179a1f7560289c939ae80cc7ba3d338d9fc4b5c ']'
+ '[' '!' -d /Users/cdodge/Library/Detox/ios/d179a1f7560289c939ae80cc7ba3d338d9fc4b5c/Detox.framework ']'
+ echo '/Users/cdodge/Library/Detox/ios/d179a1f7560289c939ae80cc7ba3d338d9fc4b5c was found, but could not find Detox.framework inside it. This means that the Detox framework build process was interrupted.
         deleting /Users/cdodge/Library/Detox/ios/d179a1f7560289c939ae80cc7ba3d338d9fc4b5c and trying to rebuild.'
/Users/cdodge/Library/Detox/ios/d179a1f7560289c939ae80cc7ba3d338d9fc4b5c was found, but could not find Detox.framework inside it. This means that the Detox framework build process was interrupted.
         deleting /Users/cdodge/Library/Detox/ios/d179a1f7560289c939ae80cc7ba3d338d9fc4b5c and trying to rebuild.
+ rm -rf /Users/cdodge/Library/Detox/ios/d179a1f7560289c939ae80cc7ba3d338d9fc4b5c
+ prepareAndBuildFramework
+ '[' -d /Users/cdodge/Documents/js/detox-master/detox/test/node_modules/detox/ios ']'
+ detoxSourcePath=/Users/cdodge/Documents/js/detox-master/detox/test/node_modules/detox/ios_src
+ extractSources /Users/cdodge/Documents/js/detox-master/detox/test/node_modules/detox/ios_src
+ detoxSourcePath=/Users/cdodge/Documents/js/detox-master/detox/test/node_modules/detox/ios_src
+ echo 'Extracting Detox sources...'
Extracting Detox sources...
+ mkdir -p /Users/cdodge/Documents/js/detox-master/detox/test/node_modules/detox/ios_src
+ tar -xjf /Users/cdodge/Documents/js/detox-master/detox/test/node_modules/detox/Detox-ios-src.tbz -C /Users/cdodge/Documents/js/detox-master/detox/test/node_modules/detox/ios_src
+ buildFramework /Users/cdodge/Documents/js/detox-master/detox/test/node_modules/detox/ios_src
+ detoxSourcePath=/Users/cdodge/Documents/js/detox-master/detox/test/node_modules/detox/ios_src
+ echo 'Building Detox.framework from /Users/cdodge/Documents/js/detox-master/detox/test/node_modules/detox/ios_src...'
Building Detox.framework from /Users/cdodge/Documents/js/detox-master/detox/test/node_modules/detox/ios_src...
+ mkdir -p /Users/cdodge/Library/Detox/ios/d179a1f7560289c939ae80cc7ba3d338d9fc4b5c
+ /Users/cdodge/Documents/js/detox-master/detox/test/node_modules/detox/scripts/build_universal_framework.sh /Users/cdodge/Documents/js/detox-master/detox/test/node_modules/detox/ios_src/Detox.xcodeproj /Users/cdodge/Library/Detox/ios/d179a1f7560289c939ae80cc7ba3d338d9fc4b5c/DetoxBuild
child_process.js:624
    throw err;
    ^

Error: Command failed: /Users/cdodge/Documents/js/detox-master/detox/test/node_modules/detox/scripts/build_framework.ios.sh
    at checkExecSyncError (child_process.js:601:13)
    at Object.execFileSync (child_process.js:621:13)
    at Object.<anonymous> (/Users/cdodge/Documents/js/detox-master/detox/test/node_modules/detox/scripts/postinstall.js:2:27)
    at Module._compile (module.js:635:30)
    at Object.Module._extensions..js (module.js:646:10)
    at Module.load (module.js:554:32)
    at tryModuleLoad (module.js:497:12)
    at Function.Module._load (module.js:489:3)
    at Function.Module.runMain (module.js:676:10)
    at startup (bootstrap_node.js:187:16)

@dodgecm
Copy link

dodgecm commented Aug 16, 2018

Never mind, figured it out. Looks like the same issue as you.

Signing Identity:     "-"

    /usr/bin/codesign --force --sign - --timestamp=none /Users/cdodge/Documents/js/detox-master/detox/test/node_modules/detox/ios_src/Build/Products/Release-iphonesimulator/Detox.framework

** BUILD SUCCEEDED **

cp: /Users/cdodge/Library/Detox/ios/d179a1f7560289c939ae80cc7ba3d338d9fc4b5c/DetoxBuild/Build/Products/Release-iphoneos/Detox.framework: No such file or directory

I followed the paths inside the build directory, and it looks like there was a Products/Release-universal folder made, which is empty. Perhaps the new version of xcode changed the folder name for simulator outputs? Based on the path of the Detox.framework that got exported, maybe it's not respecting the Derived data path?

@dodgecm
Copy link

dodgecm commented Aug 16, 2018

I think I found the issue. Inside my Xcode workspace settings, I had my build location set to "Custom", which was putting the build artifacts inside the project folder's Build directory. When I changed it back to the default setting, npm install ran smoothly again. I'm not sure what change should be made to fix this inside detox, but hopefully this should allow you guys to reproduce this easily.

In order to reproduce it, delete your DerivedData folder (Library/Detox/ios/*) and change your Xcode workspace settings to the values in the second image.

Default setting:
screen shot 2018-08-16 at 5 18 20 pm

Broken setting:
screen shot 2018-08-16 at 5 20 10 pm

@LeoNatan
Copy link
Contributor

Great, thanks! Will look into that next week.

@LeoNatan
Copy link
Contributor

Hopefully, my fix will solve this issue. If this issue gets locked before a new version is out, just open a new issue.

@rborn
Copy link
Author

rborn commented Aug 20, 2018

@LeoNatan Trying to test this by installing from git master but npm complains of Can't add "detox": invalid package version undefined. any idea? ☺️

@noomorph
Copy link
Collaborator

noomorph commented Aug 20, 2018

@rborn , try out https://github.com/wix/detox/blob/master/docs/Guide.Contributing.md
Do install via lerna, then a) npm link or b) as a hack, insert your project inside detox/ folder and add it to lerna.json and do learn bootstrap. Anyway, follow the manual.

@rborn
Copy link
Author

rborn commented Aug 20, 2018

@noomorph I'll give it a shot, thnx

@LeoNatan
Copy link
Contributor

I just pushed a further commit.
I think I know now what the original issue was. It was not what I assumed. It seems under certain conditions, doing a xcodebuild clean build removes all products, including from different SDKs. So iphoneos is built first, but then the clean for iphonesimulator causes the deletion of the product of iphoneos 🤦‍♂️ Apple and their shit

@lock lock bot locked as resolved and limited conversation to collaborators Aug 23, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants