Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrations Bundle needs help finding SQLIte on MacOS #25483

Closed
julielerman opened this issue Aug 11, 2021 · 10 comments · Fixed by #26005
Closed

Migrations Bundle needs help finding SQLIte on MacOS #25483

julielerman opened this issue Aug 11, 2021 · 10 comments · Fixed by #26005
Assignees
Labels
area-tools closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. customer-reported type-bug
Milestone

Comments

@julielerman
Copy link

julielerman commented Aug 11, 2021

Some of this was detailed in #19693. But at this point it deserves its own issue.

When executing ./bundle that was targetting SQLite, I got the error:
"System.DllNotFoundException: Unable to load shared library 'e_sqlite3' or one of its dependencies. "

I had this problem on two MacBooks (Big Sur) in VS Code. With the same project in VS Code on Windows , bundle succeeded.

I did a lot of testing and reading.

These two issues were useful reads and triggered the idea that finally led me to success although it is a HACK.

  1. Unable to load e_sqlite3.dll for Microsoft.EntityFrameworkCore.Sqlite 3.0.0 natemcmaster/DotNetCorePlugins#84
  2. DllNotFoundException: Unable to load DLL 'e_sqlite3' or one of its dependencies natemcmaster/DotNetCorePlugins#214

What ultimately worked was copying the osx/64 runtime file (in bin/debug /runtimes) into the same file path as bundle.exe.

Here you can see where bundle failed (before I copied the file) and then succeeded after I copied the file.

(Ignore the project name I was just reusing an existing project :) )

2021-08-10_20-14-20

Obviously it's a hack but I don't know my way around this well enough to take this info and come up with the real problem and thereby a proper solution.

Include stack traces

➜  CosmosProviderSample git:(removeowned) ✗ ./bundle
System.TypeInitializationException: The type initializer for 'Microsoft.Data.Sqlite.SqliteConnection' threw an exception.
 ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
 ---> System.DllNotFoundException: Unable to load shared library 'e_sqlite3' or one of its dependencies. In order to help diagnose loading problems, consider setting the DYLD_PRINT_LIBRARIES environment variable: dlopen(libe_sqlite3, 1): image not found
   at System.Runtime.InteropServices.NativeLibrary.LoadByName(String libraryName, QCallAssembly callingAssembly, Boolean hasDllImportSearchPathFlag, UInt32 dllImportSearchPathFlag, Boolean throwOnError) in System.Private.CoreLib.dll:token 0x6004664+0x41
   at System.Runtime.InteropServices.NativeLibrary.LoadLibraryByName(String libraryName, Assembly assembly, Nullable`1 searchPath, Boolean throwOnError) in System.Private.CoreLib.dll:token 0x6004662+0x7
   at System.Runtime.InteropServices.NativeLibrary.Load(String libraryName, Assembly assembly, Nullable`1 searchPath) in System.Private.CoreLib.dll:token 0x6004669+0xe
   at SQLitePCL.NativeLibrary.Load(String libraryName, Assembly assy, Int32 flags) in SQLitePCLRaw.nativelibrary.dll:token 0x6000001+0x0
   at SQLitePCL.Batteries_V2.MakeDynamic(String name, Int32 flags) in SQLitePCLRaw.batteries_v2.dll:token 0x6000002+0x10
   at SQLitePCL.Batteries_V2.DoDynamic_cdecl(String name, Int32 flags) in SQLitePCLRaw.batteries_v2.dll:token 0x6000003+0x0
   at SQLitePCL.Batteries_V2.Init() in SQLitePCLRaw.batteries_v2.dll:token 0x6000004+0x0
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Span`1& arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) in System.Private.CoreLib.dll:token 0x6004d94+0x23
   at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters) in System.Private.CoreLib.dll:token 0x6004c98+0x0
   at Microsoft.Data.Sqlite.Utilities.BundleInitializer.Initialize() in Microsoft.Data.Sqlite.dll:token 0x60001d8+0x20
   at Microsoft.Data.Sqlite.SqliteConnection..cctor() in Microsoft.Data.Sqlite.dll:token 0x60000a1+0x0
   --- End of inner exception stack trace ---
   at Microsoft.Data.Sqlite.SqliteConnection..ctor(String connectionString) in Microsoft.Data.Sqlite.dll:token 0x60000a3+0x0
   at Microsoft.EntityFrameworkCore.Sqlite.Storage.Internal.SqliteRelationalConnection.CreateDbConnection() in Microsoft.EntityFrameworkCore.Sqlite.dll:token 0x6000159+0x0
   at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.get_DbConnection() in Microsoft.EntityFrameworkCore.Relational.dll:token 0x6000514+0x25
   at Microsoft.EntityFrameworkCore.Diagnostics.RelationalLoggerExtensions.MigrateUsingConnection(IDiagnosticsLogger`1 diagnostics, IMigrator migrator, IRelationalConnection connection) in Microsoft.EntityFrameworkCore.Relational.dll:token 0x6001645+0x10
   at Microsoft.EntityFrameworkCore.Migrations.Internal.Migrator.Migrate(String targetMigration) in Microsoft.EntityFrameworkCore.Relational.dll:token 0x6000fc3+0x0
   at Microsoft.EntityFrameworkCore.Design.Internal.MigrationsOperations.UpdateDatabase(String targetMigration, String connectionString, String contextType) in Microsoft.EntityFrameworkCore.Design.dll:token 0x6000479+0x2e
   at Microsoft.EntityFrameworkCore.Design.MigrationsBundle.ExecuteInternal(String context, Assembly assembly, Assembly startupAssembly, String[] args, String migration, String connection) in Microsoft.EntityFrameworkCore.Design.dll:token 0x60003da+0x4a
   at Microsoft.EntityFrameworkCore.Design.MigrationsBundle.<>c__DisplayClass0_0.<Execute>b__0(String[] args) in Microsoft.EntityFrameworkCore.Design.dll:token 0x600065e+0x30
   at Microsoft.DotNet.Cli.CommandLine.CommandLineApplication.Execute(String[] args) in Microsoft.EntityFrameworkCore.Design.dll:token 0x6000097+0x100
   at Microsoft.EntityFrameworkCore.Design.MigrationsBundle.Execute(String context, Assembly assembly, Assembly startupAssembly, String[] args) in Microsoft.EntityFrameworkCore.Design.dll:token 0x60003d9+0xe5
The type initializer for 'Microsoft.Data.Sqlite.SqliteConnection' threw an exception.

Include provider and version information

EF Core version: 6.0.0-rc.1.21409.2
EF Core Tools version: 6.0.0-rc.1.21409.2
Database provider: Microsoft.EntityFrameworkCore.Sqlite
Target framework: .NET 6.0
Operating system: Macos Big Sur
IDE: VS Code 1.59.0

@ajcvickers
Copy link
Member

/cc @bricelam

@bricelam
Copy link
Contributor

Does this work?

DYLD_LIBRARY_PATH=$HOME/.net ./bundle

@julielerman
Copy link
Author

sorry same error

@julielerman
Copy link
Author

I had changed over to preview7 so now using daily builds (including dotnet-ef) with 6.0.0-rc.1.21412.2 and trying again. After that I will upload to github

@julielerman
Copy link
Author

same result (also note, the dbcontext bundle command fails if csproj refs 6.0.0-x but works if i specify daily build version)

@bricelam
Copy link
Contributor

also note, the dbcontext bundle command fails if csproj refs 6.0.0-x but works if i specify daily build version

I think this is because the same NuGet.Config file isn't being used (because it's in a different directory) when restoring the temporary bundle project.

@ajcvickers ajcvickers added this to the 6.0.0 milestone Aug 17, 2021
bricelam added a commit to bricelam/efcore that referenced this issue Sep 13, 2021
@bricelam bricelam added the closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. label Sep 13, 2021
@bricelam bricelam modified the milestones: 6.0.0, 6.0.0-rc2 Sep 14, 2021
@julielerman
Copy link
Author

awesome. Will try daily builds. Thanks!

@julielerman
Copy link
Author

julielerman commented Sep 15, 2021

Is this in a daily build yet? Latest tool package I am getting is 6.0.0-rc.2.21457.19 which isn't doing the trick. I'm just assuming I have to be more patient. :)
GOT IT! Yay. Version 6.0.0-rc.2.21465.1 did the trick for me. Thanks for the fix, @bricelam :)

@bricelam
Copy link
Contributor

Yay! Thank you for taking the time to verify the fix.

@ajcvickers ajcvickers modified the milestones: 6.0.0-rc2, 6.0.0 Nov 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-tools closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. customer-reported type-bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants