As reported by Leo and then analyzed by Mark, grafting crashes when the replacement string lies near the end of buffer: https://lists.gnu.org/archive/html/guix-devel/2017-07/msg00445.html With the attached patch on top of commit 7d14082d56462f7bef4254d65a21fd265fbce471, I get this backtrace: --8<---------------cut here---------------start------------->8--- $ ./pre-inst-env guix build go@1.9 [...] @ build-started /gnu/store/n420a0qs7vwnbaj4j3knhfy9j7zqwvs4-go-1.9rc1.drv - x86_64-linux /var/log/guix/drvs/n4//20a0qs7vwnbaj4j3knhfy9j7zqwvs4-go-1.9rc1.drv.bz2 grafting '/gnu/store/8zbi5rr5q2pxksfgpxq37m60nsa21d3v-go-1.9rc1-doc' -> '/gnu/store/djdi6b1bvbrp5fgkkrvk80jndg6gifrh-go-1.9rc1-doc'... grafting '/gnu/store/73fvsx0qizcrbajgjwn8mkzkpxa6abx4-go-1.9rc1' -> '/gnu/store/8bjpc7wxdxsxbf45qvwsd6jbn7zgi871-go-1.9rc1'... Backtrace: In ice-9/boot-9.scm: 160: 17 [catch #t # ...] In unknown file: ?: 16 [apply-smob/1 #] In ice-9/boot-9.scm: 66: 15 [call-with-prompt prompt0 ...] In ice-9/eval.scm: 432: 14 [eval # #] In ice-9/boot-9.scm: 2412: 13 [save-module-excursion #] 4089: 12 [#] 1734: 11 [%start-stack load-stack #] 1739: 10 [#] In unknown file: ?: 9 [primitive-load "/gnu/store/zslsp0k0m06ab7a2vzf2wp3cv6s5zwxn-go-1.9rc1-guile-builder"] In ice-9/eval.scm: 387: 8 [eval # ()] In ice-9/boot-9.scm: 806: 7 [for-each # # #] In /gnu/store/hnwfmnrb1r7dzajn744dafx19ps290d8-module-import/guix/build/graft.scm: 313: 6 [rewrite-directory "/gnu/store/73fvsx0qizcrbajgjwn8mkzkpxa6abx4-go-1.9rc1" ...] In srfi/srfi-1.scm: 616: 5 [for-each # #] In ice-9/boot-9.scm: 877: 4 [call-with-input-file "/gnu/store/73fvsx0qizcrbajgjwn8mkzkpxa6abx4-go-1.9rc1/pkg/tool/linux_amd64/link" ...] 895: 3 [call-with-output-file "/gnu/store/8bjpc7wxdxsxbf45qvwsd6jbn7zgi871-go-1.9rc1/pkg/tool/linux_amd64/link" ...] In /gnu/store/hnwfmnrb1r7dzajn744dafx19ps290d8-module-import/guix/build/graft.scm: 302: 2 [# #] 173: 1 [replace-store-references # ...] In unknown file: ?: 0 [put-bytevector # ...] ERROR: In procedure put-bytevector: ERROR: In procedure put-bytevector: Value out of range: 0 builder for `/gnu/store/n420a0qs7vwnbaj4j3knhfy9j7zqwvs4-go-1.9rc1.drv' failed with exit code 1 @ build-failed /gnu/store/n420a0qs7vwnbaj4j3knhfy9j7zqwvs4-go-1.9rc1.drv - 1 builder for `/gnu/store/n420a0qs7vwnbaj4j3knhfy9j7zqwvs4-go-1.9rc1.drv' failed with exit code 1 --8<---------------cut here---------------end--------------->8--- Ludo’.