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

cargo package downloads dev dependencies #2394

Closed
retep998 opened this issue Feb 18, 2016 · 3 comments
Closed

cargo package downloads dev dependencies #2394

retep998 opened this issue Feb 18, 2016 · 3 comments

Comments

@retep998
Copy link
Member

https://ci.appveyor.com/project/retep998/winapi-rs/build/1.0.717/job/h7ohqxbk9vjtrb7p

cargo package
   Packaging winapi v0.2.5 (file:///C:/projects/winapi-rs)
   Verifying winapi v0.2.5 (file:///C:/projects/winapi-rs)
    Updating registry `https://github.com/rust-lang/crates.io-index`
 Downloading winspool-sys v0.0.1
 Downloading dwrite-sys v0.2.0
 Downloading d3d9-sys v0.1.0
 Downloading d3d11-sys v0.1.0
 Downloading dsound-sys v0.0.1
 Downloading wevtapi-sys v0.0.1
 Downloading shlwapi-sys v0.0.1
 Downloading credui-sys v0.0.1
 Downloading advapi32-sys v0.2.0
 Downloading dwmapi-sys v0.1.0
 Downloading dxguid-sys v0.0.1
 Downloading psapi-sys v0.1.0
 Downloading crypt32-sys v0.2.0
 Downloading winhttp-sys v0.0.1
 Downloading winapi v0.2.5
 Downloading vssapi-sys v0.0.1
 Downloading ole32-sys v0.2.0
 Downloading odbc32-sys v0.0.1
 Downloading shell32-sys v0.1.1
 Downloading ktmw32-sys v0.1.0
 Downloading secur32-sys v0.2.0
 Downloading mpr-sys v0.1.0
 Downloading uuid-sys v0.1.2
 Downloading hid-sys v0.0.1
 Downloading d3dcompiler-sys v0.0.1
 Downloading ws2_32-sys v0.2.1
 Downloading kernel32-sys v0.2.1
 Downloading comdlg32-sys v0.0.1
 Downloading httpapi-sys v0.0.1
 Downloading gdi32-sys v0.2.0
 Downloading runtimeobject-sys v0.0.1
 Downloading oleaut32-sys v0.0.1
 Downloading d3d12-sys v0.0.1
 Downloading opengl32-sys v0.1.0
 Downloading netapi32-sys v0.0.1
 Downloading xinput-sys v0.0.1
 Downloading dxgi-sys v0.2.0
 Downloading d2d1-sys v0.0.1
 Downloading winmm-sys v0.2.0
 Downloading usp10-sys v0.0.1
 Downloading user32-sys v0.1.2
 Downloading winscard-sys v0.0.1
 Downloading setupapi-sys v0.0.1
 Downloading bcrypt-sys v0.0.1
 Downloading dbghelp-sys v0.2.0
 Downloading winapi-build v0.1.1
 Downloading comctl32-sys v0.0.1
   Compiling winapi v0.2.5 (file:///C:/projects/winapi-rs/target/package/winapi-0.2.5)

There's no need for it to be downloading those dev dependencies when doing cargo package.

@alexcrichton
Copy link
Member

For anyone who wishes to tackle this, the problem here looks like this:

The bug here is that we download everything regardless of whether we'll ever need it later on or not. The fundamental problem is that the filtering of what packages we really need happens as part of the backend in cargo_rustc. Ahead of time we don't actually know which packages are going to be needed or not.

Possible solutions include:

  • Lazily download all packages. While cargo_rustc is building up the graph of what to compile we could just download any package on demand.
  • Refactor out logic for calculating target dependencies. This would mean that where we currently download packages could use the backend's logic for filtering the list of packages to what we really need to download.
  • ... others!

bors added a commit that referenced this issue Feb 29, 2016
Currently Cargo will download an entire resolution graph all at once when in fact most packages may not be relevant to a compilation. For example target-specific dependencies and dev-dependencies are unconditionally downloaded regardless of whether they're actually needed or not.

This commit alters the internals of Cargo to avoid downloading everything immediately and just switches to lazily downloading packages. This involved adding a new `LazyCell` primitive (similar to the one in use on crates.io) and also propagates `CargoResult` in a few more locations.

Overall this ended up being a pretty large refactoring so the commits are separated in bite-sized chunks as much as possible with the end goal being this PR itself.

Closes #2394
@briansmith
Copy link

When traveling, or when I have spotty internet connectivity, I want to be able to download all the packages so I have them offline, so I don't need internet connectivity. The all-upfront approach works better for this. So, it would be nice to continue, at least, to have some way of downloading all the dependent packages upfront (cargo offline). However, IMO the all-upfront behavior is a pretty good default.

@alexcrichton
Copy link
Member

@briansmith cargo fetch should suffice for that now.

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

No branches or pull requests

3 participants