strongloop-community / loopback-sdk-xamarin

LoopBack Xamarin SDK
http://loopback.io
Other
11 stars 4 forks source link

Installation problem #2

Open casamia918 opened 8 years ago

casamia918 commented 8 years ago

[Environment]

  1. OS X 10.11.4 (El capitan)
  2. node -v v4.4.3
  3. mono --version Mono JIT compiler version 4.4.0 (mono-4.4.0-branch/a3fabf1 Fri Apr 8 13:48:29 EDT 2016) Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com TLS: normal SIGSEGV: altstack Notification: kqueue Architecture: x86 Disabled: none Misc: softdebug LLVM: yes(3.6.0svn-mono-master/a173357) GC: sgen

I'm following the installation guid step by step.

Clone the git repositories and executed

$npm install. 

Then, the error message is

Installing MacOS dependencies 2/3: Mono64. This might take a while.
Error: Command failed: /bin/sh -c brew install https://raw.githubusercontent.com/tjanczuk/edge/master/tools/mono64.rb
Error: Failure while executing: /usr/bin/curl -f#LA Homebrew/0.9.9\ (Macintosh;\ Intel\ Mac\ OS\ X\ 10.11.3)\ curl/7.43.0 https://raw.githubusercontent.com/tjanczuk/edge/master/tools/mono64.rb -o /Library/Caches/Homebrew/Formula/mono64.rb --silent

I found that loopback-sdk-generator needs mono64, and the brew install link in the install script is broken. So I installed mono64 by official homepage. http://www.mono-project.com/download/ -> Download Mono Universal Installer

After install mono64(Wait. when I command mono --version, its architecture shows x86, not x64.Is this important?) I execute the lb-xm command

$ node bin/lb-xm /path/to/server/script

Then the error message is

Error: The edge native module is not available at /Users/HiChoi/dev/loopback.io/loopback-sdk-xamarin/node_modules/edge/build/Release/edge.node. You can use EDGE_NATIVE environment variable to provide alternate location of edge.node. If you need to build edge.node, follow build instructions for your platform at https://github.com/tjanczuk/edge
    at Object.<anonymous> (/Users/HiChoi/dev/loopback.io/loopback-sdk-xamarin/node_modules/edge/lib/edge.js:34:11)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (/Users/HiChoi/dev/loopback.io/loopback-sdk-xamarin/bin/lb-xm.js:9:12)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)

I followed the edge build guide from https://github.com/tjanczuk/edge.

$npm install edge -> Error

No package 'mono-2' found
gyp: Call to 'pkg-config mono-2 --libs' returned exit status 1 while in binding.gyp. while trying to load binding.gyp 

I searched the problem and it needs to set path PKG_CONFIG_PATH. So I executed

$export PKG_CONFIG_PATH=/Library/Frameworks/Mono.framework/Versions/Current/lib/pkgconfig

And then, again

$npm install edge        -> Error
 CXX(target) Release/obj.target/edge/src/mono/clractioncontext.o
In file included from ../src/mono/clractioncontext.cpp:1:
In file included from ../src/mono/edge.h:4:
In file included from ../src/mono/../common/edge_common.h:8:
../node_modules/nan/nan.h:324:27: error: redefinition of 'NanEnsureHandleOrPersistent'
  NAN_INLINE v8::Local<T> NanEnsureHandleOrPersistent(const v8::Local<T> &val) {
                          ^
../node_modules/nan/nan.h:319:17: note: previous definition is here
  v8::Handle<T> NanEnsureHandleOrPersistent(const v8::Handle<T> &val) {
                ^
../node_modules/nan/nan.h:344:27: error: redefinition of 'NanEnsureLocal'
  NAN_INLINE v8::Local<T> NanEnsureLocal(const v8::Handle<T> &val) {
                          ^
../node_modules/nan/nan.h:334:27: note: previous definition is here
  NAN_INLINE v8::Local<T> NanEnsureLocal(const v8::Local<T> &val) {
                          ^
../node_modules/nan/nan.h:757:13: error: no member named 'smalloc' in namespace 'node'
    , node::smalloc::FreeCallback callback
      ~~~~~~^
../node_modules/nan/nan.h:768:12: error: no matching function for call to 'New'
    return node::Buffer::New(v8::Isolate::GetCurrent(), data, size);
           ^~~~~~~~~~~~~~~~~
/Users/HiChoi/.node-gyp/4.4.3/include/node/node_buffer.h:31:40: note: candidate function not viable: no known conversion from
      'uint32_t' (aka 'unsigned int') to 'enum encoding' for 3rd argument
NODE_EXTERN v8::MaybeLocal<v8::Object> New(v8::Isolate* isolate,
                                       ^
/Users/HiChoi/.node-gyp/4.4.3/include/node/node_buffer.h:43:40: note: candidate function not viable: 2nd argument
      ('const char *') would lose const qualifier
NODE_EXTERN v8::MaybeLocal<v8::Object> New(v8::Isolate* isolate,
                                       ^
/Users/HiChoi/.node-gyp/4.4.3/include/node/node_buffer.h:28:40: note: candidate function not viable: requires 2 arguments, but 3
      were provided
NODE_EXTERN v8::MaybeLocal<v8::Object> New(v8::Isolate* isolate, size_t length);
                                       ^
/Users/HiChoi/.node-gyp/4.4.3/include/node/node_buffer.h:36:40: note: candidate function not viable: requires 5 arguments, but 3
      were provided
NODE_EXTERN v8::MaybeLocal<v8::Object> New(v8::Isolate* isolate,
                                       ^
In file included from ../src/mono/clractioncontext.cpp:1:
In file included from ../src/mono/edge.h:4:
In file included from ../src/mono/../common/edge_common.h:8:
../node_modules/nan/nan.h:772:12: error: no viable conversion from returned value of type 'v8::MaybeLocal<v8::Object>' to
      function return type 'v8::Local<v8::Object>'
    return node::Buffer::New(v8::Isolate::GetCurrent(), size);
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/HiChoi/.node-gyp/4.4.3/include/node/v8.h:210:7: note: candidate constructor (the implicit copy constructor) not viable: no
      known conversion from 'v8::MaybeLocal<v8::Object>' to 'const v8::Local<v8::Object> &' for 1st argument
class Local {
      ^
/Users/HiChoi/.node-gyp/4.4.3/include/node/v8.h:210:7: note: candidate constructor (the implicit move constructor) not viable: no
      known conversion from 'v8::MaybeLocal<v8::Object>' to 'v8::Local<v8::Object> &&' for 1st argument
/Users/HiChoi/.node-gyp/4.4.3/include/node/v8.h:214:13: note: candidate template ignored: could not match 'Local' against
      'MaybeLocal'
  V8_INLINE Local(Local<S> that)
            ^
/Users/HiChoi/.node-gyp/4.4.3/include/node/v8.h:326:13: note: candidate template ignored: could not match 'S *' against
      'v8::MaybeLocal<v8::Object>'
  V8_INLINE Local(S* that)
            ^
In file included from ../src/mono/clractioncontext.cpp:1:
In file included from ../src/mono/edge.h:4:
In file included from ../src/mono/../common/edge_common.h:8:
../node_modules/nan/nan.h:779:26: error: no member named 'Use' in namespace 'node::Buffer'
    return node::Buffer::Use(v8::Isolate::GetCurrent(), data, size);
           ~~~~~~~~~~~~~~^
In file included from ../src/mono/clractioncontext.cpp:1:
In file included from ../src/mono/edge.h:4:
In file included from ../src/mono/../common/edge_common.h:4:
/Users/HiChoi/.node-gyp/4.4.3/include/node/v8.h:221:5: error: assigning to 'v8::Primitive *volatile' from incompatible type
      'v8::Value *'
    TYPE_CHECK(T, S);
    ^~~~~~~~~~~~~~~~
/Users/HiChoi/.node-gyp/4.4.3/include/node/v8.h:180:37: note: expanded from macro 'TYPE_CHECK'
    *(static_cast<T* volatile*>(0)) = static_cast<S*>(0);      \
                                    ^ ~~~~~~~~~~~~~~~~~~
../node_modules/nan/nan.h:501:12: note: in instantiation of function template specialization
      'v8::Local<v8::Primitive>::Local<v8::Value>' requested here
    return NanEscapeScope(NanNew(v8::Undefined(v8::Isolate::GetCurrent())));
           ^
../node_modules/nan/nan.h:483:30: note: expanded from macro 'NanEscapeScope'
# define NanEscapeScope(val) scope.Escape(Nan::imp::NanEnsureLocal(val))
                             ^
In file included from ../src/mono/clractioncontext.cpp:1:
In file included from ../src/mono/edge.h:4:
In file included from ../src/mono/../common/edge_common.h:4:
/Users/HiChoi/.node-gyp/4.4.3/include/node/v8.h:221:5: error: assigning to 'v8::Boolean *volatile' from incompatible type
      'v8::Value *'
    TYPE_CHECK(T, S);
    ^~~~~~~~~~~~~~~~
/Users/HiChoi/.node-gyp/4.4.3/include/node/v8.h:180:37: note: expanded from macro 'TYPE_CHECK'
    *(static_cast<T* volatile*>(0)) = static_cast<S*>(0);      \
                                    ^ ~~~~~~~~~~~~~~~~~~
../node_modules/nan/nan.h:511:12: note: in instantiation of function template specialization
      'v8::Local<v8::Boolean>::Local<v8::Value>' requested here
    return NanEscapeScope(NanNew(v8::True(v8::Isolate::GetCurrent())));
           ^
../node_modules/nan/nan.h:483:30: note: expanded from macro 'NanEscapeScope'
# define NanEscapeScope(val) scope.Escape(Nan::imp::NanEnsureLocal(val))
                             ^
In file included from ../src/mono/clractioncontext.cpp:1:
In file included from ../src/mono/edge.h:4:
In file included from ../src/mono/../common/edge_common.h:4:
/Users/HiChoi/.node-gyp/4.4.3/include/node/v8.h:221:5: error: assigning to 'v8::Function *volatile' from incompatible type
      'v8::Value *'
    TYPE_CHECK(T, S);
    ^~~~~~~~~~~~~~~~
/Users/HiChoi/.node-gyp/4.4.3/include/node/v8.h:180:37: note: expanded from macro 'TYPE_CHECK'
    *(static_cast<T* volatile*>(0)) = static_cast<S*>(0);      \
                                    ^ ~~~~~~~~~~~~~~~~~~
../node_modules/nan/nan.h:1645:12: note: in instantiation of function template specialization
      'v8::Local<v8::Function>::Local<v8::Value>' requested here
    return NanEscapeScope(NanNew(handle)->Get(kCallbackIndex)
           ^
../node_modules/nan/nan.h:483:30: note: expanded from macro 'NanEscapeScope'
# define NanEscapeScope(val) scope.Escape(Nan::imp::NanEnsureLocal(val))
                             ^
In file included from ../src/mono/clractioncontext.cpp:1:
In file included from ../src/mono/edge.h:4:
In file included from ../src/mono/../common/edge_common.h:4:
/Users/HiChoi/.node-gyp/4.4.3/include/node/v8.h:221:5: error: assigning to 'v8::Object *volatile' from incompatible type
      'v8::Value *'
    TYPE_CHECK(T, S);
    ^~~~~~~~~~~~~~~~
/Users/HiChoi/.node-gyp/4.4.3/include/node/v8.h:180:37: note: expanded from macro 'TYPE_CHECK'
    *(static_cast<T* volatile*>(0)) = static_cast<S*>(0);      \
                                    ^ ~~~~~~~~~~~~~~~~~~
../node_modules/nan/nan.h:1776:12: note: in instantiation of function template specialization
      'v8::Local<v8::Object>::Local<v8::Value>' requested here
    return NanEscapeScope(
           ^
../node_modules/nan/nan.h:483:30: note: expanded from macro 'NanEscapeScope'
# define NanEscapeScope(val) scope.Escape(Nan::imp::NanEnsureLocal(val))
                             ^
10 errors generated.
make: *** [Release/obj.target/edge/src/mono/clractioncontext.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/Users/HiChoi/.nvm/versions/node/v4.4.3/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:276:23)
gyp ERR! stack     at emitTwo (events.js:87:13)
gyp ERR! stack     at ChildProcess.emit (events.js:172:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
gyp ERR! System Darwin 15.3.0
gyp ERR! command "/Users/HiChoi/.nvm/versions/node/v4.4.3/bin/node" "/Users/HiChoi/.nvm/versions/node/v4.4.3/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "build"
gyp ERR! cwd /Users/HiChoi/dev/loopback.io/loopback-sdk-xamarin/node_modules/edge
gyp ERR! node -v v4.4.3
gyp ERR! node-gyp -v v3.3.1
gyp ERR! not ok
edge@0.10.1 node_modules/edge
├── edge-cs@0.2.7
└── nan@1.9.0

I totally lost the way at this stage. What's the problem?

richardpringle commented 8 years ago

@casamia918, this one might be tough to debug...

@superkhau or @gunjpan, can you guys both try the install?

$ git clone git@github.com:strongloop/loopback-sdk-xamarin.git
$ cd loopback-sdk-xamarin
$ npm install

If either of you see similar failures, please let me know and I will figure out how to move forward from there.

casamia918 commented 8 years ago

Nobody here?

richardpringle commented 8 years ago

Sorry, I talked to @gunjpan in person and he said he had some issues too although they were different.

I'm on windows and I had issues building edge when trying to install.

@casamia918, will keep you updated as we figure this out.

nuno-morais commented 8 years ago

Do you know when this bug will be fixed?

richardpringle commented 8 years ago

@xnramx, the issue isn't actually with this repo, it's with dependencies. Whenever we have an issue with 3rd party dependencies, it's difficult to put a timeline on it.

Your best bet is to try and figure out what's going on with the dependency and see if you can get that built, then this repo should work fine.

jpflueger commented 8 years ago

For what its worth, I got it working on my machine by manually upgrading edge. First, I followed the install instructions for edge. For me it was the following commands:

$ brew tap aspnet/dnx
$ brew update
$ brew install dnvm
$ source dnvm.sh
$ dnvm install latest -r coreclr -alias edge-coreclr
$ brew install pkg-config
$ dnvm use edge-coreclr

At this point I restarted the terminal.

$ git clone https://github.com/strongloop/loopback-sdk-xamarin.git
$ cd loopback-sdk-xamarin/
$ vim package.json

I removed the line for edge, I believe the version was ^0.10.1

$ npm install
$ npm install edge --save
$ node bin/lb-xm ~/projectroot/server/server.js check

And everything seems to work just fine. I won't pretend that I know why this works because I'm just getting started with Node but here it is.

The edge version that gets installed is ^5.0.0

richardpringle commented 8 years ago

Thanks @jpflueger! I'm going to keep this issue open so that people can find your solution. I don't want to update the package.json to ^5.0.0 until we really get the chance to dive into this (not quite sure when that will be as we currently have quite a few open issue within the LoopBack-core.

casamia918 commented 8 years ago

Thanks @jpflueger . I followed your advise, removed currently installed edge version(^0.10.1) and installed latest edge version (^5.0.0). After that, I ran the lb-xm code, and got new error.

$ node ./bin/lb-xm ~/path/to/server/server.js
>> SDK Generator.
dyld: lazy symbol binding failed: Symbol not found: _mono_config_parse
  Referenced from: ~/dev/loopback.io/loopback-sdk-xamarin/node_modules/edge/build/Release/edge_nativeclr.node
  Expected in: dynamic lookup

dyld: Symbol not found: _mono_config_parse
  Referenced from: ~/dev/loopback.io/loopback-sdk-xamarin/node_modules/edge/build/Release/edge_nativeclr.node
  Expected in: dynamic lookup

Trace/BPT trap: 5

By reading https://github.com/tjanczuk/edge, it seems to need to use core_clr variable. So I declare EDGE_USE_CORECLR variable, and got new error

$ EDGE_USE_CORECLR=1 node ./bin/lb-xm ~/path/to/server/server.js
>> SDK Generator.
>> Server parsed, templating code...

undefined:1
(function (f, ctx) { return function (d, cb) { return f(d, cb, ctx); }; })
                                                      ^
Error: Could not load type 'System.Console' from assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e'.
    at Error (native)
    at <anonymous>:1:55
    at Object.<anonymous> (/Users/HiChoi/dev/loopback.io/loopback-sdk-xamarin/bin/lb-xm.js:50:4)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Function.Module.runMain (module.js:441:10)
    at startup (node.js:139:18)
    at node.js:968:3

I read lb-xm.js line 50 and found it’s the edge function that calling LBXamarinSDKGenerator.dll. Refer to the readme, this is builded library for the C# part of the SDKgenerator. I presumed that the error is due to the system library loading. So I opened the the LBXamarinSDK.sln (C# project) to observe C# source code. Actually, I installed Xamarin Studio for my project to develop client side. At first, I updated the packages used in SDKgenerator (RestSharp or Newtonsoft.json) and tried to build but failed. Error message is

Build FAILED.
Errors:

~/loopback-sdk-xamarin/C#/LBXamarinSDK/LBXamarinSDKGenerator.csproj (Build) ->
/Library/Frameworks/Mono.framework/Versions/4.2.3/lib/mono/4.5/Microsoft.CSharp.targets (CoreCompile target) ->

    CSC: error CS2001: Source file `DynamicModels.cs' could not be found
    CSC: error CS2001: Source file `DynamicRepos.cs' could not be found
    CSC: error CS2001: Source file `HardcodedModels.cs' could not be found

     0 Warning(s)
     3 Error(s)

Time Elapsed 00:00:00.2575230

---------------------- Done ----------------------

Build: 3 errors, 0 warnings

Hmm… I blocked in every step by step. Anyway, can someone find the cause of System.console problem? Thanks.


At last, I made it. Just do jpflueger's bash command. After various trial, my loopback-sdk-xamarin project folder looks like somewhat twisted. So I removed the whole folder, uninstalled the every related products (mono, edge), and only follow the jpflueger's step.

Do not install mono by yourself from the mono homepage. When you execute

$ dnvm install latest -r coreclr -alias edge-coreclr

the mono is installed automatically during the coreclr installation step. I guess that  that my error 'cannot load type System.Console' is due to the complict of 2 mono version. (I'm not sure).

Thanks

loay commented 8 years ago

Hi @casamia918 is your issue fixed? I mean was it just the version conflict or you are still running into other issues?

casamia918 commented 8 years ago

@loay See my last comment. I fixed all isssues. What problems do you have?

gjroelofs commented 4 years ago

All my issues were fixed by replacing the requirement for edge into edge-js, in lb-xm.js, L14 (var edge = require ('edge');) -> (var edge = require ('edge-js');)