build.go translate does not work for me

I’ve had this problem with several PRs now, but never got it working in order to test how my own GUI changes affect translations. Now asking for help here to troubleshoot.

After running the translation script, the gui/default/assets/lang/lang-en.json file is always completely empty. It seems that redirecting the output of translate.go to lang-en-new.json fails, although the command itself does output something. This is the CLI output, maybe the warning have something to do with it?

go run build.go translate
2021/05/26 16:22:22 Untranslated text node (editFolderModalView.html):
2021/05/26 16:22:22 	<p class="help-block">
	  <span translate ng-if="folderEditor.externalCommand.$valid || folderEditor.externalCommand.$pristine">See external versioning help for supported templated command line parameters.</span>
	  <span translate ng-if="folderEditor.externalCommand.$error.required && folderEditor.externalCommand.$dirty">The path cannot be blank.</span>
      <div class="form-group" ng-if="internalVersioningEnabled()" ng-class="{'has-error': folderEditor.cleanupIntervalS.$invalid && folderEditor.cleanupIntervalS.$dirty}">
	<label translate for="cleanupIntervalS">Cleanup Interval</label>
	<div class="input-group">
	  <input name="cleanupIntervalS" id="cleanupIntervalS" class="form-control text-right" type="number" ng-model="currentFolder._guiVersioning.cleanupIntervalS" required="" min="0" max="31536000" aria-required="true" />
	  <div class="input-group-addon" translate>seconds</div>
	<p class="help-block">
	  <span translate ng-if="folderEditor.cleanupIntervalS.$valid || folderEditor.cleanupIntervalS.$pristine"class="help-block">The interval, in seconds, for running cleanup in the versions directory. Zero to disable periodic cleaning.</span>
	  <span translate ng-if="folderEditor.cleanupIntervalS.$error.required && folderEditor.cleanupIntervalS.$dirty">The cleanup interval cannot be blank.</span>
	  <span translate ng-if="folderEditor.cleanupIntervalS.$error.min && folderEditor.cleanupIntervalS.$dirty">The interval must be a positive number of seconds.</span>

    <div ng-if="!editingDefaults" id="folder-ignores" class="tab-pane">
      <p translate>Enter ignore patterns, one per line.</p>
      <div ng-class="{'has-error': ignores.error != null}">
	<textarea class="form-control" rows="5" ng-model="ignores.text" ng-disabled="ignores.disabled">

So basically if I switch from the fd output to os.Stdout in runPipe() here, the output reaches the console perfectly fine. But the created file always has length zero (verified by fd.Seek(0, 1)) and fd.Sync() doesn’t help either.

This is go version go1.16.3 linux/amd64.

Apparently it works fine when calling a different program than go run. Test program:

package main

import (

func main() {
	fd, err := os.Create("stdout.txt")
	if err != nil {
	//cmd := exec.Command("ls", "-l")                         //WORKS!
	cmd := exec.Command("go", "run", "build.go", "version") //FAILS!
	cmd.Stdout = fd
	cmd.Stderr = os.Stderr
	fi, err := fd.Stat()
	fmt.Printf("file %v has size %d", fi.Name(), fi.Size())

I have no idea, except the warning also makes no sense. So that might be related?

Except for the indeed weird warning, it works for me, so no clue either.

It seems to be related to having Go installed via Snap. If I download and extract the official binary from, the script works in both cases. Must be some sandboxing thing then which disallows passing file descriptors or something.

So I mailed the maintainer of the Snap package about the issue.

1 Like

Snap is the gift that keeps giving.