pksunkara/cargo-workspaces

`cargo ws publish` segfaults on Nix

Stonks3141 opened this issue · 7 comments

To reproduce

install Nix and run these commands:

cargo new foo
cd foo
cat <<EOF > shell.nix
{ pkgs ? import <nixpkgs> {} }: pkgs.mkShell {
  packages = with pkgs; [
    cargo
    rustc
    cargo-workspaces
  ];
}
EOF
nix-shell --run 'cargo ws publish --from-git'
  1. I don't use Nix.
  2. Can you please paste the error message here?
  3. Segfault is not something that can happen inside the lib. Are you sure this is not caused by rust itself?
  1. I do, and I want to use your project. Here is a link to an online code environment that reproduces the bug. Below are instructions to set up a Docker image that reproduces the bug. Both of these took me less than ten minutes to figure out.
  2. Segmentation fault (core dumped)
  3. Everything else works except for the publish subcommand with the --from-git flag. Even if your application isn't responsible, it's still a bug that's manifesting in it and causing problems for a user.

I found your response dismissive and unhelpful. I reported a clear bug in good faith with repro instructions, and you immediately closed the issue without any further investigation of the problem. I was and still am perfectly willing to provide whatever additional information you might need or work on a fix myself.

Docker instructions
  1. Start the NixOS image: sudo docker run -it nixos/nix
  2. Run nix-shell -p cargo to install cargo
  3. Run the original repro instructions.

I am still unable to reproduce it. I spun up the docker as you said and created the foo crate and added the shell.nix file.

bash-5.1# nix-shell -p 'cargo ws publish --from-git'
error: undefined variable 'publish'

       at «string»:1:116:

            1| {...}@args: with import <nixpkgs> args; (pkgs.runCommandCC or pkgs.runCommand) "shell" { buildInputs = [ (cargo ws publish --from-git) ]; } ""
             |                                                                                                                    ^
(use '--show-trace' to show detailed location information)

FWIW, doing cargo install cargo-workspaces inside nix-shell is failing too for me.

As an alternative, try git init in the repo first. Maybe that is what causing this.

cargo new initializes a Git repository, that shouldn't be a problem.

I'm not sure why you can't reproduce it with Docker. Running these commands reproduces it consistently for me:

sudo docker run -it nixos/nix
nix-shell -p cargo rustc cargo-workspaces
cargo new foo
cd foo
cargo ws publish --from-git

Have you tried the Replit?

I don't know what repl.it does and it would be hard to debug in there.

Can confirm that I was able to reproduce it. Though I did get some weird errors sometimes.

[nix-shell:/foo]# cargo ws publish --from-git
error: crates index error: reference 'refs/heads/master' not found; class=Reference (4); code=NotFound (-3)