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

fix: TSInstall issues on macOS, hopefully once and for good #891

Merged
merged 1 commit into from
May 24, 2023

Conversation

aldanor
Copy link
Contributor

@aldanor aldanor commented May 21, 2023

I've noticed #887 and figured maybe we can do a bit better.

Pointing people at installing external c++ compilers like gcc (especially via homebrew which they may not be using) in order to use neorg is not the most welcoming thing to put in a readme 🙂

(Also note that the "point CC at a compiler with C++11 support" part of the readme is not entirely incorrect, because native clang does have C++11 support; it's just not the default.)

Here's a solution that I've tested myself on two different macOS boxes, does not require any additional dependencies and should work with system-provided clang.

This did require digging a bit into treesitter installer internals (unfortunately) so it may potential break with future treesitter releases, however that part of TS didn't seem to have changed much at all, so it's not too likely.

@LangdalP
Copy link

I cannot comment on the quality of this fix, but I can add that I am one of the users that got slightly annoyed that I could not install the neorg parser with the built in Clang, which does have C++11 support. I actually started using nvim-orgmode because of it, however I must admit that neorg looks attractive. My point is that this fix is very welcome from the user perspective!

@vhyrro
Copy link
Member

vhyrro commented May 24, 2023

Ah, this is very nice! Thank you for taking the time to figure this out. I don't have any Mac machines to test for reference, so we'll see if the fix works for everyone once it propagates. If so, I can finally remove all the extra steps required to use Neorg on mac :D 💜

@vhyrro vhyrro changed the title Fix TSInstall issues on macOS, hopefully once and for good fix: TSInstall issues on macOS, hopefully once and for good May 24, 2023
@vhyrro vhyrro merged commit 4988a6f into nvim-neorg:main May 24, 2023
@aldanor aldanor deleted the feature/fix-ts-install-on-macos branch May 24, 2023 14:45
@mattpolzin
Copy link
Contributor

I can confirm this worked for me on an Intel Mac (shouldn't matter that it's Intel for this). The process still has caveats, but not nearly as severe of them!

  1. I use Plug and when I did :PlugUpdate, although I did get the new Neorg version I still saw the old failed compilation behavior when running :Neorg sync-parsers; I had to restart Neovim to see the fixed compilation behavior.
  2. :TSInstallSync norg still fails (naturally, since this fix is local to the Neorg command). Still worth noting, though.

normful added a commit to normful/neorg that referenced this pull request Jun 4, 2023
* upstream/main:
  feat(keybinds.lua): add descriptions to all keybinds
  chore: format with stylua
  feat(keybinds.lua): add `desc` fields to task keybinds (nvim-neorg#926)
  fix(core.summary): bugs + flexibility around incomplete metadata (nvim-neorg#927)
  docs(concealer): add comments for generators an formatters
  feat: add extra nesting level, make icons specific to non-anticonceal usage
  feat(concealer): add more icon generators
  feat(concealer): add numeric anticonceal if supported
  fix(concealer): record cursor upon init to fix first line conceal (nvim-neorg#924)
  feat: conceal the `{* }` parts of links
  fix(concealer): fix concealing in anchors, don't error on broken config (nvim-neorg#923)
  docs(todo_items): old keybinds in wiki
  docs: update `breaking-changes.norg`
  refactor!: remove the `core.news` module
  docs(README): make lazy.nvim install instructions more standard (nvim-neorg#905)
  refactor(docgen): remove unused variable
  fix(docgen): fix incorrect markdown indentation in wiki
  fix(docgen): don't fail on mixed-type tables (lists and dictionaries at the same time)
  fix(docgen): propagate docgen error exit code (nvim-neorg#917)
  refactor(promo): remove notify concealer (nvim-neorg#919)
  fix(concealer): do not listen vimleavepre (nvim-neorg#920)
  fix(concealer): minor fixes, plus wiki error fix (nvim-neorg#916)
  feat(concealer)!: rewrite for performance and stability (nvim-neorg#834)
  docs(wiki/Home.md): incorrect formatting in first paragraph
  refactor(core.highlights): don't halt execution when highlights cannot be applied
  fix(core.highlights): wrongly placed bracket
  fix(core.highlights): fix disappearing highlights when opening up norg files
  fix(highlights): attempt to reenable highlighting when none is found
  fix(todo_items): don't look at child if parent is todo (nvim-neorg#909)
  perf(core.promo): don't check `v.count`, use `v.count1` instead
  feat(promo): promote/demote prefix without following text (nvim-neorg#912)
  chore(highlights): add error message to assert for easier user debugging
  fix(highlights): assert on treesitter being enabled (nvim-neorg#914)
  feat(itero): don't start newline on empty line (nvim-neorg#911)
  refactor!(todo-items): since 5.0 do not warn about deprecated keybinds
  refactor!: since 5.0 do not longer warn about deprecated `core.norg.*` modules
  feat!: move to new/improved metadata parser, change highlight queries
  refactor(hop): add nicer error messages, format with stylua
  feat(esupports.hop): link jump to line + fixes + refactoring (nvim-neorg#903)
  refactor: remove `core.syntax` from the default module list
  chore(config.lua): update version variable
  chore(main): release 4.6.0 (nvim-neorg#900)
  feat(todo-items): add missing "need input" icon and action (nvim-neorg#896)
  fix(esupports): use structured api to avoid injection (nvim-neorg#899)
  fix(tempus): supply unprovided parameters from the current date when converting to `osdate` (supercedes nvim-neorg#897)
  chore(config.lua): update version variable
  chore(main): release 4.5.0 (nvim-neorg#883)
  fix: TSInstall issues on macOS, hopefully once and for good (nvim-neorg#891)
  docs(README): add treesitter fix for macos (nvim-neorg#887)
  feat: add colouring to TODO items
  docs: update ROADMAP.md
  fix(metagen): update generation to use user config for `updated` tag (nvim-neorg#882)
  chore(config.lua): update version variable
  chore(main): release 4.4.1 (nvim-neorg#880)
  docs(concealer): mention nerd font dependency for concealer (nvim-neorg#875)
  fix(tempus): properly handle conversions w.r.t Sun-Sat/Mon-Sun
  refactor: add `number_wrap()` function to `neorg.lib`
  fix(tempus): paste correct weekday from calendar
  chore(config.lua): update version variable
  chore(main): release 4.4.0
  fix(tempus): don't use the `re` module if it doesn't exist (nvim-neorg#872)
  feat(journal): allow `custom` to take in no arguments, in which case spawn a calendar
  fix(promo): don't add whitespace to empty lines (nvim-neorg#852)
  chore(config.lua): update version variable
  chore(main): release 4.3.0
  feat(calendar): add `t` command for "today"
  fix(hop): assume <current-day> when some parameters to dates are not supplied
  feat(hop): allow users to jump to timestamps
  fix(tempus): days like `4th`/`2nd` would not get parsed properly
  refactor(calendar): allow a target date to be supplied to the view
  chore(config.lua): update version variable
  chore(main): release 4.2.0
  fix: don't allow tempus to load unless the Neovim ver is at least 0.10.0
  feat(tempus): add insert mode `<M-d>` keybind to insert a date
  fix(tempus): do not assume `osdate` has all fields set
  feat(tempus): add `,id` (insert date) keybinding
  feat(tempus): allow dates to be converted to norg-compatible dates with `tostring()`
  chore(config.lua): update version variable
  chore(main): release 4.1.1
  fix: remove calendar as a dependency of `core.ui`, fix errors for people not on nightly
  chore(config.lua): update version variable
  chore(main): release 4.1.0
  refactor: remove `core.tempus` from `core.defaults`
  docs(tempus): add top documentation comment
  docs(calendar): add top documentation comment
  fix(calendar): allow the view to be written to on rerender
  feat(calendar): add `?` help page for custom input
  feat(calendar): implement basic `i` functionality
  feat(tempus): add `to_lua_date` function
  feat: add `core.tempus` module for date management
  feat(calendar): allow many simultaneous calendars
  fix(calendar): if another calendar is open then close it instead of erroring
  feat(calendar): add basic help popup when `?` is invoked
  refactor(core.ui): do not autoclose splits made via `create_split`
  fix(calendar): prevent the buffer from being modifiable after it has been filled
  fix(calendar): fix incorrect movement with `H` across boundaries of months with different lengths
  feat(calendar): add `$` and `0`/`_` navigation keybinds
  feat(calendar): add `m`/`M`, `L`/`H` and `y`/`Y` keybinds for the monthly view
  ref(calendar): implemented distance (monthly view) and run make format (nvim-neorg#858)
  ref(calendar): refactored view outside of calendar module (nvim-neorg#815)
  Fixed style with stylua
  Added standalone mode
  Fixed style with stylua
  Converted calendar into its own module
  Select range highlight hook is now more concise
  Mode integration (WIP)
  fix(calendar): properly display "today's day" in the calendar view
  chore: format with stylua, fix LLS warnings
  ref(calendar): refactored extmark creation, fixed single month view and added month limit (nvim-neorg#796)
  ref(calendar): extract rendering logic, add and improve keybinds (nvim-neorg#790)
  ref(calendar): extract logic, fix bug with time reformatting (nvim-neorg#788)
  fix(calendar): overlapping month names in the calendar view
  chore(calendar): initial setup for the screen update functionality
  ref: use numbers instead of strings for internal date structures
  feat: correctly handle year boundaries
  feat: add left-right cursor movement
  feat: place cursor over current day when creating calendar
  fix(calendar): make distance between each month uniform and support modifying the distance between each month
  feat(calendar): render as many months as is possible on screen
  feat(calendar): generalize functions even further, allow for offsets
  fix(calendar): fix rest of highlight groups
  fix(calendar): make month rendering work again
  fix(calendar): reversed namespace names
  fix(core.ui.calendar): wrong extmark being queried in month render routine
  feat: implement `render_month` function
  ref(core.ui.calendar): extract even more logic to `module.private`
  ref(core.ui.calendar): continue small refactors
  fix(core.ui.calendar): logic error when parsing virt_text length for `set_logical_extmark`
  ref(core.calendar.ui): begin code refactor (make the codebase ready for calendar logic)
  ref(core.ui.calendar): put rendered month extmark in decorational namespace
  feat(core.ui.calendar): highlight the current day differently
  ref(core.ui.calendar): move decorational namespace out of the `do .. end` block
  feat(core.ui.calendar): add day of the month rendering
  feat(core.ui.calendar): make the calendar display full month names
  feat(core.ui.calendar): implement more of the barebones UI
  feat(core.ui): let `create_split` take in a `height` variable
  feat(core.ui.calendar): add static calendar ui
  feat: add skeleton for the calendar UI element
@ddbrierton
Copy link

:Neorg sync-parsers does indeed work without error on macOS which is great. Thanks to all for the fix. However the fact that :TSInstallSync norg fails is kind of a problem, because every time there is a nvim-treesitter update (and there have been several in the last few days) it spews out error messages related to this, and any Mac user who is unfamiliar with the history of this problem is likely to think that something has become seriously broken with their neorg install.

@molleweide
Copy link

molleweide commented Jul 20, 2023

I am using MacOS 13 on macbook air M1:

Neorg sync-parsers yields:

Downloading tree-sitter-norg...
Creating temporary directory
Extracting tree-sitter-norg...
Compiling...
Could not load parser for norg: "...0.8.2/share/nvim/runtime/lua/vim/treesitter/language.lua:26: no parser for 'norg' language, see :help treesitter-parsers"
Unable to install norg parser.
[nvim-treesitter] [2/3, failed: 1] Downloading tree-sitter-norg_meta...
...
```.

@ddbrierton
Copy link

Could not load parser for norg: "...0.8.2/share/nvim/runtime/lua/vim/treesitter/language.lua:26: no parser for 'norg' language, see :help treesitter-parsers"

@molleweide have you tried upgrading neovim? You appear to be running 0.8.2. The latest release is 0.9.1.

@molleweide
Copy link

Could not load parser for norg: "...0.8.2/share/nvim/runtime/lua/vim/treesitter/language.lua:26: no parser for 'norg' language, see :help treesitter-parsers"

@molleweide have you tried upgrading neovim? You appear to be running 0.8.2. The latest release is 0.9.1.

yup i tried with 0.9.1 now and it sais the same.

@molleweide
Copy link

I am using MacOS 13 on macbook air M1:

Neorg sync-parsers yields:

Downloading tree-sitter-norg...
Creating temporary directory
Extracting tree-sitter-norg...
Compiling...
Could not load parser for norg: "...0.8.2/share/nvim/runtime/lua/vim/treesitter/language.lua:26: no parser for 'norg' language, see :help treesitter-parsers"
Unable to install norg parser.
[nvim-treesitter] [2/3, failed: 1] Downloading tree-sitter-norg_meta...
...
```.

I got Norg to build for myself now:

  1. I was using too old a nvim-treesitter version (probably the main issue)
  2. I had old packer package leftovers, (including old nvim-treesitter version) under XDG_DATA/nvim/site/packer/.. and nvim-treesitters function for obtaining the parser install dir for some reason returned this old packer install of nvim-treesitter.

Now, after cleaning up all those leftovers, running Neorg sync-parsers worked perfectly.

@0xFlo
Copy link

0xFlo commented Nov 30, 2023

I think it's important to pointing people at installing external c++ compilers like gcc in order to use neorg is very important to put in the readme. Currently it's very vague and difficult to debug for beginners and people probably care 0 if their mac uses clang or gcc for compiling.

Install GCC (which includes the G++ compiler) with the following command:
$ brew install gcc

Set the Environment Variables: Run the following commands in your terminal to set the CC and CXX environment variables to use GCC and G++ from Homebrew:

sh
Copy code
export CC=/opt/homebrew/bin/gcc-13
export CXX=/opt/homebrew/bin/g++-13
Add to Shell Configuration: To ensure these settings persist in future terminal sessions, add the above lines to your shell configuration file (typically ~/.zshrc or ~/.bash_profile for Zsh or Bash, respectively). You can do this by running:

sh
Copy code
echo 'export CC=/opt/homebrew/bin/gcc-13' >> ~/.zshrc
echo 'export CXX=/opt/homebrew/bin/g++-13' >> ~/.zshrc
If you're using Bash, replace ~/.zshrc with ~/.bash_profile.

Reload Shell Configuration: Apply the changes by sourcing your configuration file. For Zsh, use:

sh
Copy code
source ~/.zshrc
For Bash, use:

sh
Copy code
source ~/.bash_profile
Retry the Parser Installation: With the correct compiler set, retry installing the tree-sitter-norg parser in Neovim:

vim
Copy code
:TSInstallSync norg

@aldanor
Copy link
Contributor Author

aldanor commented Dec 1, 2023

I think it's important to pointing people at installing external c++ compilers like gcc in order to use neorg is very important to put in the readme. Currently it's very vague and difficult to debug for beginners and people probably care 0 if their mac uses clang or gcc for compiling.

@0xFlo Have you tried reading this PR's description? The whole point here was that you don't need to install any external compilers unless your environment is already messed up in some peculiar way. To repeat, you don't need gcc for it to work.

@0xFlo
Copy link

0xFlo commented Dec 1, 2023

ah sorry, I was still having issues with mac mini m2 and tried finding help on discord but it worked fine switching to gcc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants