Skip to content

OS 'DAR' not found for MeCab #135

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

Closed
HugoFara opened this issue Jul 7, 2023 · 16 comments
Closed

OS 'DAR' not found for MeCab #135

HugoFara opened this issue Jul 7, 2023 · 16 comments
Labels
enhancement Develop an existing feature

Comments

@HugoFara
Copy link
Owner

HugoFara commented Jul 7, 2023

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 #134 (comment)

@quopquai is using a Mac M2.

@HugoFara HugoFara added the bug Something isn't working label Jul 7, 2023
@HugoFara
Copy link
Owner Author

HugoFara commented Jul 7, 2023

Hmmm, it seems I never tried MeCab with a Mac as I don't own one. I may ask you a small contribution @quopquai 😄

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...

@HugoFara HugoFara added enhancement Develop an existing feature and removed bug Something isn't working labels Jul 7, 2023
@quopquai
Copy link

quopquai commented Jul 7, 2023

...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...

Screenshot 2023-07-07 at 13 41 38

@HugoFara
Copy link
Owner Author

HugoFara commented Jul 7, 2023

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!

@quopquai
Copy link

quopquai commented Jul 7, 2023

...ok I think I've done it...

Screenshot 2023-07-07 at 13 57 52

@HugoFara
Copy link
Owner Author

HugoFara commented Jul 7, 2023

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").

@quopquai
Copy link

quopquai commented Jul 7, 2023

...I changed it...and saved...

Screenshot 2023-07-07 at 14 12 34

lwt is giving me this now:

Fatal Error: MeCab not detected! Please install it and add it to your PATH.

Backtrace:

#0 /Applications/MAMP/htdocs/lwt-2.8.1/inc/kernel_utility.php(254): my_die('MeCab not detec...')
#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('[7\xE6\x9C\x884\xE6\x97\xA5 16\xE6\x99\x82...', 'ja')
#3 /Applications/MAMP/htdocs/lwt-2.8.1/do_text_header.php(313): browser_tts('[7\xE6\x9C\x884\xE6\x97\xA5 16\xE6\x99\x82...', 'Japanese')
#4 /Applications/MAMP/htdocs/lwt-2.8.1/do_text.php(96): do_text_header_content(1, true)
#5 /Applications/MAMP/htdocs/lwt-2.8.1/do_text.php(144): do_text_desktop_content(1)
#6 /Applications/MAMP/htdocs/lwt-2.8.1/do_text.php(150): do_text_page(1)

@HugoFara
Copy link
Owner Author

HugoFara commented Jul 7, 2023

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 🤔

I'm looking online...

@HugoFara
Copy link
Owner Author

HugoFara commented Jul 7, 2023

Please install it and add it to your PATH.

By the way, did you do that?

@quopquai
Copy link

quopquai commented Jul 7, 2023

...no, how do you do that?

@HugoFara
Copy link
Owner Author

HugoFara commented Jul 7, 2023

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 😶

@quopquai
Copy link

quopquai commented Jul 7, 2023

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?!

@HugoFara
Copy link
Owner Author

HugoFara commented Jul 7, 2023

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)...

@quopquai
Copy link

quopquai commented Jul 7, 2023

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?

@HugoFara
Copy link
Owner Author

HugoFara commented Jul 7, 2023

I have no idea what that is, sorry 😞

@quopquai
Copy link

quopquai commented Jul 9, 2023

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!!! :)

@ProgramComputer
Copy link

@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.

HugoFara added a commit that referenced this issue Jan 3, 2024
New databse migration strategy.
Fixes feeds (#168).
Adds missing documentation to Docker (#146, #160).
Changes in PHP and JS globals.
Fixes reading position was not set.
Read text through API (#153, #155).
Fixes word was not saved/deleted.
Fixes #170 and #69.
Updates API (#175).
Adds dependency to php-xml (#178, #181).
Updates makefile (#179).
Adds MeCab support on Mac (#135).
Adds the option to hide/show word romanization (#119).
Raises URL size limit to 2048 (#144).
@HugoFara HugoFara closed this as completed Apr 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Develop an existing feature
Projects
None yet
Development

No branches or pull requests

3 participants