cargo-local-registry icon indicating copy to clipboard operation
cargo-local-registry copied to clipboard

Unusable with workspaces

Open Kixunil opened this issue 7 years ago • 5 comments

I'm using macOS 10.12.

$ cargo local-registry --sync Cargo.lock somewhere/local-registry
error: failed to sync

Caused by:
  workspace member `/.../lib/my_lib/Cargo.toml` is not hierarchically below the workspace root `/.../foo/my_workspace/Cargo.toml`

According to several issues on Github this should be fixed in newer version? Unfortunately:

$ export OPENSSL_DIR=~/homebrew/Cellar/openssl/1.0.2l/
$ cargo install -f cargo-local-registry
   Updating registry `https://github.com/rust-lang/crates.io-index`
  Installing cargo-local-registry v0.1.3
   Compiling log v0.3.8
...
   Compiling git2-curl v0.7.0
   Compiling cargo v0.18.0
   Compiling cargo-local-registry v0.1.3
error: linking with `cc` failed: exit code: 1
... Huge message here...
  = note: Undefined symbols for architecture x86_64:
            "_libiconv", referenced from:
                _git_path_iconv in liblibgit2_sys-043a5a2e7e841ad4.rlib(path.c.o)
            "_libiconv_open", referenced from:
                _git_path_direach in liblibgit2_sys-043a5a2e7e841ad4.rlib(path.c.o)
                _git_path_iconv_init_precompose in liblibgit2_sys-043a5a2e7e841ad4.rlib(path.c.o)
                _git_path_diriter_init in liblibgit2_sys-043a5a2e7e841ad4.rlib(path.c.o)
            "_libiconv_close", referenced from:
                _git_path_direach in liblibgit2_sys-043a5a2e7e841ad4.rlib(path.c.o)
                _git_path_iconv_clear in liblibgit2_sys-043a5a2e7e841ad4.rlib(path.c.o)
                _git_path_diriter_free in liblibgit2_sys-043a5a2e7e841ad4.rlib(path.c.o)
                _git_path_dirload in liblibgit2_sys-043a5a2e7e841ad4.rlib(path.c.o)
          ld: symbol(s) not found for architecture x86_64
          clang: error: linker command failed with exit code 1 (use -v to see invocation)

I tried to invoke that command manually with added -L ~/homebrew/Cellar/libiconv/1.15/lib/ argument. It compiled but after copying to ~.cargo/bin/cargo-local-registry this happens:

$ cargo local-registry --sync Cargo.lock somewhere/local-registry
    Updating registry `https://github.com/rust-lang/crates.io-index`
error: failed to sync

Caused by:
  failed to fetch `https://github.com/rust-lang/crates.io-index`

To learn more, run the command again with --verbose.
$ cargo local-registry --verbose --sync Cargo.lock .somewhere/local-registry
    Updating registry `https://github.com/rust-lang/crates.io-index`
error: failed to sync

Caused by:
  failed to fetch `https://github.com/rust-lang/crates.io-index`

To learn more, run the command again with --verbose.

Any idea how to solve this?

Kixunil avatar Jun 09 '17 14:06 Kixunil

Thanks for the report! (Sorry for the delay looking into this)

It looks like there's 2 issues here, right? Something with workspaces and something with building this crate itself? Is that right? If so, can you provide a way to reproduce the first?

alexcrichton avatar Jun 16 '17 14:06 alexcrichton

I'm not sure now. I built it quite long ago. When looking for solution I found this issue. I suspect that since it was fixed then, it might be fixed in the newest version. So I decided to re-install cargo-local-repository and failed.

I'd try to install the newest version first, to know whether it was fixed.

I just ran cargo install cargo-local-registry. It complained about SSL library, so I did export OPENSSL_DIR=~/homebrew/Cellar/openssl/1.0.2l/, as I mentioned above.

Regarding the workspace, I set up a simple workspace with single bin project in it. It depends on library outside the workspace.

The tree looks like this:

/
+- lib/
    +- my_rust_lib/
        +- Cargo.toml
        +- ...
+- bins/
    +- my_workspace/
        +- Cargo.toml
        +- my_bin/
            +- Cargo.toml
            +- src/

In Cargo.toml of my_bin:

[dependencies]
my_rust_lib = { path = "../../../lib/my_rust_lib" }

When trying to build my_bin, it fails.

Kixunil avatar Jun 16 '17 19:06 Kixunil

Is this specific to cargo-local-registry? That just looks like a standard misconfigured workspace

alexcrichton avatar Jun 22 '17 16:06 alexcrichton

Sorry for replying late, I had other things at work.

That just looks like a standard misconfigured workspace

Well, compilation works fine. Which setting could cause cargo-local-registry fail but wouldn't break compilation?

Kixunil avatar Jun 30 '17 10:06 Kixunil

Maybe different versions of the cargo support library? I'm not sure.

alexcrichton avatar Jul 03 '17 14:07 alexcrichton