Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(987)

Side by Side Diff: app/views/doc/pub-get.html

Issue 162403002: Remove docs and point to ones on dartlang.org. (Closed) Base URL: https://github.com/dart-lang/pub-dartlang.git@master
Patch Set: Fit in 80 columns. Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « app/views/doc/pub-cache.html ('k') | app/views/doc/pub-lish.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 <pre><code>$ pub get [--offline]
2 </code></pre>
3
4 <p>This command gets all the dependencies listed in the
5 <a href="pubspec.html"><code>pubspec.yaml</code></a> file in the current working directory, as well as
6 their <a href="glossary.html#transitive-dependency">transitive dependencies</a>, and places
7 them in a <code>packages</code> directory located next to the pubspec. For examp le:</p>
8
9 <pre><code>$ pub get
10 Got dependencies!
11 </code></pre>
12
13 <p>Once the dependencies are acquired, they may be referenced in Dart code. For
14 example, if a package depends on <code>unittest</code>:</p>
15
16 <div class="highlight"><pre><code class="dart"><span class="k">import</span> <sp an class="s2">&quot;package:unittest/unittest.dart;</span>
17 </code></pre></div>
18
19 <p>When <code>pub get</code> gets new dependencies, it writes a
20 <a href="glossary.html#lockfile">lockfile</a> to ensure that future gets will us e the
21 same versions of those dependencies. Application packages should check in the
22 lockfile to source control; this ensures the application will use the exact same
23 versions of all dependencies for all developers and when deployed to production.
24 Library packages should not check in the lockfile, though, since they&rsquo;re
25 expected to work with a range of dependency versions.</p>
26
27 <p>If a lockfile already exists, <code>pub get</code> uses the versions of depen dencies
28 locked in it if possible. If a dependency isn&rsquo;t locked, pub will get the
29 latest version of that dependency that satisfies all the <a href="glossary.html# version-constraint">version
30 constraints</a>. This is the primary difference
31 between <code>pub get</code> and <a href="pub-upgrade.html"><code>pub upgrade</c ode></a>, which always tries to
32 get the latest versions of all dependencies.</p>
33
34 <h2 id="getting-a-new-dependency">Getting a new dependency</h2>
35
36 <p>If a dependency is added to the pubspec and then <code>pub get</code> is run, it will
37 get the new dependency and any of its transitive dependencies and place them in
38 the <code>packages</code> directory. However, it won&rsquo;t change the versions of any
39 already-acquired dependencies unless that&rsquo;s necessary to get the new
40 dependency.</p>
41
42 <h2 id="removing-a-dependency">Removing a dependency</h2>
43
44 <p>If a dependency is removed from the pubspec and then <code>pub get</code> is run, it will
45 remove the dependency from the <code>packages</code> directory, thus making it
46 unavailable for importing. Any transitive dependencies of the removed dependency
47 will also be removed, as long as no remaining immediate dependencies also depend
48 on them. Removing a dependency will never change the versions of any
49 already-acquired dependencies.</p>
50
51 <h2 id="linked-packages-directories">Linked <code>packages</code> directories</h 2>
52
53 <p>Every <a href="glossary.html#entrypoint">entrypoint</a> in a package needs to be next to a
54 <code>packages</code> directory in order for it to import packages acquired by P ub.
55 However, it&rsquo;s not convenient to put every entrypoint at the top level of t he
56 package alongside the main <code>packages</code> directory. You may have example scripts or
57 tests that you want to be able to run from subdirectories.</p>
58
59 <p><code>pub get</code> solves this issue by creating additional <code>packages< /code> directories
60 that link to the main <code>packages</code> directory at the root of your packag e. It
61 assumes your package is laid out according to the <a href="package-layout.html"> package layout
62 guide</a>, and creates a linked <code>packages</code> directory in
63 <code>bin/</code>, <code>test/</code>, and <code>example/</code>, as well as the ir subdirectories.</p>
64
65 <h2 id="the-system-package-cache">The system package cache</h2>
66
67 <p>Dependencies are not physically stored in the <code>packages</code> directory that pub
68 creates. Dependencies downloaded over the internet, such as those from Git and
69 <a href="http://pub.dartlang.org">pub.dartlang.org</a>, are stored in a system-w ide cache
70 and linked to from the <code>packages</code> directory. This means that if multi ple
71 packages use the same version of the same dependency, it will only need to be
72 downloaded and stored locally once. It also means that it&rsquo;s safe to delete the
73 <code>packages</code> directory without worrying about re-downloading packages.< /p>
74
75 <p>By default, the system package cache is located in the <code>.pub-cache</code > subdirectory
76 of your home directory. However, it may be configured by setting the <code>PUB_C ACHE</code>
77 environment variable before running Pub.</p>
78
79 <h2 id="getting-while-offline">Getting while offline</h2>
80
81 <p>If you don&rsquo;t have network access, you can still run <code>pub get</code >. Since pub
82 downloads packages to a central cache shared by all packages on your system, it
83 can often find previous-downloaded packages there without needing to hit the
84 network.</p>
85
86 <p>However, by default, pub will always try to go online when you get if you
87 have any hosted dependencies so that it can see if newer versions of them are
88 available. If you don&rsquo;t want it to do that, pass the <code>--offline</code > flag when
89 running pub. In this mode, it will only look in your local package cache and
90 try to find a set of versions that work with your package from what&rsquo;s alre ady
91 available.</p>
92
93 <p>Keep in mind that pub <em>will</em> generate a lockfile after it does this. I f the
94 only version of some dependency in your cache happens to be old, this will lock
95 your app to that version. The next time you are online, you will likely want to
96 run <a href="pub-upgrade.html"><code>pub upgrade</code></a> to upgrade to a late r version.</p>
OLDNEW
« no previous file with comments | « app/views/doc/pub-cache.html ('k') | app/views/doc/pub-lish.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698