yatli / fvim

Cross platform Neovim front-end UI, built with F# + Avalonia
MIT License
1.34k stars 30 forks source link

botnet run: Unable to load shared library 'fvim-ext' or one of its dependencies #126

Closed tssm closed 4 years ago

tssm commented 4 years ago

I'm trying to run my local build on macOS Catalina, but botnet run throws an exception:

Unhandled exception. System.TypeInitializationException: The type initializer for '<StartupCode$FVim>.$FVim.theme' threw an exception.
 ---> System.TypeInitializationException: The type initializer for '<StartupCode$FVim>.$FVim.ui' threw an exception.
 ---> System.DllNotFoundException: Unable to load shared library 'fvim-ext' or one of its dependencies. In order to help diagnose loading problems, consider setting the DYLD_PRINT_LIBRARIES environment variable: dlopen(libfvim-ext, 1): image not found
   at FVim.ui.osx.vh_init()
   at <StartupCode$FVim>.$FVim.ui..cctor() in /Users/tae/Projects/fvim/ui.fs:line 401
   --- End of inner exception stack trace ---
   at FVim.ui.get_DefaultFont()
   at <StartupCode$FVim>.$FVim.theme..cctor() in /Users/tae/Projects/fvim/theme.fs:line 17
   --- End of inner exception stack trace ---
   at FVim.theme.get_themeconfig_ev()
   at FVim.ThemableViewModelBase..ctor(FSharpOption`1 x, FSharpOption`1 y, FSharpOption`1 w, FSharpOption`1 h) in /Users/tae/Projects/fvim/ViewModels/ThemableViewModelBase.fs:line 24
   at FVim.MainWindowViewModel..ctor(FSharpOption`1 cfg, FSharpOption`1 _maingrid) in /Users/tae/Projects/fvim/ViewModels/MainWindowViewModel.fs:line 22
   at FVim.Program.Main(String[] args) in /Users/tae/Projects/fvim/Program.fs:line 113

I'm have .NET 3.1.102 on my path. The full log is

log: fvim started. time = 03/07/2020 19:40:42
model: starting neovim instance...
model: opts = { intent = Start
  logToStdout = false
  logToFile = false
  logPatterns = None
  args = ["--embed"]
  program = "nvim"
  stderrenc = System.Text.UTF8Encoding+UTF8EncodingSealed
  serveropts = StartNew }
neovim.process: Starting process. Program: nvim; Arguments: --embed
neovim.process: begin read loop
model: commencing early initialization...
neovim.process: call: 0 -> [0,0,"nvim_get_api_info",[]]
model: available ui options: set
  ["ext_cmdline"; "ext_hlstate"; "ext_linegrid"; "ext_messages"; "ext_multigrid";
   "ext_popupmenu"; "ext_tabline"; "ext_termcolors"; "ext_wildmenu"; ...]
neovim.process: call: 1 -> [0,1,"nvim_set_var",["fvim_loaded",1]]
neovim.process: call: 2 -> [0,2,"nvim_set_client_info",["FVim",{"major":"0","minor":"2","prerelease":"dev"},"ui",{},{"InstanceId":"9bee470c-a234-4e84-ac3d-542b53335d47"}]]
neovim.process: call: 3 -> [0,3,"nvim_list_chans",[]]
model: FVim connected clients: [("9bee470c-a234-4e84-ac3d-542b53335d47", 1)]
model: FVim client channel is: 1
neovim.process: call: 4 -> [0,4,"nvim_command",["let g:clipboard = {  'name': 'FVimClipboard',  'copy': {     '+': {lines, regtype -> rpcrequest(1, 'set-clipboard', lines, regtype)},     '*': {lines, regtype -> rpcrequest(1, 'set-clipboard', lines, regtype)},   },  'paste': {     '+': {-> rpcrequest(1, 'get-clipboard')},     '*': {-> rpcrequest(1, 'get-clipboard')},  },}"]]
neovim.process: call: 5 -> [0,5,"nvim_set_var",["fvim_channel",1]]
neovim.process: call: 6 -> [0,6,"nvim_command",["command! -nargs=0 FVimDetach call rpcnotify(1, 'remote.detach')"]]
neovim.process: call: 7 -> [0,7,"nvim_command",["command! -nargs=0 FVimToggleFullScreen call rpcnotify(1, 'ToggleFullScreen', 1)"]]
neovim.process: call: 8 -> [0,8,"nvim_command",["command! -nargs=1 -complete=expression FVimCursorSmoothMove call rpcnotify(1, 'cursor.smoothmove', <args>)"]]
neovim.process: call: 9 -> [0,9,"nvim_command",["command! -nargs=1 -complete=expression FVimCursorSmoothBlink call rpcnotify(1, 'cursor.smoothblink', <args>)"]]
neovim.process: call: 10 -> [0,10,"nvim_command",["command! -nargs=1 -complete=expression FVimFontLineHeight call rpcnotify(1, 'font.lineheight', <args>)"]]
neovim.process: call: 11 -> [0,11,"nvim_command",["command! -nargs=1 -complete=expression FVimFontAutoSnap call rpcnotify(1, 'font.autosnap', <args>)"]]
neovim.process: call: 12 -> [0,12,"nvim_command",["command! -nargs=1 -complete=expression FVimFontAntialias call rpcnotify(1, 'font.antialias', <args>)"]]
neovim.process: call: 13 -> [0,13,"nvim_command",["command! -nargs=1 -complete=expression FVimFontLigature call rpcnotify(1, 'font.ligature', <args>)"]]
neovim.process: call: 14 -> [0,14,"nvim_command",["command! -nargs=1 -complete=expression FVimFontDrawBounds call rpcnotify(1, 'font.drawBounds', <args>)"]]
neovim.process: call: 15 -> [0,15,"nvim_command",["command! -nargs=1 -complete=expression FVimFontAutohint call rpcnotify(1, 'font.autohint', <args>)"]]
neovim.process: call: 16 -> [0,16,"nvim_command",["command! -nargs=1 -complete=expression FVimFontSubpixel call rpcnotify(1, 'font.subpixel', <args>)"]]
neovim.process: call: 17 -> [0,17,"nvim_command",["command! -nargs=1 -complete=expression FVimFontLcdRender call rpcnotify(1, 'font.lcdrender', <args>)"]]
neovim.process: call: 18 -> [0,18,"nvim_command",["command! -nargs=1 -complete=expression FVimFontHintLevel call rpcnotify(1, 'font.hindLevel', <args>)"]]
neovim.process: call: 19 -> [0,19,"nvim_command",["command! -nargs=1 -complete=expression FVimFontNormalWeight call rpcnotify(1, 'font.weight.normal', <args>)"]]
neovim.process: call: 20 -> [0,20,"nvim_command",["command! -nargs=1 -complete=expression FVimFontBoldWeight call rpcnotify(1, 'font.weight.bold', <args>)"]]
neovim.process: call: 21 -> [0,21,"nvim_command",["command! -nargs=1 -complete=expression FVimFontNoBuiltinSymbols call rpcnotify(1, 'font.nonerd', <args>)"]]
neovim.process: call: 22 -> [0,22,"nvim_command",["command! -nargs=1 -complete=expression FVimKeyDisableShiftSpace call rpcnotify(1, 'key.disableShiftSpace', <args>)"]]
neovim.process: call: 23 -> [0,23,"nvim_command",["command! -nargs=1 -complete=expression FVimUIMultiGrid call rpcnotify(1, 'ui.multigrid', <args>)"]]
neovim.process: call: 24 -> [0,24,"nvim_command",["command! -nargs=1 -complete=expression FVimUIPopupMenu call rpcnotify(1, 'ui.popupmenu', <args>)"]]
neovim.process: call: 25 -> [0,25,"nvim_command",["command! -nargs=1 -complete=expression FVimUITabLine call rpcnotify(1, 'ui.tabline', <args>)"]]
neovim.process: call: 26 -> [0,26,"nvim_command",["command! -nargs=1 -complete=expression FVimUICmdLine call rpcnotify(1, 'ui.cmdline', <args>)"]]
neovim.process: call: 27 -> [0,27,"nvim_command",["command! -nargs=1 -complete=expression FVimUIWildMenu call rpcnotify(1, 'ui.wildmenu', <args>)"]]
neovim.process: call: 28 -> [0,28,"nvim_command",["command! -nargs=1 -complete=expression FVimUIMessages call rpcnotify(1, 'ui.messages', <args>)"]]
neovim.process: call: 29 -> [0,29,"nvim_command",["command! -nargs=1 -complete=expression FVimUITermColors call rpcnotify(1, 'ui.termcolors', <args>)"]]
neovim.process: call: 30 -> [0,30,"nvim_command",["command! -nargs=1 -complete=expression FVimUIHlState call rpcnotify(1, 'ui.hlstate', <args>)"]]
neovim.process: call: 31 -> [0,31,"nvim_command",["command! -nargs=1 -complete=expression FVimDrawFPS call rpcnotify(1, 'DrawFPS', <args>)"]]
neovim.process: call: 32 -> [0,32,"nvim_command",["command! -nargs=1 -complete=expression FVimCustomTitleBar call rpcnotify(1, 'CustomTitleBar', <args>)"]]
neovim.process: call: 33 -> [0,33,"nvim_command",["command! -nargs=1 -complete=expression FVimBackgroundOpacity call rpcnotify(1, 'background.opacity', <args>)"]]
neovim.process: call: 34 -> [0,34,"nvim_command",["command! -nargs=1 -complete=expression FVimBackgroundComposition call rpcnotify(1, 'background.composition', <args>)"]]
neovim.process: call: 35 -> [0,35,"nvim_command",["command! -nargs=1 -complete=expression FVimBackgroundAltOpacity call rpcnotify(1, 'background.altopacity', <args>)"]]
neovim.process: call: 36 -> [0,36,"nvim_command",["command! -nargs=1 -complete=expression FVimBackgroundImage call rpcnotify(1, 'background.image.file', <args>)"]]
neovim.process: call: 37 -> [0,37,"nvim_command",["command! -nargs=1 -complete=expression FVimBackgroundImageOpacity call rpcnotify(1, 'background.image.opacity', <args>)"]]
neovim.process: call: 38 -> [0,38,"nvim_command",["command! -nargs=1 -complete=expression FVimBackgroundImageStretch call rpcnotify(1, 'background.image.stretch', <args>)"]]
neovim.process: call: 39 -> [0,39,"nvim_command",["command! -nargs=1 -complete=expression FVimBackgroundImageHAlign call rpcnotify(1, 'background.image.halign', <args>)"]]
neovim.process: call: 40 -> [0,40,"nvim_command",["command! -nargs=1 -complete=expression FVimBackgroundImageVAlign call rpcnotify(1, 'background.image.valign', <args>)"]]
neovim.process: call: 41 -> [0,41,"nvim_command",["autocmd VimEnter * runtime! ginit.vim"]]
Unhandled exception. System.TypeInitializationException: The type initializer for '<StartupCode$FVim>.$FVim.theme' threw an exception.
 ---> System.TypeInitializationException: The type initializer for '<StartupCode$FVim>.$FVim.ui' threw an exception.
 ---> System.DllNotFoundException: Unable to load shared library 'fvim-ext' or one of its dependencies. In order to help diagnose loading problems, consider setting the DYLD_PRINT_LIBRARIES environment variable: dlopen(libfvim-ext, 1): image not found
   at FVim.ui.osx.vh_init()
   at <StartupCode$FVim>.$FVim.ui..cctor() in /Users/tae/Projects/fvim/ui.fs:line 401
   --- End of inner exception stack trace ---
   at FVim.ui.get_DefaultFont()
   at <StartupCode$FVim>.$FVim.theme..cctor() in /Users/tae/Projects/fvim/theme.fs:line 17
   --- End of inner exception stack trace ---
   at FVim.theme.get_themeconfig_ev()
   at FVim.ThemableViewModelBase..ctor(FSharpOption`1 x, FSharpOption`1 y, FSharpOption`1 w, FSharpOption`1 h) in /Users/tae/Projects/fvim/ViewModels/ThemableViewModelBase.fs:line 24
   at FVim.MainWindowViewModel..ctor(FSharpOption`1 cfg, FSharpOption`1 _maingrid) in /Users/tae/Projects/fvim/ViewModels/MainWindowViewModel.fs:line 22
   at FVim.Program.Main(String[] args) in /Users/tae/Projects/fvim/Program.fs:line 113

Any ideas?

yatli commented 4 years ago

Try copy lib/libfvim-ext.dylib to bin/Debug/netcoreapp3.1?

tssm commented 4 years ago

Hey, thanks! That did the trick. Shouldn't that step be automatic? Anyway, I'll try to see if I can fix some macOS stuff

yatli commented 4 years ago

The build script copies the lib directly to the deployment directory so the build dir is skipped.. Glad it works for you now :)

Ping me for any questions. I don't have access to a real mac at the moment, so it'd be awesome if you can sort it out!

tssm commented 4 years ago

Thanks for all your help. I want to start with simple stuff because I don't have any F# experience, so I want to fix the shell: I see that Bash is hardcoded in lib/fvim-osx-launcher, but that is not the default anymore (they switched to ZSH on Catalina) and anyway a lot of us uses Fish, so I would like FVim to pick the default shell from the environment. I changed some stuff on the script, but no matter what, they are not being picked up. I guess it's because dotnet run doesn't rely on that script at all: the only reference to that file I see is in the pack.sh file. Is there a way to try changes to lib/fvim-osx-launcher without packaging the app?

yatli commented 4 years ago

they switched to ZSH on Catalina

Really! No wonder the script would fail on newer systems.

Yeah, dotnet run doesn't call the script file. Only a packaged app folder use it.

yatli commented 4 years ago

btw, the way the launcher is activated is in lib/Info.plist. My preliminary research on this is based on this document: https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Introduction/Introduction.html and another neovim frontend app for mac (I don't remember clearly now... sorry)

tssm commented 4 years ago

Bash is still available (too many scripts to replace), so it doesn't fail. It is just annoying that your default shell is not being picked up.

Thanks for the link, I'll start there. Grepping trough the project only shows that Bash is hardcoded on getopt.fs, azure-pipelines.yaml, pack.sh, and Info.plist, but none of them have anything to do with how :terminal behaves 🤔 That's why I think fvim-osx-launcher is the culprit

yatli commented 4 years ago

There is a binary executable generated by dotnet publish in the app dir "FVim". Initially I thought that pointing to it in the plist is enough, but in my setting at that time, it was picking up an ancient bash (v3.x) instead of brew-installed new bash. That's why I set up the launcher script in the hope to load up the proper environment for the user.

yatli commented 4 years ago

In the launcher: export SHELL=$new_bash

That controls the :terminal behavior.

yatli commented 4 years ago

So if you can work out a way to decide what's the best value for SHELL, please do it :)

yatli commented 4 years ago

logger output can be viewed in the Console.app

tssm commented 4 years ago

Last question regarding this, and then I think I can keep going alone: Any idea why dotnet run picks Bash as default shel if it doesn't rely on the fvim-osx-launcher script?

yatli commented 4 years ago

It should inherit SHELL from the environment. Echo that to verify.

See also: https://github.com/neovim/neovim/issues/2292

tssm commented 4 years ago

Funny: The error was that I ran dotnet run in a terminal inside the latest release of FVim, with has Bash hardcoded 😅

I confirmed that without fvim-osx-launcher FVim correctly picks the right shell as long as it was changed with chsh and its full path was added as an entry to /etc/shells. This may explain why it wasn't picking a new version of installed with Homebrew.

I want to send a PR, but I'm having problems getting the bundle to work :( I'll do it as soon as I can

yatli commented 4 years ago

That was meta :D