hchunhui / librime-lua

Extending RIME with Lua scripts
BSD 3-Clause "New" or "Revised" License
309 stars 44 forks source link

How to add librime-lua plugin support. #25

Closed maojunxyz closed 4 years ago

maojunxyz commented 4 years ago

Error creating translator: 'lua_translator'

I have a problem when using lua script https://github.com/rime/librime/issues/332#issue-540037438

I did not compile and install from source, but directly installed binary packages.

Environment:

$ whereis librime
librime: /usr/lib/librime.so

Please help me how to add librime-lua support on the existing basis.

TKS.

hchunhui commented 4 years ago

You may need to remove librime package, and compile librime by yourself, since librime-lua support is not compiled in archlinux's package.

The following build instructions should work:

sudo pacman -S ....      # librime's dependencies
sudo pacman -S lua
git clone https://github.com/rime/librime.git
cd librime
./install-plugins.sh hchunhui/librime-lua
make merged-plugins
sudo make install
maojunxyz commented 4 years ago

failed.

I will try to package into pkg, then use pacman to install a local package.

uninstall librime

$ sudo pacman -Rdd librime

lua version:

$ lua -v
Lua 5.3.5  Copyright (C) 1994-2018 Lua.org, PUC-Rio

install librime & librime-lua plugins

git clone https://github.com/rime/librime.git
cd librime
./install-plugins.sh hchunhui/librime-lua
make merged-plugins
sudo make install

make install log

cmake --build build --target install
make[1]: Entering directory '/home/maojun/Documents/GitHub/librime/build'
make[2]: Entering directory '/home/maojun/Documents/GitHub/librime/build'
make[3]: Entering directory '/home/maojun/Documents/GitHub/librime/build'
make[3]: Leaving directory '/home/maojun/Documents/GitHub/librime/build'
[  5%] Built target rime-lua-objs
make[3]: Entering directory '/home/maojun/Documents/GitHub/librime/build'
make[3]: Leaving directory '/home/maojun/Documents/GitHub/librime/build'
[ 78%] Built target rime
make[3]: Entering directory '/home/maojun/Documents/GitHub/librime/build'
make[3]: Leaving directory '/home/maojun/Documents/GitHub/librime/build'
[ 79%] Built target rime_deployer
make[3]: Entering directory '/home/maojun/Documents/GitHub/librime/build'
make[3]: Leaving directory '/home/maojun/Documents/GitHub/librime/build'
[ 80%] Built target rime_patch
make[3]: Entering directory '/home/maojun/Documents/GitHub/librime/build'
make[3]: Leaving directory '/home/maojun/Documents/GitHub/librime/build'
[ 82%] Built target rime_dict_manager
make[3]: Entering directory '/home/maojun/Documents/GitHub/librime/build'
make[3]: Leaving directory '/home/maojun/Documents/GitHub/librime/build'
[ 84%] Built target rime_console
make[3]: Entering directory '/home/maojun/Documents/GitHub/librime/build'
make[3]: Leaving directory '/home/maojun/Documents/GitHub/librime/build'
[ 85%] Built target rime_api_console
make[3]: Entering directory '/home/maojun/Documents/GitHub/librime/build'
make[3]: Leaving directory '/home/maojun/Documents/GitHub/librime/build'
[100%] Built target rime_test
make[2]: Leaving directory '/home/maojun/Documents/GitHub/librime/build'
Install the project...
-- Install configuration: "Release"
-- Installing: /usr/lib/pkgconfig/rime.pc
-- Installing: /usr/share/cmake/rime/RimeConfig.cmake
-- Installing: /usr/include/rime_api.h
-- Installing: /usr/include/rime_levers_api.h
-- Installing: /usr/lib/librime.so.1.5.3
-- Up-to-date: /usr/lib/librime.so.1
-- Set runtime path of "/usr/lib/librime.so.1.5.3" to ""
-- Up-to-date: /usr/lib/librime.so
-- Installing: /usr/bin/rime_dict_manager
-- Set runtime path of "/usr/bin/rime_dict_manager" to ""
-- Installing: /usr/bin/rime_deployer
-- Set runtime path of "/usr/bin/rime_deployer" to ""
make[1]: Leaving directory '/home/maojun/Documents/GitHub/librime/build'

exec fcitx

$ (ERROR-30626 ime.c:440) fcitx-keyboard-in-tel-kagapa already exists
(ERROR-30626 ime.c:440) fcitx-keyboard-cm-mmuock already exists
=========================
FCITX 4.2.9.7 -- Get Signal No.: 11
Date: try "date -d @1576811752" if you are using GNU date ***
ProcessID: 30626
fcitx(+0x17ce)[0x559ce7f8f7ce]
/usr/lib/libc.so.6(+0x3bfb0)[0x7fd0aadc6fb0]
/usr/lib/libc.so.6(+0x1616f5)[0x7fd0aaeec6f5]
/usr/lib/librime.so.1(_ZN4rime12SetupLoggingEPKciS1_+0x2b)[0x7fd0a6b2e57b]
/usr/lib/fcitx/fcitx-rime.so(+0x243b)[0x7fd0a6ccf43b]
/usr/lib/fcitx/fcitx-rime.so(+0x24fb)[0x7fd0a6ccf4fb]
/usr/lib/libfcitx-core.so.0(+0x11490)[0x7fd0aafb2490]
/usr/lib/libfcitx-core.so.0(+0x144f9)[0x7fd0aafb54f9]
/usr/lib/libfcitx-core.so.0(+0x14707)[0x7fd0aafb5707]
/usr/lib/libfcitx-core.so.0(FcitxInstanceUpdateIMList+0x827)[0x7fd0aafb4947]
/usr/lib/libfcitx-core.so.0(+0x14165)[0x7fd0aafb5165]
/usr/lib/libfcitx-core.so.0(+0xa3cb)[0x7fd0aafab3cb]
/usr/lib/libfcitx-core.so.0(FcitxInstanceRun+0x57)[0x7fd0aafabdf7]
fcitx(+0x113e)[0x559ce7f8f13e]
/usr/lib/libc.so.6(__libc_start_main+0xf3)[0x7fd0aadb2153]
fcitx(+0x11be)[0x559ce7f8f1be]

fcitx log

$ tail -f crash.log
/usr/lib/libfcitx-core.so.0(+0x11490)[0x7fd0aafb2490]
/usr/lib/libfcitx-core.so.0(+0x144f9)[0x7fd0aafb54f9]
/usr/lib/libfcitx-core.so.0(+0x14707)[0x7fd0aafb5707]
/usr/lib/libfcitx-core.so.0(FcitxInstanceUpdateIMList+0x827)[0x7fd0aafb4947]
/usr/lib/libfcitx-core.so.0(+0x14165)[0x7fd0aafb5165]
/usr/lib/libfcitx-core.so.0(+0xa3cb)[0x7fd0aafab3cb]
/usr/lib/libfcitx-core.so.0(FcitxInstanceRun+0x57)[0x7fd0aafabdf7]
fcitx(+0x113e)[0x559ce7f8f13e]
/usr/lib/libc.so.6(__libc_start_main+0xf3)[0x7fd0aadb2153]
fcitx(+0x11be)[0x559ce7f8f1be]
hchunhui commented 4 years ago

According to the backtrace, the crash is caused by rime::SetupLogging(). I find the crash is caused by an ABI breakage in the latest commit of librime (https://github.com/rime/librime/commit/90839b0b3d47cbfef715ea5f061c7505666ff75d).

So either rebuild fcitx-rime, or checkout older version of librime (e.g. git checkout 1.5.3).

maojunxyz commented 4 years ago

Alright. I rolled back the librime version to 1.5.3 and installed again.

Clear previous version

$ cd librime
$ sudo make uninstall
$ sudo pacman -Rdd librime fcitx-rime

checkout version to 1.5.3

$ git checkout 1.5.3
$ git log -n 1
commit 719542c9bc9fd941cd6fb977b2998557b0be5122 (HEAD, tag: 1.5.3)
Author: Chen Gong <chen.sst@gmail.com>
Date:   Sat Jun 22 18:47:49 2019 +0800

    chore(release): 1.5.3 :tada:

make && make install

$ make merged-plugins
$ sudo make install

Reinstall fcitx-rime

$ sudo pacman -Sdd fcitx-rime

The bad news is that fcitx is not working. The good news is that the errors are different than before.

exec fcitx

$ 12538 addon.c:151) Load Addon Config File:fcitx-notificationitem.conf
(INFO-12538 addon.c:151) Load Addon Config File:fcitx-chttrans.conf
(INFO-12538 addon.c:151) Load Addon Config File:fcitx-xim.conf
(INFO-12538 addon.c:151) Load Addon Config File:fcitx-pinyin-enhance.conf
(INFO-12538 addon.c:151) Load Addon Config File:fcitx-kimpanel-ui.conf
(INFO-12538 addon.c:151) Load Addon Config File:fcitx-vk.conf
(INFO-12538 addon.c:151) Load Addon Config File:fcitx-classic-ui.conf
(INFO-12538 addon.c:151) Load Addon Config File:fcitx-quickphrase.conf
(INFO-12538 addon.c:151) Load Addon Config File:fcitx-autoeng.conf
(INFO-12538 addon.c:151) Load Addon Config File:fcitx-clipboard.conf
(INFO-12538 addon.c:151) Load Addon Config File:fcitx-lua.conf
(INFO-12538 addon.c:151) Load Addon Config File:fcitx-remote-module.conf
(INFO-12538 addon.c:151) Load Addon Config File:fcitx-keyboard.conf
(INFO-12538 addon.c:151) Load Addon Config File:fcitx-punc.conf
(INFO-12538 addon.c:151) Load Addon Config File:fcitx-xkbdbus.conf
(INFO-12538 addon.c:151) Load Addon Config File:fcitx-freedesktop-notify.conf
(ERROR-12538 ime.c:440) fcitx-keyboard-in-tel-kagapa already exists
(ERROR-12538 ime.c:440) fcitx-keyboard-cm-mmuock already exists
PANIC: unprotected error in call to Lua API (attempt to index a nil value)
=========================
FCITX 4.2.9.7 -- Get Signal No.: 6
Date: try "date -d @1576988387" if you are using GNU date ***
ProcessID: 12538
fcitx(+0x17ce)[0x563cb052b7ce]
/usr/lib/libc.so.6(+0x3bfb0)[0x7fe72fc5efb0]
/usr/lib/libc.so.6(gsignal+0x145)[0x7fe72fc5ef25]
/usr/lib/libc.so.6(abort+0x12b)[0x7fe72fc48897]
/usr/lib/liblua.so.5.3(+0x8026)[0x7fe72c76f026]
/usr/lib/liblua.so.5.3(+0xca2d)[0x7fe72c773a2d]
/usr/lib/liblua.so.5.3(+0xcb69)[0x7fe72c773b69]
/usr/lib/liblua.so.5.3(+0xcbb0)[0x7fe72c773bb0]
/usr/lib/liblua.so.5.3(+0x199fa)[0x7fe72c7809fa]
/usr/lib/liblua.so.5.3(lua_settable+0x31)[0x7fe72c770311]
/usr/lib/librime.so.1(_ZN3LuaC1Ev+0x38)[0x7fe72bae8778]
/usr/lib/librime.so.1(+0x252e08)[0x7fe72bad9e08]
/usr/lib/librime.so.1(_ZN4rime13ModuleManager10LoadModuleEP13rime_module_t+0xd6)[0x7fe72b9b97b6]
/usr/lib/librime.so.1(_ZN4rime11LoadModulesEPPKc+0xb6)[0x7fe72b9c7356]
/usr/lib/librime.so.1(RimeInitialize+0x24)[0x7fe72b9800d4]
/usr/lib/fcitx/fcitx-rime.so(+0x244c)[0x7fe72bb6744c]
/usr/lib/fcitx/fcitx-rime.so(+0x24fb)[0x7fe72bb674fb]
/usr/lib/libfcitx-core.so.0(+0x11490)[0x7fe72fe4a490]
/usr/lib/libfcitx-core.so.0(+0x144f9)[0x7fe72fe4d4f9]
/usr/lib/libfcitx-core.so.0(+0x14707)[0x7fe72fe4d707]
/usr/lib/libfcitx-core.so.0(FcitxInstanceUpdateIMList+0x827)[0x7fe72fe4c947]
/usr/lib/libfcitx-core.so.0(+0x14165)[0x7fe72fe4d165]
/usr/lib/libfcitx-core.so.0(+0xa3cb)[0x7fe72fe433cb]
/usr/lib/libfcitx-core.so.0(FcitxInstanceRun+0x57)[0x7fe72fe43df7]
fcitx(+0x113e)[0x563cb052b13e]
/usr/lib/libc.so.6(__libc_start_main+0xf3)[0x7fe72fc4a153]
fcitx(+0x11be)[0x563cb052b1be]

PANIC: unprotected error in call to Lua API (attempt to index a nil value) OMG, this seems to be a problem calling lua api. But what should I do?

/usr/lib/librime.so.1(_ZN4rime13ModuleManager10LoadModuleEP13rime... librime still reports errors during startup, but I don't know what this means.

crash log

$ cat crash.log
=========================
FCITX 4.2.9.7 -- Get Signal No.: 6
Date: try "date -d @1576988387" if you are using GNU date ***
ProcessID: 12538
fcitx(+0x17ce)[0x563cb052b7ce]
/usr/lib/libc.so.6(+0x3bfb0)[0x7fe72fc5efb0]
/usr/lib/libc.so.6(gsignal+0x145)[0x7fe72fc5ef25]
/usr/lib/libc.so.6(abort+0x12b)[0x7fe72fc48897]
/usr/lib/liblua.so.5.3(+0x8026)[0x7fe72c76f026]
/usr/lib/liblua.so.5.3(+0xca2d)[0x7fe72c773a2d]
/usr/lib/liblua.so.5.3(+0xcb69)[0x7fe72c773b69]
/usr/lib/liblua.so.5.3(+0xcbb0)[0x7fe72c773bb0]
/usr/lib/liblua.so.5.3(+0x199fa)[0x7fe72c7809fa]
/usr/lib/liblua.so.5.3(lua_settable+0x31)[0x7fe72c770311]
/usr/lib/librime.so.1(_ZN3LuaC1Ev+0x38)[0x7fe72bae8778]
/usr/lib/librime.so.1(+0x252e08)[0x7fe72bad9e08]
/usr/lib/librime.so.1(_ZN4rime13ModuleManager10LoadModuleEP13rime_module_t+0xd6)[0x7fe72b9b97b6]
/usr/lib/librime.so.1(_ZN4rime11LoadModulesEPPKc+0xb6)[0x7fe72b9c7356]
/usr/lib/librime.so.1(RimeInitialize+0x24)[0x7fe72b9800d4]
/usr/lib/fcitx/fcitx-rime.so(+0x244c)[0x7fe72bb6744c]
/usr/lib/fcitx/fcitx-rime.so(+0x24fb)[0x7fe72bb674fb]
/usr/lib/libfcitx-core.so.0(+0x11490)[0x7fe72fe4a490]
/usr/lib/libfcitx-core.so.0(+0x144f9)[0x7fe72fe4d4f9]
/usr/lib/libfcitx-core.so.0(+0x14707)[0x7fe72fe4d707]
/usr/lib/libfcitx-core.so.0(FcitxInstanceUpdateIMList+0x827)[0x7fe72fe4c947]
/usr/lib/libfcitx-core.so.0(+0x14165)[0x7fe72fe4d165]
/usr/lib/libfcitx-core.so.0(+0xa3cb)[0x7fe72fe433cb]
/usr/lib/libfcitx-core.so.0(FcitxInstanceRun+0x57)[0x7fe72fe43df7]
fcitx(+0x113e)[0x563cb052b13e]
/usr/lib/libc.so.6(__libc_start_main+0xf3)[0x7fe72fc4a153]
fcitx(+0x11be)[0x563cb052b1be]
maojunxyz commented 4 years ago

solved.

I upgraded fcitx4 to fcitx5 and it works perfectly.

$ fcitx5 -v
4.99.0

Allright, it is still 4.xx

However, the problems discussed above still exist in fcitx4

fcitx5 rime works fine in Librime 1.5.3(commit 719542c9bc9fd941cd6fb977b2998557b0be5122 (HEAD, tag: 1.5.3))

Warning: The master version still has problems(commit 90839b0b3d47cbfef715ea5f061c7505666ff75d (HEAD -> master, origin/master, origin/HEAD) ) https://github.com/hchunhui/librime-lua/issues/25#issuecomment-567776565

exec fcitx5 (librime master version)

$ fcitx5 
I instance.cpp:903] Override Enabled Addons: {}
I instance.cpp:904] Override Disabled Addons: {}
I addonmanager.cpp:177] Loaded addon unicode
I addonmanager.cpp:177] Loaded addon wayland
I addonmanager.cpp:177] Loaded addon quickphrase
I addonmanager.cpp:177] Loaded addon xcb
I addonmanager.cpp:177] Loaded addon waylandim
I isocodes.cpp:42] 639-3
I isocodes.cpp:42] 3166-1
I addonmanager.cpp:177] Loaded addon keyboard
I addonmanager.cpp:177] Loaded addon clipboard
I addonmanager.cpp:177] Loaded addon dbus
I addonmanager.cpp:177] Loaded addon dbusfrontend
I addonmanager.cpp:177] Loaded addon ibusfrontend
I addonmanager.cpp:177] Loaded addon xim
I inputmethodmanager.cpp:117] Found 676 input method(s) in addon keyboard
I addonmanager.cpp:177] Loaded addon kimpanel
I addonmanager.cpp:177] Loaded addon classicui
I addonmanager.cpp:177] Loaded addon notificationitem
I kimpanel.cpp:100] Kimpanel new owner
=========================
Fcitx 4.99.0 -- Get Signal No.: 11
Date: try "date -d @1577001644" if you are using GNU date ***
ProcessID: 25680
fcitx5(+0x978e)[0x55fbb2e6b78e]
/usr/lib/libc.so.6(+0x3bfb0)[0x7f2e27e22fb0]
/usr/lib/libc.so.6(+0x161727)[0x7f2e27f48727]
/usr/lib/librime.so.1(_ZN4rime12SetupLoggingEPKciS1_+0x2b)[0x7f2e2510357b]
/usr/lib/fcitx5/rime.so(+0x96ee)[0x7f2e252e46ee]
/usr/lib/fcitx5/rime.so(+0x9a30)[0x7f2e252e4a30]
/usr/lib/fcitx5/rime.so(+0xa418)[0x7f2e252e5418]
/usr/lib/fcitx5/rime.so(+0xbdec)[0x7f2e252e6dec]
/usr/lib/libFcitx5Core.so.5(+0x5c8f7)[0x7f2e2830b8f7]
/usr/lib/libFcitx5Core.so.5(+0x5f87d)[0x7f2e2830e87d]
/usr/lib/libFcitx5Core.so.5(_ZN5fcitx12AddonManager5addonERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEb+0xcd)[0x7f2e2830c74d]
/usr/lib/libFcitx5Core.so.5(_ZN5fcitx8Instance19activateInputMethodERNS_17InputContextEventE+0x201)[0x7f2e282e8f81]
/usr/lib/libFcitx5Core.so.5(+0x3a6d1)[0x7f2e282e96d1]
/usr/lib/libFcitx5Core.so.5(_ZN5fcitx8Instance9postEventERNS_5EventE+0x304)[0x7f2e282e5844]
/usr/lib/libFcitx5Core.so.5(+0x44f42)[0x7f2e282f3f42]
/usr/lib/libFcitx5Core.so.5(+0x3727d)[0x7f2e282e627d]
/usr/lib/libFcitx5Core.so.5(_ZN5fcitx8Instance9postEventERNS_5EventE+0x304)[0x7f2e282e5844]
/usr/lib/fcitx5/dbusfrontend.so(+0xe68b)[0x7f2e26ec568b]
/usr/lib/libFcitx5Utils.so.1(+0x3b764)[0x7f2e2822e764]
/usr/lib/libsystemd.so.0(+0x6bed9)[0x7f2e27d38ed9]
/usr/lib/libsystemd.so.0(+0x538c0)[0x7f2e27d208c0]
/usr/lib/libsystemd.so.0(+0x53cd4)[0x7f2e27d20cd4]
/usr/lib/libsystemd.so.0(+0x3a1f7)[0x7f2e27d071f7]
/usr/lib/libsystemd.so.0(sd_event_dispatch+0x11a)[0x7f2e27d0a63a]
/usr/lib/libsystemd.so.0(sd_event_run+0x99)[0x7f2e27d0bfc9]
/usr/lib/libsystemd.so.0(sd_event_loop+0x58)[0x7f2e27d0c1e8]
/usr/lib/libFcitx5Utils.so.1(_ZN5fcitx9EventLoop4execEv+0x12)[0x7f2e282309b2]
/usr/lib/libFcitx5Core.so.5(_ZN5fcitx8Instance4execEv+0x2c)[0x7f2e282ed49c]
fcitx5(+0x805a)[0x55fbb2e6a05a]
/usr/lib/libc.so.6(__libc_start_main+0xf3)[0x7f2e27e0e153]
fcitx5(+0x87ce)[0x55fbb2e6a7ce]

P.s.

Installation process of librim-lua plugin with fcitx5

For Archlinux/Using pacman as a package management system

  1. uninstall fcitx4 and its dependencies.
  2. install fcitx5 and its dependencies.
$ sudo pacman -S fcitx5-git fcitx5-gtk-git fcitx5-qt5-git fcitx5-rime-git
  1. Remove only librime
    $ sudo pacman -Rdd librime
  2. install librime & librime-lua plugins
    $ git clone https://github.com/rime/librime.git
    $ cd librime
    $ git checkout 1.5.3  # important(Maybe the above problems will be fixed in a future version)
    $ ./install-plugins.sh hchunhui/librime-lua
    $ make merged-plugins
    $ sudo make install

Because I have upgraded to fcitx5 and will no longer return fcitx4 in the future.

So this issue has been closed

CoelacanthusHex commented 4 years ago

librime on Arch have supported librime-lua at https://github.com/archlinux/svntogit-community/commit/5c076244a2f123299e59f909803a2f02e4ef3693 since 1:1.5.3-10 at 2020-06-28 AND plugins such as librime-lua.so have been supported in fcitx5 since https://github.com/fcitx/fcitx5-rime/commit/3adb995f8b937ff32f815f0f29eb22f5e27ab04d and https://github.com/fcitx/fcitx5-rime/issues/8 the update was taken into Arch at 0.0.0.20200517-1