Closed HugoFara closed 5 months ago
Hmmm, it seems I never tried MeCab with a Mac as I don't own one. I may ask you a small contribution @quopquai :smile:
First, did you install MeCab? It is not shipped with LWT and needs to be installed separately.
Second, can you open a terminal and tell me if this command works command -v mecab
please? If so, I may add a support for MeCab Mac...
...a contribution, sure, that sounds reasonable...!
I have no idea if I installed it or not!? I might have!?
...when I type the command, nothing seems to happen...
Okay, so MeCab is not installed. You need to install it first, and the previous command returns the location of the binary. Unfortunately I cannot recommend you a good tutorial as I don't have a Mac, but I already read that you can install it with homebrew.
Once that's done, we can work one an integration of MeCab for Mac!
...ok I think I've done it...
Nice! Let's perform some live surgery on LWT!
Can you go to line 250 of kernel_utility.php
(/Applications/MAMP/htdocs/lwt-2.8.1/inc/kernel_utility.php(268)
), and do the following substitution?
From
if ($os == 'LIN') {
to
if ($os == 'LIN' || $os == 'DAR') {
If MeCab works with that, I'm adding the feature!
EDIT: just to explain a bit $os
is you OS name ("LIN" for Linux, "DAR" for Darwin (Mac)...), so here we tell LWT to behave the same with Linux and Mac (||
means "or").
...I changed it...and saved...
lwt is giving me this now:
Fatal Error: MeCab not detected! Please install it and add it to your PATH.
Backtrace:
I think you installed MeCab on your computer, but MAMP cannot access its path and cannot find it. I'm not sure about how to solve it :thinking:
I'm looking online...
Please install it and add it to your PATH.
By the way, did you do that?
...no, how do you do that?
I'm copy/pasting from https://apple.stackexchange.com/questions/41542/adding-a-new-executable-to-the-path-environment-variable
In your case, you can add usr/local/bin/mecab
, then reload the server. I hope that will work :no_mouth:
I'm sorry for the delay:
Macintosh:~ julisco$ usr/local/bin/mecab -bash: usr/local/bin/mecab: No such file or directory Macintosh:~ julisco$
I have no idea what is going on?!
I cannot be sure... I think the best solution for now is to try having a working instance of MeCab, then run LWT, and if it doesn't work you may need to configure MAMP to use the good path (I'm really not sure how MAMP works)...
I found this in my terminal when installing MeCab:
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
does it mean anything?
I have no idea what that is, sorry :disappointed:
https://github.com/jzohrab/lute/wiki/Mecab-and-Apache
MAMP (Mac users) Run the following in terminal to adjust the MAMP Apache server PATH:
printf 'export PATH="/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"' >> /Applications/MAMP/Library/bin/envvars
...finally jz from LUTE gave me the solution. ...now everything seems to work fine on Mac.
Thanks again HugoFara!!! :)
@HugoFara
printf 'export PATH="/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"' >> /Applications/MAMP/Library/bin/envvars
Add this in docs and close issue.
when I open a text now, it shows the following...
Fatal Error: Your OS 'DAR' cannot use MeCab with this version of LWT!
Backtrace:
0 /Applications/MAMP/htdocs/lwt-2.8.1/inc/kernel_utility.php(268): my_die('Your OS 'DAR' c...')
1 /Applications/MAMP/htdocs/lwt-2.8.1/inc/session_utility.php(4498): get_mecab_path(' -O yomi ')
2 /Applications/MAMP/htdocs/lwt-2.8.1/do_text_header.php(186): phonetic_reading('\xE8\x8C\xA8\xE5\x9F\x8E\xE7\x9C\x8C\xE3\x81\xAE\xE7\xB4\x8D...', 'ja')
3 /Applications/MAMP/htdocs/lwt-2.8.1/do_text_header.php(313): browser_tts('\xE8\x8C\xA8\xE5\x9F\x8E\xE7\x9C\x8C\xE3\x81\xAE\xE7\xB4\x8D...', 'Japanese')
4 /Applications/MAMP/htdocs/lwt-2.8.1/do_text.php(96): do_text_header_content(3, true)
5 /Applications/MAMP/htdocs/lwt-2.8.1/do_text.php(144): do_text_desktop_content(3)
6 /Applications/MAMP/htdocs/lwt-2.8.1/do_text.php(150): do_text_page(3)
Originally posted by @quopquai in https://github.com/HugoFara/lwt/issues/134#issuecomment-1624704329
@quopquai is using a Mac M2.