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

出现 function error,不知道是不是 PATH 设置的不对 #32

Closed
Lightmann opened this issue May 24, 2020 · 10 comments
Closed

出现 function error,不知道是不是 PATH 设置的不对 #32

Lightmann opened this issue May 24, 2020 · 10 comments

Comments

@Lightmann
Copy link

我将 PanBook 下载在了 /Users/lightmann/Desktop/temp 文件夹下面,然后添加了环境变量
export PATH=$PATH:/Users/lightmann/Desktop/temp/PanBook
但执行 panbook book 时出现下面的错误:

> panbook book
/Users/lightmann/Desktop/temp/PanBook/panbook: line 22: declare: -A: invalid option
declare: usage: declare [-afFirtx] [-p] [name[=value] ...]
/Users/lightmann/Desktop/temp/PanBook/panbook: line 23: declare: -A: invalid option
declare: usage: declare [-afFirtx] [-p] [name[=value] ...]
/Users/lightmann/Desktop/temp/PanBook/panbook: line 24: declare: -A: invalid option
declare: usage: declare [-afFirtx] [-p] [name[=value] ...]
/Users/lightmann/Desktop/temp/PanBook/panbook: line 25: declare: -A: invalid option
declare: usage: declare [-afFirtx] [-p] [name[=value] ...]
/Users/lightmann/Desktop/temp/PanBook/panbook: line 26: declare: -A: invalid option
declare: usage: declare [-afFirtx] [-p] [name[=value] ...]
/Users/lightmann/Desktop/temp/PanBook/panbook: line 27: declare: -A: invalid option
declare: usage: declare [-afFirtx] [-p] [name[=value] ...]
/Users/lightmann/Desktop/temp/PanBook/panbook: line 28: declare: -A: invalid option
declare: usage: declare [-afFirtx] [-p] [name[=value] ...]
/Users/lightmann/Desktop/temp/PanBook/panbook: line 93: declare: -A: invalid option
declare: usage: declare [-afFirtx] [-p] [name[=value] ...]
ls: /Users/lightmann/Desktop/temp/PanBook//Users/lightmann/Desktop/temp/PanBook/build/add-headers-260781537425204.tex/: No such file or directory
[NOTE] Welcome to PanBook!
[ERRO] Function: /Users/lightmann/Desktop/temp/PanBook/book_/Users/lightmann/Desktop/temp/PanBook/book not defined
@annProg
Copy link
Owner

annProg commented May 24, 2020

检查一下 bash 的版本 bash --version

$ bash --version
GNU bash,版本 4.4.23(1)-release (x86_64-pc-msys)
Copyright (C) 2016 Free Software Foundation, Inc.
许可证 GPLv3+: GNU GPL 许可证第三版或者更新版本 <http://gnu.org/licenses/gpl.html>

本软件是自由软件,您可以自由地更改和重新发布。
在法律许可的情况下特此明示,本软件不提供任何担保。

ref: https://stackoverflow.com/questions/6047648/bash-4-associative-arrays-error-declare-a-invalid-option

@Lightmann
Copy link
Author

是不是版本太老了?

$ bash --version
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin19)
Copyright (C) 2007 Free Software Foundation, Inc.

@annProg
Copy link
Owner

annProg commented May 24, 2020

是的,需要 4.x 以上版本,可以试试升级 bash

@Lightmann
Copy link
Author

更新 bash 版本之后的情况:

$ bash --version
GNU bash, version 5.0.17(1)-release (x86_64-apple-darwin19.4.0)
Copyright (C) 2019 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
$ panbook book
[NOTE] Welcome to PanBook!
cp: illegal option -- u
usage: cp [-R [-H | -L | -P]] [-fi | -n] [-apvXc] source_file target_file
       cp [-R [-H | -L | -P]] [-fi | -n] [-apvXc] source_file ... target_directory
Unknown option --metadata-file.
Try pandoc --help for more information.
sed: 1: "s#(\includegraphics\{.* ...": RE error: invalid repetition count(s)
sed: 1: "s#(\includegraphics\{)h ...": RE error: invalid repetition count(s)
Latexmk: This is Latexmk, John Collins, 17 Jan. 2018, version: 4.55.

------------
Latexmk: Could not find file [/Users/lightmann/Desktop/temp/PanBook/build/PanBook-book-ctexbook-pc.tex].
-- Use the -f option to force complete processing.
[ERRO] book Compile status is not 0. Please Check. you may add -d or --trace to see more output
$ pandoc -v
pandoc 2.2.3.2
Compiled with pandoc-types 1.17.5.1, texmath 0.11.0.1, skylighting 0.7.2
Default user data directory: /Users/lightmann/.pandoc
Copyright (C) 2006-2018 John MacFarlane
Web:  http://pandoc.org
This is free software; see the source for copying conditions.
There is no warranty, not even for merchantability or fitness
for a particular purpose.

@annProg
Copy link
Owner

annProg commented May 24, 2020

cp 命令参考此文: https://stackoverflow.com/questions/27514652/cp-illegal-option-b-on-mac

pandoc 需要 2.9 以上版本

@Lightmann
Copy link
Author

谢谢。mac 真是太坑了,现在能编译了,只是出来的 pdf 样式比较单一,没有 https://panbook.annhe.net/pub/PanBook-book-elegantbook-pc.pdf 好看

$ panbook book
[NOTE] Welcome to PanBook!
[NOTE] use -V device:(pc|mobile|kindle) to produce different size of pdf
[NOTE] use -V cover:(1-60|R|N|filepath) select cover background.R=random,N=no cover,filepath=custom cover file
[NOTE] use -V pagestyle:style to set pagestyle
Plot Warning: dot not installed!
Plot Warning: ditaa not installed!
Plot Warning: goseq not installed!
Plot Warning: a2s not installed!
Plot Warning: gnuplot not installed!
Plot Warning: gnuplot not installed!
Plot Cache Hit: _plot_render/f2ff41d8e88b195b77692897e8edb7ff89816fd4_asy.pdf
Plot Warning: abcm2ps not installed!
Plot Cache Hit: _plot_render/8420f3fa3ba1cc3ad6fa4e3c7d7aab86b90a2eef_tikz.pdf
Plot Warning: gnuplot not installed!
Plot Warning: gnuplot not installed!
Plot Warning: ditaa not installed!
WARNING: pandoc-crossref was compiled with pandoc 2.9.2 but is being run through 2.9.2.1. This is not supported. Strange things may (and likely will) happen silently.
sed: 1: "s#(\includegraphics\{.* ...": RE error: invalid repetition count(s)
sed: 1: "s#(\includegraphics\{)h ...": RE error: invalid repetition count(s)
Latexmk: This is Latexmk, John Collins, 17 Jan. 2018, version: 4.55.
Latexmk: applying rule 'xelatex'...
Rule 'xelatex': File changes, etc:
...
...
[NOTE] book Compile SUCCESSFUL

@annProg
Copy link
Owner

annProg commented May 24, 2020

book 默认的模板是 ctex,你发的那个链接是 elegantbook 模板,需要加参数编译:

panbook book --style=elegantbook

@Lightmann
Copy link
Author

是用的 elegantbook,代码块显示不太好:

image-20200525014130674

@annProg
Copy link
Owner

annProg commented May 24, 2020

pandoc 有代码高亮风格,默认的是无背景的。演示文档加了 --highlight-style=tango 参数,你可以看看 Makefile 里的定义,或者直接用 make elegantbook 来生成和演示pdf效果一样的文档。

@Lightmann
Copy link
Author

原来如此,太感谢了

@annProg annProg closed this as completed May 26, 2020
@annProg annProg mentioned this issue Dec 11, 2020
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

No branches or pull requests

2 participants