CoreyKaylor / Lightning.NET

.NET library for LMDB key-value store
Other
397 stars 82 forks source link

Unable to load shared library 'lmdb' on Linux #133

Closed eaba closed 3 years ago

eaba commented 3 years ago
System.DllNotFoundException: Unable to load shared library 'lmdb' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: liblmdb: cannot open shared object file: No such file or directory
[Node #1(first)]   at LightningDB.Native.LmdbMethods.mdb_env_create(IntPtr& env)
[Node #1(first)]   at LightningDB.Native.Lmdb.mdb_env_create(IntPtr& env)
[Node #1(first)]   at LightningDB.LightningEnvironment..ctor(String path, EnvironmentConfiguration configuration)
[Node #1(first)]   at Akka.DistributedData.LightningDB.LmdbDurableStore.get_Lmdb() in /home/vsts/work/1/s/src/contrib/cluster/Akka.DistributedData.LightningDB/LmdbDurableStore.cs:line 79
[Node #1(first)]   at Akka.DistributedData.LightningDB.LmdbDurableStore.<Active>b__19_0(Store store) in /home/vsts/work/1/s/src/contrib/cluster/Akka.DistributedData.LightningDB/LmdbDurableStore.cs:line 161
[Node #1(first)]Cause: System.DllNotFoundException: Unable to load shared library 'lmdb' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: liblmdb: cannot open shared object file: No such file or directory
[Node #1(first)]   at LightningDB.Native.LmdbMethods.mdb_env_create(IntPtr& env)
[Node #1(first)]   at LightningDB.Native.Lmdb.mdb_env_create(IntPtr& env)
[Node #1(first)]   at LightningDB.LightningEnvironment..ctor(String path, EnvironmentConfiguration configuration)
[Node #1(first)]   at Akka.DistributedData.LightningDB.LmdbDurableStore.get_Lmdb() in /home/vsts/work/1/s/src/contrib/cluster/Akka.DistributedData.LightningDB/LmdbDurableStore.cs:line 79
[Node #1(first)]   at Akka.DistributedData.LightningDB.LmdbDurableStore.<Active>b__19_0(Store store) in /home/vsts/work/1/s/src/contrib/cluster/Akka.DistributedData.LightningDB/LmdbDurableStore.cs:line 161
[Node #1(first)]   at LightningDB.Native.LmdbMethods.mdb_env_create(IntPtr& env)
[Node #1(first)]   at LightningDB.Native.Lmdb.mdb_env_create(IntPtr& env)
[Node #1(first)]   at LightningDB.LightningEnvironment..ctor(String path, EnvironmentConfiguration configuration)
[Node #1(first)]   at Akka.DistributedData.LightningDB.LmdbDurableStore.get_Lmdb() in /home/vsts/work/1/s/src/contrib/cluster/Akka.DistributedData.LightningDB/LmdbDurableStore.cs:line 79
[Node #1(first)]   at Akka.DistributedData.LightningDB.LmdbDurableStore.<Active>b__19_0(Store store) in /home/vsts/work/1/s/src/contrib/cluster/Akka.DistributedData.LightningDB/LmdbDurableStore.cs:line 161
[Node #1(first)]Cause: System.DllNotFoundException: Unable to load shared library 'lmdb' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: liblmdb: cannot open shared object file: No such file or directory
[Node #1(first)]   at LightningDB.Native.LmdbMethods.mdb_env_create(IntPtr& env)
[Node #1(first)]   at LightningDB.Native.Lmdb.mdb_env_create(IntPtr& env)
[Node #1(first)]   at LightningDB.LightningEnvironment..ctor(String path, EnvironmentConfiguration configuration)
[Node #1(first)]   at Akka.DistributedData.LightningDB.LmdbDurableStore.get_Lmdb() in /home/vsts/work/1/s/src/contrib/cluster/Akka.DistributedData.LightningDB/LmdbDurableStore.cs:line 79
[Node #1(first)]   at Akka.DistributedData.LightningDB.LmdbDurableStore.<Active>b__19_0(Store store) in /home/vsts/work/1/s/src/contrib/cluster/Akka.DistributedData.LightningDB/LmdbDurableStore.cs:line 161
[Node #1(first)]   at LightningDB.Native.LmdbMethods.mdb_env_create(IntPtr& env)
[Node #1(first)]   at LightningDB.Native.Lmdb.mdb_env_create(IntPtr& env)
[Node #1(first)]   at LightningDB.LightningEnvironment..ctor(String path, EnvironmentConfiguration configuration)
[Node #1(first)]   at Akka.DistributedData.LightningDB.LmdbDurableStore.get_Lmdb() in /home/vsts/work/1/s/src/contrib/cluster/Akka.DistributedData.LightningDB/LmdbDurableStore.cs:line 79
[Node #1(first)]   at Akka.DistributedData.LightningDB.LmdbDurableStore.<Active>b__19_0(Store store) in /home/vsts/work/1/s/src/contrib/cluster/Akka.DistributedData.LightningDB/LmdbDurableStore.cs:line 161
eaba commented 3 years ago

How does one set the path via Code or Configuration - am asking because of this:

- name: Test (Linux)
        working-directory: ${{ runner.workspace }}/Lightning.NET
        run: LD_LIBRARY_PATH=${{ runner.workspace}}/Lightning.NET/lmdb/libraries/liblmdb/:$LD_LIBRARY_PATH dotnet test -f netcoreapp3.1 --no-restore --verbosity normal
        if: matrix.os == 'ubuntu-latest'
AlgorithmsAreCool commented 3 years ago

@eaba I've seen this issue, I'll take a look soon

eaba commented 3 years ago

I was able to get pass this with the following:

 - script: make --directory=$(build.sourcesDirectory)/lmdb/libraries/liblmdb/
    displayName: 'Build lmdb native lib'
    condition: in( variables['Agent.OS'], 'Linux', 'Darwin' )
 - script: echo '##vso[task.setvariable variable=LD_LIBRARY_PATH]$(build.sourcesDirectory)/lmdb/libraries/liblmdb/'
    displayName: Set LMDB Env Variable
    condition: in( variables['Agent.OS'], 'Linux', 'Darwin' )
simonfisher16 commented 3 years ago

I am getting this same error (below), running dotnet core 3.1 on Amazon Linux 2. I'm not following the above, how exactly can I fix this?

"Unable to load shared library 'lmdb' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: liblmdb: cannot open shared object file: No such file or directorySystem.DllNotFoundException: Unable to load shared library 'lmdb' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: liblmdb: cannot open shared object file: No such file or directory at LightningDB.Native.LmdbMethods.mdb_env_create(IntPtr& env) at LightningDB.Native.Lmdb.mdb_env_create(IntPtr& env) at LightningDB.LightningEnvironment..ctor(String path, EnvironmentConfiguration configuration)"

Thanks Simon

simonfisher16 commented 3 years ago

@eaba

 - script: make --directory=$(build.sourcesDirectory)/lmdb/libraries/liblmdb/
    displayName: 'Build lmdb native lib'
    condition: in( variables['Agent.OS'], 'Linux', 'Darwin' )
 - script: echo '##vso[task.setvariable variable=LD_LIBRARY_PATH]$(build.sourcesDirectory)/lmdb/libraries/liblmdb/'
    displayName: Set LMDB Env Variable
    condition: in( variables['Agent.OS'], 'Linux', 'Darwin' )

I'm not quite following how you fixed this. Any ideas how I can fix this on Amazon Linux or Ubuntu? Do I need to set some environment config?

eaba commented 3 years ago

@eaba

 - script: make --directory=$(build.sourcesDirectory)/lmdb/libraries/liblmdb/
    displayName: 'Build lmdb native lib'
    condition: in( variables['Agent.OS'], 'Linux', 'Darwin' )
 - script: echo '##vso[task.setvariable variable=LD_LIBRARY_PATH]$(build.sourcesDirectory)/lmdb/libraries/liblmdb/'
    displayName: Set LMDB Env Variable
    condition: in( variables['Agent.OS'], 'Linux', 'Darwin' )

I'm not quite following how you fixed this. Any ideas how I can fix this on Amazon Linux or Ubuntu? Do I need to set some environment config?

I did that in Azure pipeline template yaml. make --directory=$(build.sourcesDirectory) - compiles the code. echo '##vso[task.setvariable variable=LD_LIBRARY_PATH]$(build.sourcesDirectory)/lmdb/libraries/liblmdb/' - sets the path environment variable for azure....

What I did was used in CI...if u are doing it manually then you will need to set the path environment variable and then run the make script

CoreyKaylor commented 3 years ago

It might be the path of least resistance to include linux binaries in the nuget at this point. I didn't bother early on because there was a lot of churn, but thinking the dust has settled by now.

Anybody up for a PR?

eaba commented 3 years ago

The last time I checked, nuget had linux libraries included but somehow that is not being discovered on linux

CoreyKaylor commented 3 years ago

Fixed by 057e8410e2c