realm / realm-js

Realm is a mobile database: an alternative to SQLite & key-value stores
https://realm.io
Apache License 2.0
5.8k stars 576 forks source link

Build Failed on iOS #1774

Closed krrevilla closed 6 years ago

krrevilla commented 6 years ago

Result

Resolved requirements: { SYNC_SERVER_FOLDER: 'sync', SYNC_ARCHIVE: 'realm-sync-cocoa-3.0.0.tar.gz', SYNC_ARCHIVE_ROOT: 'core' } No lockfile found at the target, proceeding. Download url: https://static.realm.io/downloads/sync/realm-sync-cocoa-3.0.0.tar.gz Extracting realm-sync-cocoa-3.0.0.tar.gz => /Users/pong/Projects/infopais-mobile/node_modules/realm/vendor/realm-ios { Error: unexpected end of file at Zlib._handle.onerror (zlib.js:371:17) errno: -5, code: 'Z_BUF_ERROR' } Command /bin/sh failed with exit code 1

Steps to Reproduce

react-native init Test yarn add realm react-native link realm react-native run-ios

Version of Realm and Tooling

Issue is same with #1647, but after removing and installing after many times. Still getting error

kneth commented 6 years ago

It looks like downloaded realm-sync-cocoa-3.0.0.tar.gz failed silently, and it is not possible to unpack it. I see it sometimes on our CI system, and typically I just retry. We are using Amazon S3 to host our files, and the service is apparently not 100 % reliable.

krrevilla commented 6 years ago

Okay got it @kneth will try and try for now. Thanks

rcalabro commented 6 years ago

I am getting the same error with realm-sync-cocoa-2.2.9.tar.gz I tried to clean caches and reinstall several times now Any idea how to solve this?

Moving realm-sync-cocoa-2.2.9.tar.gz to /node_modules/realm/vendor/realm-ios didn`t work either

kneth commented 6 years ago

@rcalabro Sync 2.2.9 is from December 2017, and it is probably not work with master of this repository. Realm JS depends heavily on Realm Sync and Realm Core so many changes to those two will be reflected in the code base. I suggest that you try to build directly from master with recent versions of sync and core.

ekeuus commented 6 years ago

Tried it multiple times with various versions as well, can't get it to work. Debugging shows me that in download-realm.js

const corePath = desired.CORE_ARCHIVE && path.resolve(os.tmpdir(), desired.CORE_ARCHIVE);

is undefined

rcalabro commented 6 years ago

Updating Xcode was the only "solution"

Get Outlook for Android

On Fri, May 18, 2018 at 6:31 PM -0300, "Ekke Tõiv Uustalu" notifications@github.com wrote:

Tried it multiple times with various versions as well, can't get it to work. Debugging shows me that

const corePath = desired.CORE_ARCHIVE && path.resolve(os.tmpdir(), desired.CORE_ARCHIVE);

is undefined

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

ekeuus commented 6 years ago

Lowering the version to 2.3.1 and clearing yarn caches worked for me.

kneth commented 6 years ago

@krrevilla Do you still experience it? Also after clearing your cache?

krrevilla commented 6 years ago

@kneth no, i don't experience it anymore. Somehow internet connection can also cause this issue.

kneth commented 6 years ago

@krrevilla Thanks. I close the issue. Never hesitate to ask another time.

dwilt commented 6 years ago

This happened to us. As @ekeuus suggested, downgrading to 2.3.1 solved it.

kneth commented 6 years ago

@dwilt Which version did you try before downgrading?

dwilt commented 6 years ago

image image @kneth It's happening to me with the latest version (2.12.0)

kneth commented 6 years ago

@dwilt I have tried to manually download the file, and it seems to be fine:

$ curl -O https://static.realm.io/downloads/sync/realm-sync-cocoa-3.7.0.tar.gz
$ tar tzf realm-sync-cocoa-3.7.0.tar.gz

Can you try the two command above to see if you get any error messages?

dwilt commented 6 years ago

@kneth Maybe we're onto something here. Just tried the curl:

image

To make sure it wasn't my internet:

image

Any ideas?

kneth commented 6 years ago
dwilt commented 6 years ago

@kneth I'm pretty sure I don't have a proxy server. I'd know that, right? You can't just have one of those without realizing it?

Both didn't work: image

kneth commented 6 years ago

Yes, you will know if you are behind a proxy as it will require some configuration.

This is a bit bizarre. I mean, it works perfectly for me - and I am in Europe and our download server is in USA.

dwilt commented 6 years ago

Is this what is happening during the build process? It's trying to redownload this tar file?

On Mon, Jul 9, 2018 at 1:59 PM Kenneth Geisshirt notifications@github.com wrote:

Yes, you will know if you are behind a proxy as it will require some configuration.

This is a bit bizarre. I mean, it works perfectly for me - and I am in Europe and our download server is in USA.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/realm/realm-js/issues/1774#issuecomment-403566970, or mute the thread https://github.com/notifications/unsubscribe-auth/ABBCQxC3EacjeeVEI9J0Vx0vsClMqptlks5uE5oFgaJpZM4Twhdq .

kneth commented 6 years ago

It will download the file the first time.

Btw, does wget https://static.realm.io/downloads/sync/realm-sync-cocoa-3.7.0.tar.gz work?

dwilt commented 6 years ago

@kneth Had to download wget via brew but it worked:

image image

kneth commented 6 years ago

I guess we can conclude that the problem is the download script (scripts/download-realm.js) and not our server. The script is using node-fetch, and curl has the same issue.

dwilt commented 6 years ago

What does that mean? Is there a way we can work around this in the mean time?

kneth commented 6 years ago

You can unpack the file in vendor/realm-mac-x64 and create an empty file download-realm.lock (touch vendor/realm-mac-x64/download-realm.lock).

kneth commented 6 years ago

And then I have to understand in which situations, node-fetch doesn't work 😄

dwilt commented 6 years ago

@kneth where is this vendor folder at?

dwilt commented 6 years ago

image

Are you talking about here: node_modules/realm/vendor?

kneth commented 6 years ago

Yes, the one in your screenshot

dwilt commented 6 years ago

@kneth I tried that and it still failed to build. Same exact error.

dwilt commented 6 years ago

@kneth tried downgrading Xcode, moving over to the same node version as another guy on my team, and still nothing. I even tried creating a brand new react native project and just installed realm - same build error.

kneth commented 6 years ago

Maybe https://realm.io/docs/javascript/latest/#cannot-download-realm-sync-cocoa can help you.

dwilt commented 6 years ago

@kneth those instructions aren't working for me either. I noticed that the latest package is 3.8.0 so I updated the script. I followed all of the steps to putt the files in the realm-ios folder but they just get wiped every time a build runs. Isn't the download-realm.lock file supposed to prevent it from trying to sync from the server? It says No lockfile found at the target, proceeding. I just put one there though?

image

What I find really interesting, is that if I'm offline, it still tries to sync and then overwrites my folder. Our project is completely blocked by this. Any help (happy to do a screenshare here) would be great appreciated.

dwilt commented 6 years ago

I created a video showing my steps. Let me know if something seems off here.

realm trouble

dwilt commented 6 years ago

Also, fwiw, I can curl now but the build still fails.

dwilt commented 6 years ago

Reformatted my Mac. All is working now.

joaom182 commented 6 years ago

@dwilt you reformatted your MAC? :O WTF!!

joaom182 commented 6 years ago

Not able to download

https://static.realm.io/downloads/sync/realm-sync-cocoa-3.8.0.tar.gz Failed network error

Anyone can post this file in another source to test?

joaom182 commented 6 years ago

My issue is related with Wifi on OSX High Sierra. Trying to download with Windows PC, it's fine.

joaom182 commented 6 years ago

Now throws an error on iOS build

** BUILD FAILED **

The following commands produced analyzer issues:

    Analyze Base/RCTModuleMethod.mm normal x86_64
(1 command with analyzer issues)

The following build commands failed:
    CompileC /Users/joaom182/Projects/eipets/app/ios/build/Build/Intermediates.noindex/RealmReact.build/Debug-iphonesimulator/RealmReact.build/Objects-normal/x86_64/RealmReact.o RealmReact/RealmReact.mm normal x86_64 objective-c++ com.apple.compilers.llvm.clang.1_0.compiler
(1 failure)
dwilt commented 6 years ago

@joaom182 haha yea, I tried everything else. Reformatting was the last option.

CyberNika commented 6 years ago

Oh my god! I have the same problem. I really can't imagine Reformatting is the only way!

joaom182 commented 6 years ago

@snokier I did not have to format, i have only to fix the issue with my Wi-fi on High Sierra.

kneth commented 6 years ago

I have been offline for a while (vacation), and it is interesting to read. MacOS has been having issues with WiFi but I thought it was over. @joaom182 Can you explain (I am just curious here) what your WiFi issue was?

@dwilt I admire that you go the extra mile (formatting your Mac) just to use Realm - thanks!

joaom182 commented 6 years ago

@kneth Instability, many packet loses, so the download never complete.

This resolved my issue: http://osxdaily.com/2016/09/22/fix-wi-fi-problems-macos-sierra/

alwex commented 6 years ago

I know this issue has been closed, but I just had the issue recently and found what was causing this. Here is what happens to me, a corrupted file have been downloaded on the build server during a previous build, or a savagely aborted build, I can't really tell. But I was having the exact same error message as described above. To find out what was going on, I decided to start logging every steps on the download-realm.js file and found out that the download is not triggered if a file is already present on a temporary folder, was this one for me /var/folders/5v/lgs_9f8d6ms25pf_09y2xvfc0000gn/T/realm-sync-cocoa-2.2.10.tar.gz

Fixing the issue was then just about deleting this corrupted file and running the build again. This would explain the issue being resolved after a restart or even after a format as well as the issue encountered by some when on an unstable network.

Hope this can help someone.

dexiouz commented 3 years ago

I resolved this issue by getting a stronger network connection.