Hi all!
Very new to roc and this issue may not even be Roc related? If not, I'm very puzzled where the missing text is coming from if not stdout. Here is the symptom I'm seeing:
$ roc
ec425a0 Ignore compiler artifact
$ git log --oneline --no-color
ec425a0 (HEAD -> main) Ignore compiler artifact
$ git log --oneline --no-color 2>/dev/null
ec425a0 (HEAD -> main) Ignore compiler artifact
For some reason my Roc output is missing the branch information section.
Here is my code to execute git log that follows the very nice example in the basic cli platform:
gitLog =
(_status, stdout, _stderr) <-
Cmd.new "git"
|> Cmd.args [
"log",
"--oneline",
"--no-color",
]
|> Cmd.output
|> Task.map \output -> (Success, output.stdout, output.stderr)
|> Task.onErr \(output, err) ->
when err is
ExitCode code -> Task.ok (NonZeroExit code, output.stdout, output.stderr)
KilledBySignal -> Task.ok (Killed, output.stdout, output.stderr)
IOError error -> Task.ok (IOError error, output.stdout, output.stderr)
|> Task.await
value = Str.fromUtf8 stdout |> Result.withDefault "Failed to read buffer"
Stdout.write value
I appreciate anyone that takes the time to look into this with me!
So is the issue that when you run this with roc the (HEAD -> main)
is missing?
Yep! Sorry I could have been more clear. That text is missing and its definitely produced by the same command when I call it in my terminal
Can you run like cargo init bin
and copy paste this in
fn main() {
use std::io::{self, Write};
use std::process::Command;
let output = Command::new("git")
.args(["log", "--oneline", "--no-color"])
.output()
.expect("failed to execute process");
println!("status: {}", output.status);
io::stdout().write_all(&output.stdout[..]).unwrap();
io::stderr().write_all(&output.stderr[..]).unwrap();
}
and see what the output when you run cargo run
is?
Yep! I got the same output as my Roc application
Edit to help anyone just showing up
Output:
Compiling roc-git-browser v0.1.0 (/home/jordan/personal/projects/roc/roc-git-browser)
Finished dev [unoptimized + debuginfo] target(s) in 0.30s
Running `target/debug/roc-git-browser`
status: exit status: 0
ec425a0 Ignore compiler artifact
normal git log output:
$ git log --oneline --no-color 2>/dev/null
ec425a0 (HEAD -> main) Ignore compiler artifact
I've been scratching my head on this one, and I don't have any good ideas from here. I guess it's something to do with how rust executes a command that is different to the shell, or maybe the program git
behaves differently somehow.
yep! that is the only thing I could think of as well. I ran it as root just to see if I had something weird in git config but no dice
Just tested with a simple ruby script as well and it was also missing the info
puts `git log --oneline --no-color`
So this is definitely not a Roc thing. I will continue my search but thank you for checking it out!
Jordan Grant has marked this topic as resolved.
@Luke Boswell
Oh! I found the answer and will post if for posterity. Git must use the --decorate
flag by default when executed by a shell process?
Just add --decorate
as an option to the above code and you get the expected result
Last updated: Jul 06 2025 at 12:14 UTC