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

Builds from master don’t work on MacOS (Apple Silicon) #411

Closed
halostatue opened this issue Sep 30, 2021 · 5 comments
Closed

Builds from master don’t work on MacOS (Apple Silicon) #411

halostatue opened this issue Sep 30, 2021 · 5 comments
Labels
bug Something isn't working

Comments

@halostatue
Copy link

halostatue commented Sep 30, 2021

I’m trying to build master so that I can have a native arm64 build, and it’s not working. My current Neovim version is from Homebrew (NVIM v0.5.1, Build type: Release, LuaJIT 2.1.0-beta3). My default node.js is also the Homebrew node.js, currently at v16.10.0.

nom i produces a diff in package-lock.json:

diff --git i/package-lock.json w/package-lock.json
index bf1214ee2011..6c80d17b466c 100644
--- i/package-lock.json
+++ w/package-lock.json
@@ -5,6 +5,7 @@
   "requires": true,
   "packages": {
     "": {
+      "name": "uivonim",
       "version": "0.28.0",
       "license": "AGPL-3.0-only",
       "dependencies": {

npm run package works and produces a .app and .dmg file. There’s one error for which I added stats: { errorDetails: true } and see

Critical dependency: the request of a dependency is an expression
    at CommonJsRequireContextDependency.getWarnings (/Users/austin/mess/2021/39/uivonim/node_modules/webpack/lib/dependencies/ContextDependency.js:82:18)
    at Compilation.reportDependencyErrorsAndWarnings (/Users/austin/mess/2021/39/uivonim/node_modules/webpack/lib/Compilation.js:2685:24)
    at /Users/austin/mess/2021/39/uivonim/node_modules/webpack/lib/Compilation.js:2293:28
    at _next2 (eval at create (/Users/austin/mess/2021/39/uivonim/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:25:1)
    at eval (eval at create (/Users/austin/mess/2021/39/uivonim/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:52:1)
    at /Users/austin/mess/2021/39/uivonim/node_modules/webpack/lib/FlagDependencyExportsPlugin.js:403:11
    at /Users/austin/mess/2021/39/uivonim/node_modules/neo-async/async.js:2830:7
    at Object.each (/Users/austin/mess/2021/39/uivonim/node_modules/neo-async/async.js:2850:39)
    at /Users/austin/mess/2021/39/uivonim/node_modules/webpack/lib/FlagDependencyExportsPlugin.js:368:18
    at /Users/austin/mess/2021/39/uivonim/node_modules/neo-async/async.js:2830:7
 @ ./src/renderer/index.ts 9:13-39

When I run uivonim (open dist/mac-arm64/uivonim.app), I get the following result:

First run

The message is that app/runtime/uivonim.vim cannot be loaded; the file is in Contents/Resources/app/build/runtime/uivonim.vim.

Uncaught Exception:
Error: Error making request to nvim_get_hl_by_name
at NeovimClient.request (/Users/austin/mess/2021/39/uivonim/dist/mac-arm64/uivonim.app/Contents/Resources/app/node_modules/neovim/lib/api/Base.js:75:23)
at NeovimClient.getHighlightByName (/Users/austin/mess/2021/39/uivonim/dist/mac-arm64/uivonim.app/Contents/Resources/app/node_modules/neovim/lib/api/Neovim.js:261:21)
at /Users/austin/mess/2021/39/uivonim/dist/mac-arm64/uivonim.app/Contents/Resources/app/build/main/workers/instance.js:53:77
at MessagePort.<anonymous> (/Users/austin/mess/2021/39/uivonim/dist/mac-arm64/uivonim.app/Contents/Resources/app/build/main/workers/messaging/worker-client.js:49:24)
at MessagePort.[nodejs.internal.kHybridDispatch] (internal/event_target.js:398:41)
at MessagePort.exports.emitMessage (internal/per_context/messageport.js:18:26)

If I make the following modification:

diff --git i/src/main/core/master-control.ts w/src/main/core/master-control.ts
index ad01947b9344..3909440d87c2 100644
--- i/src/main/core/master-control.ts
+++ w/src/main/core/master-control.ts
@@ -39,7 +39,7 @@ const spawnNvimInstance = (
   useWsl: boolean,
   nvimBinary?: string
 ) => {
-  const runtimeDir = resolve(__dirname, '..', '..', '..', 'runtime')
+  const runtimeDir = resolve(__dirname, '..', '..', 'runtime')
   const args = [
     '--cmd',
     `let $PATH .= ':${runtimeDir}/${process.platform}' | let &runtimepath .= ',${runtimeDir}'`,

This is what shows up:

after fix

So there’s a problem with the build that’s easily fixed.

What I can’t figure out is how to stop the developer panel from opening. Suggestions?

smolck added a commit that referenced this issue Sep 30, 2021
smolck added a commit that referenced this issue Sep 30, 2021
@smolck
Copy link
Owner

smolck commented Sep 30, 2021

Should be fixed on master, mind giving it a test to confirm on your system?

@smolck smolck added the bug Something isn't working label Sep 30, 2021
@halostatue
Copy link
Author

It works. I also looked at the code changes and what I can’t tell is whether the process.env in 0f055ce is set at packaging time or at runtime (if at packaging time then NODE_ENV=production npm run package should have the same effect, right?).

I’m not sure if you’ve given any thought to a command-line launcher, but simply running the inner uivonim binary doesn’t do what would be expected, and the code helper for viscose doesn’t seem to be useful in terms of figuring out how to make it work.

dist/mac-arm64/uivonim.app/Contents/MacOS/uivonim package.json
(node:69474) electron: The default of nativeWindowOpen is deprecated and will be changing from false to true in Electron 15.  See https://github.com/electron/electron/issues/28511 for more information.
(Use `uivonim --trace-warnings ...` to show where the warning was created)
No argument passed to --nvim, using default `nvim`
[winston] Attempt to write logs with no transports {"message":"request -> neovim.api.nvim_ui_attach","level":"debug"}
[winston] Attempt to write logs with no transports {"message":"request -> neovim.api.nvim_command","level":"debug"}
[winston] Attempt to write logs with no transports {"message":"request -> neovim.api.nvim_command","level":"debug"}
[winston] Attempt to write logs with no transports {"message":"request -> neovim.api.nvim_ui_try_resize","level":"debug"}
[winston] Attempt to write logs with no transports {"message":"request -> neovim.api.nvim_ui_try_resize","level":"debug"}
[winston] Attempt to write logs with no transports {"message":"request -> neovim.api.nvim_ui_try_resize","level":"debug"}
[winston] Attempt to write logs with no transports {"message":"response -> neovim.api.nvim_ui_attach: null","level":"debug"}
[winston] Attempt to write logs with no transports {"message":"request -> neovim.api.nvim_command","level":"debug"}
[winston] Attempt to write logs with no transports {"message":"request -> neovim.api.nvim_subscribe","level":"debug"}
[winston] Attempt to write logs with no transports {"message":"request -> neovim.api.nvim_subscribe","level":"debug"}
[winston] Attempt to write logs with no transports {"message":"request -> neovim.api.nvim_subscribe","level":"debug"}
[winston] Attempt to write logs with no transports {"message":"request -> neovim.api.nvim_subscribe","level":"debug"}
[winston] Attempt to write logs with no transports {"message":"request -> neovim.api.nvim_subscribe","level":"debug"}
[winston] Attempt to write logs with no transports {"message":"request -> neovim.api.nvim_subscribe","level":"debug"}
[winston] Attempt to write logs with no transports {"message":"request -> neovim.api.nvim_subscribe","level":"debug"}
[winston] Attempt to write logs with no transports {"message":"request -> neovim.api.nvim_call_function","level":"debug"}
[winston] Attempt to write logs with no transports {"message":"request -> neovim.api.nvim_command","level":"debug"}
[winston] Attempt to write logs with no transports {"message":"request -> neovim.api.nvim_command","level":"debug"}
[winston] Attempt to write logs with no transports {"message":"request -> neovim.api.nvim_command","level":"debug"}
[winston] Attempt to write logs with no transports {"message":"request -> neovim.api.nvim_command","level":"debug"}
[winston] Attempt to write logs with no transports {"message":"request -> neovim.api.nvim_command","level":"debug"}
[winston] Attempt to write logs with no transports {"message":"request -> neovim.api.nvim_command","level":"debug"}
[winston] Attempt to write logs with no transports {"message":"request -> neovim.api.nvim_command","level":"debug"}
[winston] Attempt to write logs with no transports {"level":"info","message":"handleNotification: "}
[winston] Attempt to write logs with no transports {"level":"info","message":"handleNotification: "}
[winston] Attempt to write logs with no transports {"message":"response -> neovim.api.nvim_command: null","level":"debug"}
[winston] Attempt to write logs with no transports {"message":"response -> neovim.api.nvim_command: null","level":"debug"}
[winston] Attempt to write logs with no transports {"level":"info","message":"handleNotification: "}
[winston] Attempt to write logs with no transports {"message":"response -> neovim.api.nvim_ui_try_resize: null","level":"debug"}
[winston] Attempt to write logs with no transports {"level":"info","message":"handleNotification: "}
[winston] Attempt to write logs with no transports {"level":"info","message":"handleNotification: "}
[winston] Attempt to write logs with no transports {"message":"response -> neovim.api.nvim_ui_try_resize: null","level":"debug"}
Error running nvimCommand instance.ts: 'Error: nvim_command: Vim(call):E117: Unknown function: UivonimCreateHighlights'

I want to make an alias that launches uivonim instead of MacVim when I type gvim; I could do it as something that calls open -a uivonim "${@}", but that feels unnecessarily platform-specific.

I’ll open a separate ticket for that if I find something that will help with this. Thanks for the quick fixes!

@smolck
Copy link
Owner

smolck commented Sep 30, 2021

It works. I also looked at the code changes and what I can’t tell is whether the process.env in 0f055ce is set at packaging time or at runtime (if at packaging time then NODE_ENV=production npm run package should have the same effect, right?).

My understanding is that it's set at runtime, although I could be wrong, haven't tested it.

I’m not sure if you’ve given any thought to a command-line launcher, but simply running the inner uivonim binary doesn’t do what would be expected, and the code helper for viscose doesn’t seem to be useful in terms of figuring out how to make it work.

What's unexpected? Those logs are actually all normal; I guess I could silence them for production though.

I’ll open a separate ticket for that if I find something that will help with this. Thanks for the quick fixes!

No problem, and thank you for opening the issue! Definitely feel free to let me know/open an issue if you run into anything else.

@smolck smolck closed this as completed Sep 30, 2021
@halostatue
Copy link
Author

Re: NODE_ENV, I am sort of surprised that the prod webpack build doesn’t substitute process.env.NODE_ENV for 'production' so that tests like 'production' === 'production' become true tests.

The unexpected event was that package.json wasn’t opened by uivonim.app/Contents/MacOS/uivonim package.json. Sorry that I forgot to put that detail in. The logging should be suppressed when running from the command-line in production, or hooked up to something that logs to the macOS console.

Ultimately I’m looking for something like what Oni2 provides (https://onivim.github.io/docs/using-onivim/command-line#macos) or what VSCode provides with its code binary. It’s a script that would have to be packaged in, but I’m trying to figure out the right way to get things working. I’ll open a ticket when I figure more out, but it’ll be a few days.

@halostatue
Copy link
Author

Hate to raise this further, but things seem to not be great with the packaged .app.

  1. ran npm run package
  2. opened the dmg for arm64 (dist/uivonim-0.28.0-arm64.dmg)
  3. dragged uivonim.app to /Applications
  4. opened uivonim via Alfred or the finder in /Applications

I get the following JS error:

CleanShot 2021-09-30 at 18 27 37@2x

and the ui doesn’t start properly:

CleanShot 2021-09-30 at 18 26 46@2x

I suspect that this is related to the fact the nvim is installed in /opt/homebrew/bin/ (the default location for arm64 Homebrew installations) and not in /usr/local/bin (the default location for x86-64 Homebrew installations). The former is not in the system-defined $PATH, but is in my shell’s $PATH (which would explain why opening it from the command-line works).

To test this, I created a symlink from /opt/homebrew/bin/nvim to /usr/local/bin/nvim and things worked. On the other hand, I then got this pair of messages from my plugins:

CleanShot 2021-09-30 at 18 34 13@2x

I think that the right thing to do here would be to modify process.env.PATH to include /opt/homebrew/bin if the architecture is arm64, the OS is Darwin, and the path already exists. This won’t help anyone not using Homebrew (e.g., Macports users and Nix users won’t get any benefit from this), but it would fix the 90% case, and it might be possible to later figure out more generally applicable heuristics (e.g., finding local-path installed homebrew, which I ran for years).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants