Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/cue: "file already exists" when using --outfile=/dev/null #3624

Open
kshpytsya opened this issue Dec 13, 2024 · 6 comments
Open

cmd/cue: "file already exists" when using --outfile=/dev/null #3624

kshpytsya opened this issue Dec 13, 2024 · 6 comments
Labels

Comments

@kshpytsya
Copy link

</dev/null cue export - --out json -o/dev/null
error writing "/dev/null": file already exists

Sapienti sat.

P.S. I am aware of the following alternative:

</dev/null cue export - --out json -o- >/dev/null
@kshpytsya kshpytsya added the Triage Requires triage/attention label Dec 13, 2024
@myitcv
Copy link
Member

myitcv commented Dec 13, 2024

@kshpytsya thanks for raising. Please can you confirm the details present in the "Bug Report" issue template?

https://github.com/cue-lang/cue/issues/new/choose

Happy for you to edit this issue, or create a new one - whichever you prefer.

@myitcv myitcv added NeedsInfo More information or clarification needed from the user and removed Triage Requires triage/attention labels Dec 13, 2024
@kshpytsya
Copy link
Author

kshpytsya commented Dec 13, 2024

So much for "sat".

$ cue version
cue version
cue version v0.11.0

go version go1.23.3
      -buildmode exe
       -compiler gc
  DefaultGODEBUG asynctimerchan=1,gotypesalias=0,httpservecontentkeepheaders=1,tls3des=1,tlskyber=0,x509keypairleaf=0,x509negativeserial=1
     CGO_ENABLED 1
          GOARCH amd64
            GOOS linux
         GOAMD64 v1
cue.lang.version v0.11.0

Does this issue reproduce with the latest stable release?

Yes

What did you do?

</dev/null cue export - --out json -o/dev/null

What did you expect to see?

zennish empty output and 0 exit code.

What did you see instead?

error writing "/dev/null": file already exists

and 1 for exit code.

@myitcv
Copy link
Member

myitcv commented Dec 13, 2024

So much for "sat".

The reason for having a standard form for bug reports is that, when reviewing a number of them, having such a standard form makes the human job of parsing them easier. It also confirms exactly what version was in use, which is then further relevant for confirming any fixes. Hopefully that's a reasonable position. In any case, thank you for taking the time to raise an initial issue, and follow up with details.

@mvdan
Copy link
Member

mvdan commented Dec 13, 2024

Happy to review a change to fix this edge case, as I imagine it's going to be rather simple. We would need a testscript test as well, even if it is linux-specific, but it could possibly be portable via os.DevNull.

@mvdan mvdan changed the title "/dev/null": file already exists cmd/cue: "file already exists" when using --outfile=/dev/null Dec 13, 2024
@mvdan mvdan added NeedsFix and removed NeedsInfo More information or clarification needed from the user labels Dec 18, 2024
@jpluscplusm
Copy link
Collaborator

I am aware of the following alternative:

</dev/null cue export - --out json -o- >/dev/null

Just for your awareness, @kshpytsya, the cue command's default is to emit exported data to stdout, and also to emit JSON. Thus the minimal alternative is:

 </dev/null cue export - >/dev/null

Because the command also permits files to be specified, with a qualifier prefix indicating their encoding if it can't be inferred from the filename extension, an alternative alternative is:

cue export cue: /dev/null >/dev/null

I don't believe either of these invalidate the need for a fix for your initial issue, but they might be useful.

@jpluscplusm
Copy link
Collaborator

this edge case

I noticed the same error message writing to both /dev/null and a named pipe with --outfile, so I opened #3631 to track the latter. I mention here in case it widens the corner case and affects the potential portability of the solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants