Realm-js: Brand new realm 2.1.1 install, build fails (old lzma-native dependency)

Created on 18 Dec 2017  ·  18Comments  ·  Source: realm/realm-js

Goals

What are you trying to achieve?

Install realm in a react native project

What did you expect to happen?

Build successful

What happened instead?

Build fails. Unmet dependencies with lzma-native.

It seems that when extracting _realm-sync-cocoa_ it looks for a _lzma-native_ module that doesn't exist (_binding-v3.0.4-node-v51-darwin-x64_ instead of _binding-v3.0.4-node-v59-darwin-x64_).

Steps to Reproduce

Create a brand new react native project, install realm-js and build:

react-native init app
cd app
npm install realm --save
react-native link

Build fails.

Code Sample

Xcode build output:

v7.10.0 is already installed.
Now using node v7.10.0 (npm v4.2.0)
Resolved requirements: { SYNC_SERVER_FOLDER: 'sync',
  SYNC_ARCHIVE: 'realm-sync-cocoa-2.1.10.tar.xz',
  SYNC_ARCHIVE_ROOT: 'core' }
Target directory has a differing lockfile, overwriting.
Extracting realm-sync-cocoa-2.1.10.tar.xz => /Users/ruben/dev/test/Wayne/node_modules/realm/vendor/realm-ios
{ Error: Cannot find module '/Users/ruben/dev/test/Wayne/node_modules/lzma-native/binding-v3.0.4-node-v51-darwin-x64/lzma_native.node'
    at Function.Module._resolveFilename (module.js:470:15)
    at Function.Module._load (module.js:418:25)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at /Users/ruben/dev/test/Wayne/node_modules/lzma-native/index.js:13:14
    at Object.<anonymous> (/Users/ruben/dev/test/Wayne/node_modules/lzma-native/index.js:595:3)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12) code: 'MODULE_NOT_FOUND' }
Command /bin/sh failed with exit code 1

Available binding folders for _lzma-native_:

binding-v3.0.1-node-v58-linux-x64
binding-v3.0.1-node-v59-linux-x64
binding-v3.0.3-node-v59-linux-x64
binding-v3.0.4-node-v59-darwin-x64

Version of Realm and Tooling

O-Community T-Bug

Most helpful comment

As @esutton points out, a mismatch of node versions can cause many problems. We are working on getting rid of our LZMA-native dependency, but we will appreciate any help on the build side.

All 18 comments

I've found this issue https://github.com/realm/realm-js/issues/1567 that seems to have the same error, even though they are using _realm-js 2.0.13_ version instead of the latest.

@rubengarciam We have seen issues with LZMA-native a number of times. We are considering not using tar.xz but good, old tar.gz.

Sweet, thanks @kneth. I know this wasn't your doing but thought it was worth raising it. That dependency seems to have caused some pain in the past already.

I'll roll back to a previous release until it gets fixed or moved to tgz :)

I'm having the same issue :(, any solution to this?

realm and lzma_native keep cropping up frequently, every other 2.x release build?

I cannot build on iOS. So frustrating and time consuming.

I must roll-back and find a realm version that worked. realm 2.0.3 maybe?

realm 1.x seemed trouble free. What is the benefit of 2.x if I am just using as a local database?

Android works.

Using:
"realm": "^2.0.12",
"react": "^16.2.0",
"react-native": "^0.51.0",

Xcode error:
{ Error: Cannot find module '/Users/edward3/Documents/projects/react-native/android-field-scout/source/node_modules/lzma-native/binding-v3.0.4-node-v51-darwin-x64/lzma_native.node' at Function.Module._resolveFilename (module.js:470:15) at Function.Module._load (module.js:418:25) at Module.require (module.js:498:17) at require (internal/module.js:20:19) at /Users/edward3/Documents/projects/react-native/android-field-scout/source/node_modules/lzma-native/index.js:13:14 at Object.<anonymous> (/Users/edward3/Documents/projects/react-native/android-field-scout/source/node_modules/lzma-native/index.js:595:3) at Module._compile (module.js:571:32) at Object.Module._extensions..js (module.js:580:10) at Module.load (module.js:488:32) at tryModuleLoad (module.js:447:12) code: 'MODULE_NOT_FOUND' } Command /bin/sh failed with exit code 1

Same as @rubengarciam
````
"name": "lzma-native",
"version": "3.0.4",

Edwards-MacBook-Pro:lzma-native edward3$ tree binding*
binding-v3.0.1-node-v58-linux-x64
└── lzma_native.node
binding-v3.0.1-node-v59-linux-x64
└── lzma_native.node
binding-v3.0.3-node-v59-linux-x64
└── lzma_native.node
binding-v3.0.4-node-v59-darwin-x64
└── lzma_native.node
binding.gyp [error opening dir]
````

@rubengarciam Solved. Should this issue be closed?

Problem: Caused by node version mismatch ( I think )

Xcode uses /usr/local/bin/node and node in the path ( which node ) not matching.

https://github.com/realm/realm-js/issues/1424

node --version v9.2.1 /usr/local/bin/node --version v7.2.0

I am not a node.js expert. I am not sure how I got into this state?

  • Perhaps using nvm complicated the matter.
  • I may have installed Node.js in the past using a macOS package installer.
  • I plan to use only homebrew from now on.

My approach was to uninstall all node versions, nvm, and stick yo using homebrew in the future.

I uninstalled nvm because I did not understand how to make it work with the node version that xcode finds.

Uninstall nvm:
1) Remove any nvm lines from ~/.bash_profile (and/or ~/.profile)
2) rm -rf ~/.nvm
3) Reopen shell, or re-source your bash profile.

brew uninstall node brew uninstall nvm

Remove node.js
https://stackoverflow.com/questions/11177954/how-do-i-completely-uninstall-node-js-and-reinstall-from-beginning-mac-os-x
````

!/bin/bash

set -x
echo Xcode uses node from /usr/local/bin/ directory.
node --version
/usr/local/bin/node --version

sudo rm -rf /usr/local/lib/node /usr/local/lib/node_modules /var/db/receipts/org.nodejs.*
sudo rm -rf /usr/local/include/node /Users/$USER/.npm
sudo rm /usr/local/bin/node
sudo rm /usr/local/share/man/man1/node.1
sudo rm /usr/local/bin/npm
sudo rm /usr/local/share/systemtap/tapset/node.stp
sudo rm /usr/local/lib/dtrace/node.d
Verify node is not in path.
node --version
/usr/local/bin/node --version
````

Reinstall
brew install node brew install yarn

I am adding this script to either Xcode or package.json scripts/postinstall:

````

!/bin/bash

nodeVersionInPath=$(node --version)
nodeVersionXcode=$(/usr/local/bin/node --version)
if [ "$nodeVersionInPath" != "$nodeVersionXcode" ]; then
echo "* Error: node version mismatch may cause Xcode build failures"
echo "Xcode uses /usr/local/bin/node = ${nodeVersionXcode}"
echo "node in path $(which node) : ${nodeVersionInPath}"
exit 1
fi
````

I'm having the same issue, I've tried with different versions of Realm but I can't solve the problem, very frustrating... I don't have the version mismatch anymore but still the problem... any clue?

I am also facing following error while installing realm 👍
ode-pre-gyp ERR! Tried to download(undefined): https://node-pre-gyp.addaleax.net/lzma-native/lzma_native-v3.0.4-node-v57-darwin-x64.tar.gz
node-pre-gyp ERR! Pre-built binaries not found for [email protected] and [email protected] (node-v57 ABI, unknown) (falling back to source compile with node-gyp)

As @esutton points out, a mismatch of node versions can cause many problems. We are working on getting rid of our LZMA-native dependency, but we will appreciate any help on the build side.

@kneth It will be really great if it can be solved.Thanks :)

I solved it by NVM

  1. Please check the node version installed in error message, such as this one: 'v7.10.0 is already installed'

  2. then run below commands
    nvm use v7.10.0
    npm i lzma-native -D

you can see that the correct version of lzma_native.node installed

@vincentsong Good catch. But still I would like to get rid of the LZMA dependency :smile:

From my understanding, all you need is to have the matching node version at the time of realm installation. If you don't use nvm you will have to replace your current node with the correct version, and then replace that one with the one you had in the first place (if you really have to use that one)

So if you use nvm:

  • switch to the correct node version (v7.10.0 in my case)
  • delete node_modules (so that the modules will be downloaded again)
  • npm install (with the correct version)

After this you can go back to the version you prefer. At least in my case I have done this for every realm update so far.

I solved with following

  1. goto https://node-pre-gyp.addaleax.net/lzma-native/ and download you version v3.0.4-node-v51-darwin-x64
  2. goto node_modules/realm/node_modules/lzma-native if folder not exist, go to node_modules/realm and run npm install, folder will be here.
  3. goto node_modules/realm/node_modules/lzma-native and extract file lzma_native-v3.0.4-node-v51-darwin-x64.tar.gz you will have a folder binding-v3.0.4-node-v51-darwin-x64
  4. now, build you project again, pass...

@duguying This works for me! Thanks a lot.

@kneth Getting Rid of LZMA dependency will be a nice idea as in organisation level multiple people work on projects, and everyone may not save node v7.

for me I need to ensure both
node --version
/usr/local/bin/node --version
are v7.6.0

Was this page helpful?
0 / 5 - 0 ratings