janlikar / cargo-clone Goto Github PK
View Code? Open in Web Editor NEWA cargo subcommand to fetch the source code of a Rust crate
License: Apache License 2.0
A cargo subcommand to fetch the source code of a Rust crate
License: Apache License 2.0
cargo-clone
should also be able to clone source code from a git repo or a local dir.
Useful in case one needs to make a modification to a dependencies source, and would like to subsequently use the edited checkout instead of a cargo managed checkout.
Ie:
# --umbrella puts the repo in one level higher than highest level cargo project
# ie if your project was at /foo/bar/far, where 'far' is a nested crate inside bar,
# cargo clean should checkout the project to /foo/project-name.
#
# --override-dep adds a cargo config path entry for the project;
# using the previous example, the config file is placed so it overrides 'bar' 's deps when
# --umbrella is given, else the project present in the current dir.
cargo clone --umbrella --override-dep
It has been deprecated: announcement.
Looks like this is blocked by docopt/docopt.rs#128. I will follow up in this issue when they have a new release ready.
At the moment, we call the invalidate_cache function for every crate we download.
A possible optimization could be to call the invalidate_cache function only once.
See #55 (comment).
Since openssl-sys 0.9.0 has been released, cargo's dependency resolution mechanism is unable to automatically choose a single openssl-sys version for this crate, resulting in a failed build:
native library `openssl` is being linked to by more than one version of the same package, but it can only be linked once; try updating or pinning your dependencies to ensure that this package only shows up once
When I clone manually and do:
cargo update -p openssl-sys:0.9.0 --precise 0.7.17
everything builds fine.
Hi! It looks like the v1.0.1 tag was created two days ago pointing to 3cc5bdd, but since that commit contained an error (Cargo.lock wasn't updated), it was changed to point to d176523 instead. Please don't do that - release tags are meant to be immutable references, and changing them to suddenly point to a different commit causes all kinds of issues with software that expects that not to happen (in my case, makepkg
when building the AUR package). If a release contains a small bug, simply create another patch release (v1.0.2 in this case) that fixes the issue, people will update to that instead. Thanks!
As discussed in #18, add syntax sugar to either change or alias --prefix
to a more git like cargo clone [options] <crate> [path]
On
Darwin Kernel Version 16.5.0: Fri Mar 3 16:52:33 PST 2017; root:xnu-3789.51.2~3/RELEASE_X86_64
with
$ rustup --version
rustup 1.3.0 (124170c 2017-05-09)
$ git --version
git version 2.13.0
$ cargo --version
cargo 0.20.0-nightly (41e490480 2017-05-16)
$ rustc --version
rustc 1.19.0-nightly (0ed1ec9f9 2017-05-18)
I get the following error when I try to clone:
$ cargo clone cortex-m-quickstart
Updating registry `https://github.com/rust-lang/crates.io-index`
error: [6/-8] Cannot reset hard. This operation is not allowed against bare repositories.
This is recent/fresh install.
Simply typing cargo install cargo-clone
, encountered mysterious build failure.
Rustc : rustc 1.36.0 (a53f9df32 2019-07-03)
Toolchain : stable-x86_64-pc-windows-gnu
The error messages are too long so I truncated it
(blob.o):blob.c:(.text$StringCatNWorkerA+0x0): first defined here
C:\Users\Phosphorus15\AppData\Local\Temp\cargo-install52V8Sy\release\deps\liblibgit2_sys-431fcc36e11dd03d.rlib(settings.o):settings.c:(.text$StringCatNWorkerW+0x0): multiple definition of `StringCatNWorkerW'
C:\Users\Phosphorus15\AppData\Local\Temp\cargo-install52V8Sy\release\deps\liblibgit2_sys-431fcc36e11dd03d.rlib(blob.o):blob.c:(.text$StringCatNWorkerW+0x0): first defined here
C:\Users\Phosphorus15\AppData\Local\Temp\cargo-install52V8Sy\release\deps\liblibgit2_sys-431fcc36e11dd03d.rlib(settings.o):settings.c:(.text$StringCatNExWorkerA+0x0): multiple definition of `StringCatNExWorkerA'
C:\Users\Phosphorus15\AppData\Local\Temp\cargo-install52V8Sy\release\deps\liblibgit2_sys-431fcc36e11dd03d.rlib(blob.o):blob.c:(.text$StringCatNExWorkerA+0x0): first defined here
C:\Users\Phosphorus15\AppData\Local\Temp\cargo-install52V8Sy\release\deps\liblibgit2_sys-431fcc36e11dd03d.rlib(settings.o):settings.c:(.text$StringCatNExWorkerW+0x0): multiple definition of `StringCatNExWorkerW'
C:\Users\Phosphorus15\AppData\Local\Temp\cargo-install52V8Sy\release\deps\liblibgit2_sys-431fcc36e11dd03d.rlib(blob.o):blob.c:(.text$StringCatNExWorkerW+0x0): first defined here
C:\Users\Phosphorus15\AppData\Local\Temp\cargo-install52V8Sy\release\deps\liblibgit2_sys-431fcc36e11dd03d.rlib(settings.o):settings.c:(.text$StringVPrintfWorkerA+0x0): multiple definition of `StringVPrintfWorkerA'
C:\Users\Phosphorus15\AppData\Local\Temp\cargo-install52V8Sy\release\deps\liblibgit2_sys-431fcc36e11dd03d.rlib(blob.o):blob.c:(.text$StringVPrintfWorkerA+0x0): first defined here
C:\Users\Phosphorus15\AppData\Local\Temp\cargo-install52V8Sy\release\deps\liblibgit2_sys-431fcc36e11dd03d.rlib(settings.o):settings.c:(.text$StringVPrintfWorkerW+0x0): multiple definition of `StringVPrintfWorkerW'
C:\Users\Phosphorus15\AppData\Local\Temp\cargo-install52V8Sy\release\deps\liblibgit2_sys-431fcc36e11dd03d.rlib(blob.o):blob.c:(.text$StringVPrintfWorkerW+0x0): first defined here
C:\Users\Phosphorus15\AppData\Local\Temp\cargo-install52V8Sy\release\deps\liblibgit2_sys-431fcc36e11dd03d.rlib(settings.o):settings.c:(.text$StringVPrintfExWorkerA+0x0): multiple definition of `StringVPrintfExWorkerA'
C:\Users\Phosphorus15\AppData\Local\Temp\cargo-install52V8Sy\release\deps\liblibgit2_sys-431fcc36e11dd03d.rlib(blob.o):blob.c:(.text$StringVPrintfExWorkerA+0x0): first defined here
C:\Users\Phosphorus15\AppData\Local\Temp\cargo-install52V8Sy\release\deps\liblibgit2_sys-431fcc36e11dd03d.rlib(settings.o):settings.c:(.text$StringVPrintfExWorkerW+0x0): multiple definition of `StringVPrintfExWorkerW'
C:\Users\Phosphorus15\AppData\Local\Temp\cargo-install52V8Sy\release\deps\liblibgit2_sys-431fcc36e11dd03d.rlib(blob.o):blob.c:(.text$StringVPrintfExWorkerW+0x0): first defined here
C:\Users\Phosphorus15\AppData\Local\Temp\cargo-install52V8Sy\release\deps\liblibgit2_sys-431fcc36e11dd03d.rlib(settings.o):settings.c:(.text$StringLengthWorkerA+0x0): multiple definition of `StringLengthWorkerA'
C:\Users\Phosphorus15\AppData\Local\Temp\cargo-install52V8Sy\release\deps\liblibgit2_sys-431fcc36e11dd03d.rlib(blob.o):blob.c:(.text$StringLengthWorkerA+0x0): first defined here
C:\Users\Phosphorus15\AppData\Local\Temp\cargo-install52V8Sy\release\deps\liblibgit2_sys-431fcc36e11dd03d.rlib(settings.o):settings.c:(.text$StringLengthWorkerW+0x0): multiple definition of `StringLengthWorkerW'
C:\Users\Phosphorus15\AppData\Local\Temp\cargo-install52V8Sy\release\deps\liblibgit2_sys-431fcc36e11dd03d.rlib(blob.o):blob.c:(.text$StringLengthWorkerW+0x0): first defined here
error: aborting due to previous error
error: failed to compile `cargo-clone v0.1.3`, intermediate artifacts can be found at `C:\Users\PHOSPH~1\AppData\Local\Temp\cargo-install52V8Sy`
Caused by:
Could not compile `cargo-clone`.
Command line argument parsing does not seem to work on Windows,
i get just
C:\rust>cargo clone -h
Invalid arguments.
Usage:
cargo clone [options] [<crate>]
whatever I pass to it.
Is unusable 👎
It is discovered that cargo clone
cannot properly handle some Cargo.toml
file and would panic even if it is correct, example is shown below
$ cargo clone rand
Updating registry `https://github.com/rust-lang/crates.io-index`
error: failed to parse manifest at `C:\Users\Phosphorus15\.cargo\registry\src\github.com-1ecc6299db9ec823\rand-0.7.1\Cargo.toml`
I've discovered that this problem is because the cargo
crate (version 0.30.0
) is outdated, and I switch it to version 0.38.0
(the latest version), it seems to fix the problem after some tweaking (some of the methods signature have changed).
A pr will be created soon to fully fix this problem.
Can I use cargo clone from my Rust app as a library rather than an executable?
It would be nice in my case, rather than spawning a process to run cargo clone.
error: failed to compile
cargo-clone v0.1.0
Caused by:
build script output was not valid utf-8
When building from repo:
Couldn't find libcurl from pkgconfig ("pkg-config doesn't handle cross compilation. Use PKG_CONFIG_ALLOW_CROSS=1 to override"), compiling it from source...
...
curl-sys-0.1.30\curl\lib\curl_setup.h(132): fatal error C1083: Cannot open include file: 'curl/curlbuild.h': No such file or directory
It seems, curl-sys wont to be compiled.
On second thought, having this is completely useless.
Why would I want to do
cargo clone --git https://github.com/JanLikar/cargo-clone.git
Instead of
git clone https://github.com/JanLikar/cargo-clone.git
I'm planning to remove this functionality to simplify the command, unless someone has good arguments against it.
Depending on Cargo makes the build time unreasonable.
Last time I heard it Cargo team was not too keen on including cargo-clone into Cargo, that's why it doesn't make sense anymore to depend on Cargo.
Everything we use Cargo for could be re-implemented with minimal dependencies. Alternatively, we could call the cargo
binary to perform some of the tasks.
Follow up on #53
AFAIK there is no real standard around that but a lot of packages are using hyphens in their names (while not allowed in imports) yet some still use underscore to match the import name!
Cargo-download for instance does fallback automatically.
While this is not wanted for clone, there could at least be a fallback search of alternative punctuation if the package is not found and report the typo to the end user
Is there a pull request or issue tracking getting this merged into https://github.com/rust-lang/cargo ?
Hi,
I'm coming from cargo-download that is unmaintained but allowed repository less crates to be downloaded, this doesn't seem possible with cargo-clone or I'm missing something?
Thanks
This needs to go if we want to have #19.
I'm trying to clone a specific version of a crate from Crates.io using this command. The crate version is 64.0.0. If i run cargo clone --vers 64.0.0 onig_sys
I get version 64.0.1 rather than 64.0.0. I can clone 63.0.0 successfully. It looks like the --vers
string is being treated as ^64.0.0
not =64.0.0
.
I tried using =64.0.0
and <=64.0.0
but got the error error: cannot parse '=64.0.0' as a semver
.
$ cargo clone byteorder bytes failure futures
I wanted to inspect some of my dependencies and this would have been convenient.
Hi, I notice that cargo clone
only download the source code of the crate, instead of the full git repo. Is there an option to get the git repo too?, so the result will be similar to a git clone
run.
This probably due to refererring to an cargo version (0.9) that transitively depends on non a libssh2 version not yet compatible with OpenSSL 1.1. The following happens upon cargo install cargo-clone
on Debian stretch amd64 system with rustc 1.14.0-beta.2 (e627a2e6e 2016-11-16)
:
Build failed, waiting for other jobs to finish...
error: failed to compilecargo-clone v0.1.0
, intermediate artifacts can be found at/tmp/user/1000/cargo-install.avhrR20HO7OI
Caused by:
failed to run custom build command forlibssh2-sys v0.1.41
process didn't exit successfully:/tmp/user/1000/cargo-install.avhrR20HO7OI/release/build/libssh2-sys-5ede2d7f8ada4bc1/build-script-build
(exit code: 101)
--- stdout
running: "cmake" "/home/rotty/.cargo/registry/src/github.com-1ecc6299db9ec823/libssh2-sys-0.1.41/libssh2" "-DCRYPTO_BACKEND=OpenSSL" "-DBUILD_SHARED_LIBS=OFF" "-DENABLE_ZLIB_COMPRESSION=ON" "-DCMAKE_INSTALL_LIBDIR=lib" "-DBUILD_EXAMPLES=OFF" "-DBUILD_TESTING=OFF" "-DCMAKE_INSTALL_PREFIX=/tmp/user/1000/cargo-install.avhrR20HO7OI/release/build/libssh2-sys-5ede2d7f8ada4bc1/out" "-DCMAKE_C_FLAGS= -O0 -ffunction-sections -fdata-sections -m64 -fPIC" "-DCMAKE_C_FLAGS_RELEASE= -O0 -ffunction-sections -fdata-sections -m64 -fPIC" "-DCMAKE_C_COMPILER=/home/rotty/bin/cc" "-DCMAKE_CXX_FLAGS= -O0 -ffunction-sections -fdata-sections -m64 -fPIC" "-DCMAKE_CXX_FLAGS_RELEASE= -O0 -ffunction-sections -fdata-sections -m64 -fPIC" "-DCMAKE_CXX_COMPILER=/home/rotty/bin/c++" "-DCMAKE_BUILD_TYPE=Release"
[...]
/home/rotty/.cargo/registry/src/github.com-1ecc6299db9ec823/libssh2-sys-0.1.41/libssh2/src/openssl.c: In function ‘_libssh2_rsa_new’:
/home/rotty/.cargo/registry/src/github.com-1ecc6299db9ec823/libssh2-sys-0.1.41/libssh2/src/openssl.c:71:11: error: dereferencing pointer to incomplete type ‘RSA {aka struct rsa_st}’
(*rsa)->e = BN_new();
^~
/home/rotty/.cargo/registry/src/github.com-1ecc6299db9ec823/libssh2-sys-0.1.41/libssh2/src/openssl.c: In function ‘_libssh2_dsa_new’:
/home/rotty/.cargo/registry/src/github.com-1ecc6299db9ec823/libssh2-sys-0.1.41/libssh2/src/openssl.c:130:14: error: dereferencing pointer to incomplete type ‘DSA {aka struct dsa_st}’
(*dsactx)->p = BN_new();
^~
/home/rotty/.cargo/registry/src/github.com-1ecc6299db9ec823/libssh2-sys-0.1.41/libssh2/src/openssl.c: In function ‘_libssh2_dsa_sha1_verify’:
/home/rotty/.cargo/registry/src/github.com-1ecc6299db9ec823/libssh2-sys-0.1.41/libssh2/src/openssl.c:156:13: error: storage size of ‘dsasig’ isn’t known
DSA_SIG dsasig;
^~~~~~
/home/rotty/.cargo/registry/src/github.com-1ecc6299db9ec823/libssh2-sys-0.1.41/libssh2/src/openssl.c:156:13: warning: unused variable ‘dsasig’ [-Wunused-variable]
In file included from /usr/include/openssl/asn1.h:24:0,
from /usr/include/openssl/rsa.h:16,
from /home/rotty/.cargo/registry/src/github.com-1ecc6299db9ec823/libssh2-sys-0.1.41/libssh2/src/openssl.h:42,
from /home/rotty/.cargo/registry/src/github.com-1ecc6299db9ec823/libssh2-sys-0.1.41/libssh2/src/crypto.h:42,
from /home/rotty/.cargo/registry/src/github.com-1ecc6299db9ec823/libssh2-sys-0.1.41/libssh2/src/libssh2_priv.h:140,
from /home/rotty/.cargo/registry/src/github.com-1ecc6299db9ec823/libssh2-sys-0.1.41/libssh2/src/openssl.c:41:
/home/rotty/.cargo/registry/src/github.com-1ecc6299db9ec823/libssh2-sys-0.1.41/libssh2/src/openssl.c: In function ‘_libssh2_dsa_sha1_sign’:
/home/rotty/.cargo/registry/src/github.com-1ecc6299db9ec823/libssh2-sys-0.1.41/libssh2/src/openssl.c:597:29: error: dereferencing pointer to incomplete type ‘DSA_SIG {aka struct DSA_SIG_st}’
r_len = BN_num_bytes(sig->r);
^
make[2]: *** [src/CMakeFiles/libssh2.dir/openssl.c.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [src/CMakeFiles/libssh2.dir/all] Error 2
make: *** [all] Error 2
thread 'main' panicked at '
command did not execute successfully, got: exit code: 2build script failed, must exit now', /home/rotty/.cargo/registry/src/github.com-1ecc6299db9ec823/cmake-0.1.19/src/lib.rs:542
note: Run withRUST_BACKTRACE=1
for a backtrace.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.