Reputation:
I'm working through Avdi Grimm's tutorial series on Rake, and I'm stuck on Part 6. The tasks that invoke Pandoc work fine, but Calibre's ebook-convert
command returns a Status 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.epub
ebook-convert
is in a path of my Applications directory: /Applications/calibre.app/Contents/MacOS/calibre
, while my Rakefile is in /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
Is there a way to require the Calibre tools in the Rakefile, like a gem, or use the absolute path or a symlink? I don't think it should be necessary, since there's nothing like that in Avdi's code. Or do I need to install Calibre elsewhere?
Upvotes: 0
Views: 1641
Reputation: 351
It is because ebook-convert
is not in path. You should use full path of ebook-convert
or add it to path.
Change your
ebook-convert book.html book.epub
To
/Applications/calibre.app/Contents/MacOS/ebook-convert book.html book.epub
Or add ln
to /usr/local/bin and try again
sudo ln -s /Applications/calibre.app/Contents/MacOS/ebook-convert /usr/local/bin
Upvotes: 0
Reputation: 1238
Exit code 127 is "command not found". http://otaku-elite.com/blog/2013/06/06/rake-status-127/
As a first step, you might try which ebook-convert and then use the full path.
Upvotes: 0