hyperledger-archives / aries-mobile-agent-xamarin

Apache License 2.0
38 stars 31 forks source link

Not able to run the mediator on mac #10

Closed lalc closed 3 years ago

lalc commented 4 years ago

Tried to follow the instructions can ran it on mac (10.14.6 Mojave)

It gives this exception:

Lals MB: dotnet run
Unhandled exception. System.DllNotFoundException: Unable to load shared library 'indy' or one of its dependencies. In order to help diagnose loading problems, consider setting the DYLD_PRINT_LIBRARIES environment variable: dlopen(libindy, 1): image not found
   at Hyperledger.Indy.WalletApi.NativeMethods.indy_create_wallet(Int32 command_handle, String config, String credentials, IndyMethodCompletedDelegate cb)
   at Hyperledger.Indy.WalletApi.Wallet.CreateWalletAsync(String config, String credentials)
   at Hyperledger.Aries.Storage.DefaultWalletService.CreateWalletAsync(WalletConfiguration configuration, WalletCredentials credentials)
   at Hyperledger.Aries.Configuration.DefaultProvisioningService.ProvisionAgentAsync(AgentOptions agentOptions)
   at Hyperledger.Aries.Agents.Edge.MediatorProvisioningService.StartAsync(CancellationToken cancellationToken)
   at Microsoft.Extensions.Hosting.Internal.Host.StartAsync(CancellationToken cancellationToken)
   at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
   at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
   at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.Run(IHost host)
   at mediator.Program.Main(String[] args) in /Users/lal@igrant.io/iGrant/hyperledgerIndy/aries-mobileagent-xamarin/mediator/Program.cs:line 16

dotnet environment is as given:

Lals MB: dotnet --info
.NET Core SDK (reflecting any global.json):
 Version:   3.1.401
 Commit:    39d17847db

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  10.14
 OS Platform: Darwin
 RID:         osx.10.14-x64
 Base Path:   /usr/local/share/dotnet/sdk/3.1.401/

Host (useful for support):
  Version: 3.1.7
  Commit:  fcfdef8d6b

.NET Core SDKs installed:
  3.1.401 [/usr/local/share/dotnet/sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.App 3.1.7 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.1.21 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.7 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
tmarkovski commented 4 years ago

Try copying the libindy.dylib into your output folder, usually bin/Debug/netcoreapp3.1 if you're running in Debug mode.

lalc commented 4 years ago

After I tried building the libindy sdk on my machine, and copying over the library file to /mediator/bin/Debug/ now works. So, could use this issue to either update the docs or to fix the library dependencies.

Also, it only works if we keep leave the library at /mediator/bin/Debug/ folder. Setting path variables doesn't work.

spsingh559 commented 4 years ago

I have also the same issue.

dotnet info:

.NET Core SDK (reflecting any global.json): Version: 3.1.403 Commit: 9e895200cd

Runtime Environment: OS Name: Mac OS X OS Version: 10.15 OS Platform: Darwin RID: osx.10.15-x64 Base Path: /usr/local/share/dotnet/sdk/3.1.403/

Host (useful for support): Version: 3.1.9 Commit: 774fc3d6a9

.NET Core SDKs installed: 3.1.403 [/usr/local/share/dotnet/sdk]

.NET Core runtimes installed: Microsoft.AspNetCore.App 3.1.9 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.NETCore.App 3.1.9 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]

I have places the libindy.dylib file in Debug as well as netcoreapp3.1, but the error is the same.

image

what could be the possible solution?

tmarkovski commented 4 years ago

@spsingh559 Did you download the library or built it yourself?

spsingh559 commented 4 years ago

I downloaded the static library from https://github.com/hyperledger/indy-sdk#macos and even try to build from the source https://github.com/hyperledger/indy-sdk/blob/master/docs/build-guides/mac-build.md but nothing works out.

spsingh559 commented 4 years ago

Finally, the issue has been fixed by adding environment variable targeting to indy sdk build.

export LIBRARY_PATH=$HOME/indy-sdk/libindy/target/debug export LD_LIBRARY_PATH=$LIBRARY_PATH export DYLD_LIBRARY_PATH=$LIBRARY_PATH export PATH=$PATH:$LIBRARY_PATH:$LD_LIBRARY_PATH:$DYLD_LIBRARY_PATH

Note: I have not placed libindy.dylib anywhere. Just followed the instruction to build from the source https://github.com/hyperledger/indy-sdk/blob/master/docs/build-guides/mac-build.md and then add the above environment variable as shown above in .zshrc file

Try removing wallet, to start mediator afresh. cd $HOME/.indy_client rm -rf wallet

tmarkovski commented 4 years ago

Glad you solved this. It's unfortunate that there's no one way that works for everyone. Libindy has too many external dependencies and this has been a point of great friction.