← Back to issue list

Can't redirect the output of go run to a file

View original Github issue

Metadata

Project
rockcraft
Number
#755
Type
issue
State
open
Author
kian99
Labels
Created
2024-11-19 10:36:50+00:00
Updated
2024-11-19 10:36:50+00:00
Closed

Current evaluation

No evaluation has been recorded for this issue yet.

Issue body

### Bug Description When running in the override-build step, the output of `go run` is not being redirected to a file as expected. In my override-build step I am using a go package to do some formatting on a file. As I was typing out this bug report, I realised that I think this is happening because of snap confinement. It feels a bit frustrating to face snap confinement issues while in a build environment. ### To Reproduce Use the rockcraft.yaml below and put an `exit 1` at the start of override-build and run `rockcraft pack --debug`. Then try the following: - go run github.com/openfga/cli/cmd/fga@latest model -h - go run github.com/openfga/cli/cmd/fga@latest model -h > test-file - ls -lah test-file - go install github.com/openfga/cli/cmd/fga@latest - /root/go/bin/fga model -h > test-file - ls -lah test-file On my machine: ``` # go run github.com/openfga/cli/cmd/fga@latest model -h > test-file # ls -lah test-file -rw-r--r-- 1 root root 0 Nov 19 12:31 test-file # /root/go/bin/fga -h > test-file # ls -lah test-file -rw-r--r-- 1 root root 1.5K Nov 19 12:35 test-file ``` As you can see the first attempt results in an empty file (maybe because of snap confinement?) while the second attempt works. ### Environment ``` $ lxc version Client version: 6.1 Server version: 6.1 ``` ### rockcraft.yaml ```yaml name: jimm base: ubuntu@22.04 version: '0.1' summary: Juju Intelligent Model Manager provides a convient way to manage all of your models! description: | JIMM is a Juju controller, used in conjunction with the JaaS dashboard to provide a seamless way to manage models, regardless of where their controllers reside or what cloud they may be running on. license: GPL-3.0 platforms: amd64: parts: ca-certs: plugin: nil overlay-packages: [ca-certificates] builder: plugin: go # https://canonical-craft-parts--694.com.readthedocs.build/en/694/common/craft-parts/reference/plugins/go_plugin.html after: - ca-certs source: . source-type: local build-snaps: - go/1.23/stable build-packages: - git - make build-environment: - GOOS: linux override-build: | set -ex mkdir -p $CRAFT_PART_INSTALL/usr/local/bin make build/server cp ./jimmsrv $CRAFT_PART_INSTALL/usr/local/bin # The location of SQL files isn't configurable right now, as such we just # place it in bin cp -r ./internal/dbmodel/sql $CRAFT_PART_INSTALL/usr/local/bin/sql # Convert the OpenFGA auth model to JSON and place a copy in the ROCK # Used by the charm to apply to the OpenFGA server, not by the container itself mkdir -p $CRAFT_PART_INSTALL/root/openfga/ go install github.com/openfga/cli/cmd/fga@latest go run github.com/openfga/cli/cmd/fga@latest model transform --file ./openfga/authorisation_model.fga --output-format json > $CRAFT_PART_INSTALL/root/openfga/authorisation_model.json exit 1 ``` ### Relevant log output ```shell None ```

Evaluation history

No evaluation history available.