我正在学习Avdi Grimm关于Rake的教程系列,但我被Part 6卡住了。调用Pandoc的任务工作正常,但Calibre的ebook-convert命令返回状态127:
andrekibbe@Andres-MacBook rake_basics (master) $ rake
pandoc -o ch1.html ch1.md
pandoc -o ch2.html ch2.md
pandoc -o ch3.html ch3.md
pandoc -o subdir/appendix.html subdir/appendix.md
pandoc -o ch4.html ch4.markdown
cat ch1.html ch2.html ch3.html ch4.html > book.html
ebook-convert book.html book.epub
rake aborted!
Command failed with status (127): [ebook-convert book.html book.epub...]
/Users/andrekibbe/code/rake_basics/Rakefile:27:in `block in <top (required)>'
/Users/andrekibbe/.rvm/gems/ruby-2.2.1/bin/ruby_executable_hooks:15:in `eval'
/Users/andrekibbe/.rvm/gems/ruby-2.2.1/bin/ruby_executable_hooks:15:in `<main>'
Tasks: TOP => default => book.epubebook-convert在我的应用程序目录的路径中:/Applications/calibre.app/Contents/MacOS/calibre,而我的Rakefile在/Users/andrekibbe/code/rake_basics中
require "rake/clean"
SOURCE_FILES = Rake::FileList.new("**/*.md", "**/*.markdown") do |fl|
fl.exclude("~*")
fl.exclude(/^scratch\//)
fl.exclude do |f|
`git ls-files #{f}`.empty?
end
end
CLEAN.include(SOURCE_FILES.ext(".html"))
task default: ["book.epub", "book.mobi"]
task html: SOURCE_FILES.ext(".html")
rule ".html" => ->(f){source_for_html(f)} do |t|
sh "pandoc -o #{t.name} #{t.source}"
end
file "book.html" => SOURCE_FILES.ext(".html") do |t|
chapters = FileList["**/ch*.html"]
backmatter = FileList["backmatter/*.html"]
sh "cat #{chapters} #{backmatter} > #{t.name}"
end
CLEAN.include("book.html")
file "book.epub" => "book.html" do |t|
sh "ebook-convert book.html #{t.name}"
end
CLOBBER.include("book.epub")
file "book.mobi" => "book.epub" do |t|
sh "kindlegen book.epub -o #{t.name}"
end
CLOBBER.include("book.mobi")
def source_for_html(html_file)
SOURCE_FILES.detect{|f| f.ext('') == html_file.ext('')}
end有没有办法要求Rakefile中的Calibre工具,比如gem,或者使用绝对路径或符号链接?我不认为这应该是必要的,因为在Avdi的代码中没有这样的东西。或者我需要在其他地方安装Calibre?
发布于 2016-08-24 12:25:38
退出代码127是“未找到命令”。http://otaku-elite.com/blog/2013/06/06/rake-status-127/
作为第一步,您可以尝试将电子书转换为的,然后使用完整路径。
发布于 2021-07-25 12:08:19
这是因为ebook-convert不在path中。您应该使用ebook-convert的完整路径或将其添加到路径中。
改变你的
ebook-convert book.html book.epub至
/Applications/calibre.app/Contents/MacOS/ebook-convert book.html book.epub或者将本地添加到/usr/ ln /bin,然后重试
sudo ln -s /Applications/calibre.app/Contents/MacOS/ebook-convert /usr/local/binhttps://stackoverflow.com/questions/32426215
复制相似问题