操作系统:linux gentoo 6.0.9
我正试图使用Stack和我编写的构建脚本来构建XMonad的自定义版本,该脚本紧密地基于这里的这个脚本。
build.sh
:
#!/bin/sh
SRC_DIR=$HOME/.config/xmonad
EXE_DIR=$HOME/.local/bin
EXE_NAME=xmonad
######################
unset STACK_YAML
cd $SRC_DIR
stack build 2>.log
ln -f -T $(stack exec -- which $EXE_NAME) $EXE_DIR/$EXE_NAME 2>.log
rm ./src/$EXE_NAME.hi ./src/$EXE_NAME.o 2>/dev/null
上面的stack build
调用未能编译我编写的名为Prompt.Man
的模块(不要被我没有编写的XMonad.Prompt.Man
混淆),该模块以前编译得很好,我根本不理解GHC错误;当我尝试查看错误引用的文件(XMonad/Actions/OnScreen.dyn_hi
)时,它是一个二进制文件。
.log
:
Building executable 'xmonad-vem:xmobar'.
Other executables with the same name might be overwritten: 'xmobar:xmobar'.
Building executable 'xmonad-vem:xmonad'.
Other executables with the same name might be overwritten: 'xmonad:xmonad'.
Building all executables for `xmonad-vem' once. After a successful build of all of them, only specified executables will be rebuilt.
xmonad-vem> configure (exe)
xmonad-vem> Configuring xmonad-vem-0.3...
xmonad-vem> build (exe)
xmonad-vem> Preprocessing executable 'xmobar' for xmonad-vem-0.3..
xmonad-vem> Building executable 'xmobar' for xmonad-vem-0.3..
xmonad-vem> [9 of 9] Compiling Prompt.Man
xmonad-vem>
xmonad-vem> /home/myuser/.config/xmonad/src/Prompt/Man.hs:9:1: error:
xmonad-vem> Bad interface file: /home/myuser/.config/xmonad/.stack-work/install/x86_64-linux-tinfo6/11f8cebbee3588011a80cb3a0acfb83ab68c1e233a64bf2f944fbcae91e1b2fb/8.10.6/lib/x86_64-linux-ghc-8.10.6/xmonad-contrib-0.17.0-KtuI6PQ7yCQKkNv0hd26Wj/XMonad/Actions/OnScreen.dyn_hi
xmonad-vem> Something is amiss; requested module xmonad-contrib-0.17.0:XMonad.Actions.OnScreen differs from name found in the interface file xmonad-contrib-0.17.0-Jq55vblrWW56gRIiMssDFv:XMonad.Actions.OnScreen (if these names look the same, try again with -dppr-debug)
xmonad-vem> |
xmonad-vem> 9 | import XMonad.Actions.OnScreen (onlyOnScreen)
xmonad-vem> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-- While building package xmonad-vem-0.3 (scroll up to its section to see the error) using:
/home/myuser/.stack/setup-exe-cache/x86_64-linux-tinfo6/Cabal-simple_mPHDZzAJ_3.2.1.0_ghc-8.10.6 --builddir=.stack-work/dist/x86_64-linux-tinfo6/Cabal-3.2.1.0 build exe:xmobar exe:xmonad --ghc-options ""
Process exited with code: ExitFailure 1
如GHC所建议的,将标志-dppr-debug
添加到package.yaml
中的ghc-opts
在尝试重建时产生完全相同的错误消息。
我还尝试删除我的.stack
和.stack-work
目录,然后重新运行,这是一次无望的尝试,看看是否能修复任何问题,但没有成功。
是什么导致了这个错误,我该如何解决?
其他文件
stack.yaml
:
resolver: lts-18.7
packages:
- .
- /var/cache/distfiles/xmobar-0.44.1
- /var/cache/distfiles/xmonad-0.17.0
- /var/cache/distfiles/xmonad-contrib-0.17.0
extra-deps: []
flags:
xmobar:
with_xpm: false
with_threaded: false
with_xft: true
with_rtsopts: false
with_alsa: true
with_mpd: false
with_weather: false
with_dbus: false
with_mpris: false
with_inotify: false
with_nl80211: false
with_iwlib: false
with_datezone: false
with_uvmeter: false
with_kraken: false
arch: x86_64
/var/cache/distfiles/
保存了xmonad、xmonad-contrib和xmobar的特定版本的源代码。
package.yaml
:
name: xmonad-vem
version: 0.3
ghc-options: -Wall -Wcompat -Wincomplete-record-updates -Wincomplete-uni-patterns -Wredundant-constraints -O2 -j -dynamic
dependencies:
- base
- containers
- directory
- filepath
- process
- regex-tdfa
- utf8-string
- unix
- xmobar
- xmonad >= 0.17
- xmonad-contrib >= 0.17
source-dirs:
- src
executables:
xmonad:
main: xmonad.hs
dependencies:
- xmonad
- X11 >= 1.10
xmobar:
main: xmobar.hs
dependencies:
- xmobar
更新#1
应一条评论的请求,说问题出在xmonad-contrib-0.17.0
的全局安装版本上,我尝试了stack exec ghc-pkg unregister xmonad-contrib-0.17.0 && stack build
,它现在正在编译,但在运行时立即崩溃,并出现以下错误:
discover_other_daemon: 0/home/myuser/.local/bin/xmonad: error while loading shared libraries: libHSxmonad-contrib-0.17.0-Jq55vblrWW56gRIiMssDFv-ghc8.10.6.so: cannot open shared object file: No such file or directory
更新#2
多亏了一条评论,我明白了其中的一部分;我需要更新我的stack.yaml
,使其不包括xmonad、xmonad-contrib和xmobar的本地版本,并让Stack为我获取它们:
stack.yaml
:
resolver: lts-18.7
packages:
- .
extra-deps:
- xmonad-0.17.0
- xmonad-contrib-0.17.0
- xmobar-0.44.1
xmobar:
with_xpm: false
with_threaded: false
with_xft: true
with_rtsopts: false
with_alsa: true
with_mpd: false
with_weather: false
with_dbus: false
with_mpris: false
with_inotify: false
with_nl80211: false
with_iwlib: false
with_datezone: false
with_uvmeter: false
with_kraken: false
arch: x86_64
并稍微编辑构建脚本:build.sh
:
#!/bin/sh
SRC_DIR=$HOME/.config/xmonad
EXE_DIR=$HOME/.local/bin
EXE_NAME_XMONAD=xmonad
EXE_NAME_XMOBAR=xmobar
######################
unset STACK_YAML
cd $SRC_DIR
stack build 2>.log
ln -f -T $(stack exec -- which $EXE_NAME_XMONAD) $EXE_DIR/$EXE_NAME_XMONAD 2>.log
ln -f -T $(stack exec -- which $EXE_NAME_XMOBAR) $EXE_DIR/$EXE_NAME_XMOBAR 2>.log
rm ./src/$EXE_NAME_XMONAD.hi ./src/$EXE_NAME_XMONAD.o ./src/$EXE_NAME_XMOBAR.hi ./src/$EXE_NAME_XMOBAR.o 2>/dev/null
在X服务器上执行build.sh
并尝试从/home/myuser/.local/bin
运行新的xmonad
和xmobar
后,我仍然会遇到类似的运行时错误:
discover_other_daemon: 0XMonad is recompiling and replacing itself with another XMonad process because the current process is called "xmonad" but the compiled configuration should be called "xmonad-x86_64-linux"
XMonad will use build script at "/home/myuser/.config/xmonad/build" to recompile.
XMonad recompiling because a custom build script is being used.
XMonad recompilation process exited with success!
/home/myuser/.cache/xmonad/xmonad-x86_64-linux: error while loading shared libraries: libHSxmonad-contrib-0.17.0-KtuI6PQ7yCQKkNv0hd26Wj-ghc8.10.6.so: cannot open shared object file: No such file or directory
我想明白了。这就是我必须做的:
#1
使用以下内容作为Stack配置的起点。
stack.yaml
:
resolver: lts-18.7
packages:
- .
extra-deps:
- xmonad-0.17.0
- xmonad-contrib-0.17.0
- xmobar-0.44.1
xmobar:
with_xpm: false
with_threaded: false
with_xft: true
with_rtsopts: false
with_alsa: true
with_mpd: false
with_weather: false
with_dbus: false
with_mpris: false
with_inotify: false
with_nl80211: false
with_iwlib: false
with_datezone: false
with_uvmeter: false
with_kraken: false
arch: x86_64
package.yaml
:
name: xmonad-vem
version: 0.3
ghc-options: -Wall -Wcompat -Wincomplete-record-updates -Wincomplete-uni-patterns -Wredundant-constraints -O2 -j -dynamic
dependencies:
- base
- containers
- directory
- filepath
- process
- regex-tdfa
- utf8-string
- unix
- xmobar
- xmonad >= 0.17
- xmonad-contrib >= 0.17
source-dirs:
- src
executables:
xmonad:
main: xmonad.hs
dependencies:
- xmonad
- X11 >= 1.10
xmobar:
main: xmobar.hs
dependencies:
- xmobar
解释
需要确保Stack将我想用作起点的xmonad、xmonad-contrib和xmobar的版本作为依赖项,如package.yaml
中的依赖项所指定的;而不是试图使用我的机器上全局安装的版本。
#2
将我的build
脚本更新为以下内容:
#!/bin/sh
SRC_DIR=$HOME/.config/xmonad
EXE_NAME=xmonad
unset STACK_YAML
FAIL=0
cd $SRC_DIR
stack build 2>.log || FAIL=1
ln -f -T $(stack exec -- which $EXE_NAME) $1 2>.log || FAIL=2
rm ./src/*.hi ./src/*.o 2>/dev/null
exit $FAIL
那么调用CCD_ 28应该如何工作。
解释
XMonad的重新编译过程比我的构建脚本做的更多。在我的例子中,我只是简单地将编译后的xmonad
和xmobar
二进制文件直接链接到我的本地bin并退出,然后在命令行上调用./build
来重新编译xmonad;然而,通过xmonad --recompile
调用构建脚本实际上会向./build
传递一个参数,并将二进制文件链接到该参数。
感谢@lsmor指出这一点。