I am trying to run
gitbook build within a post-receive Git hook on my (Gitlab, Debian 7, virtual private) server.
Basically I want to:
- checkout the bare repository to a temporary dir
gitbook buildin that temporary dir
- sync with the webspace through
post-receive script runs something like:
git --work-tree=/home/git/temp-checkout / --git-dir=/home/git/repositories/my/repo.git checkout -f gitbook build /home/git/temp-checkout rsync ...
Running these commands from the server's command line works perfectly.
Running the script from the server's command line works well too.
But when the script is invoked from the Git hook the
gitbook call produces the following error:
remote: path.js:439 remote: throw new TypeError('Arguments to path.resolve must be strings'); remote: ^ remote: TypeError: Arguments to path.resolve must be strings remote: at Object.posix.resolve (path.js:439:13) remote: at Object.<anonymous> (/usr/lib/node_modules/gitbook-cli/lib/config.js:5:24) remote: at Module._compile (module.js:460:26) remote: at Object.Module._extensions..js (module.js:478:10) remote: at Module.load (module.js:355:32) remote: at Function.Module._load (module.js:310:12) remote: at Module.require (module.js:365:17) remote: at require (module.js:384:17) remote: at Object.<anonymous> (/usr/lib/node_modules/gitbook-cli/bin/gitbook.js:11:14) remote: at Module._compile (module.js:460:26)
Searching for that error message seems to point to Grunt, but I just have no idea what is happening here. I suspected something about invocation/permissions, but neither the user (in both cases
whoami returns the
git user) nor the working directory seem to make a difference.
But in any case
gitbook behaves differently when invoked "locally" (i.e. from the server's command line) or from the Git hook.