-
Notifications
You must be signed in to change notification settings - Fork 331
Expand file tree
/
Copy pathkind.rs
More file actions
1648 lines (1395 loc) · 54.7 KB
/
kind.rs
File metadata and controls
1648 lines (1395 loc) · 54.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
use std::fmt;
use std::path::PathBuf;
use super::ExitCode;
use crate::style::{text_width, tool_version};
use crate::tool;
use crate::tool::package::PackageManager;
use textwrap::{fill, indent};
const REPORT_BUG_CTA: &str =
"Please rerun the command that triggered this error with the environment
variable `VOLTA_LOGLEVEL` set to `debug` and open an issue at
https://github.com/volta-cli/volta/issues with the details!";
const PERMISSIONS_CTA: &str = "Please ensure you have correct permissions to the Volta directory.";
#[derive(Debug)]
#[cfg_attr(test, derive(PartialEq, Eq))]
pub enum ErrorKind {
/// Thrown when package tries to install a binary that is already installed.
BinaryAlreadyInstalled {
bin_name: String,
existing_package: String,
new_package: String,
},
/// Thrown when executing an external binary fails
BinaryExecError,
/// Thrown when a binary could not be found in the local inventory
BinaryNotFound {
name: String,
},
/// Thrown when building the virtual environment path fails
BuildPathError,
/// Thrown when unable to launch a command with VOLTA_BYPASS set
BypassError {
command: String,
},
/// Thrown when a user tries to `volta fetch` something other than node/yarn/npm.
CannotFetchPackage {
package: String,
},
/// Thrown when a user tries to `volta pin` something other than node/yarn/npm.
CannotPinPackage {
package: String,
},
/// Thrown when the Completions out-dir is not a directory
CompletionsOutFileError {
path: PathBuf,
},
/// Thrown when the containing directory could not be determined
ContainingDirError {
path: PathBuf,
},
CouldNotDetermineTool,
/// Thrown when unable to start the migration executable
CouldNotStartMigration,
CreateDirError {
dir: PathBuf,
},
/// Thrown when unable to create the layout file
CreateLayoutFileError {
file: PathBuf,
},
/// Thrown when unable to create a link to the shared global library directory
CreateSharedLinkError {
name: String,
},
/// Thrown when creating a temporary directory fails
CreateTempDirError {
in_dir: PathBuf,
},
/// Thrown when creating a temporary file fails
CreateTempFileError {
in_dir: PathBuf,
},
CurrentDirError,
/// Thrown when deleting a directory fails
DeleteDirectoryError {
directory: PathBuf,
},
/// Thrown when deleting a file fails
DeleteFileError {
file: PathBuf,
},
DeprecatedCommandError {
command: String,
advice: String,
},
DownloadToolNetworkError {
tool: tool::Spec,
from_url: String,
},
/// Thrown when unable to execute a hook command
ExecuteHookError {
command: String,
},
/// Thrown when `volta.extends` keys result in an infinite cycle
ExtensionCycleError {
paths: Vec<PathBuf>,
duplicate: PathBuf,
},
/// Thrown when determining the path to an extension manifest fails
ExtensionPathError {
path: PathBuf,
},
/// Thrown when a hook command returns a non-zero exit code
HookCommandFailed {
command: String,
},
/// Thrown when a hook contains multiple fields (prefix, template, or bin)
HookMultipleFieldsSpecified,
/// Thrown when a hook doesn't contain any of the known fields (prefix, template, or bin)
HookNoFieldsSpecified,
/// Thrown when determining the path to a hook fails
HookPathError {
command: String,
},
/// Thrown when determining the name of a newly-installed package fails
InstalledPackageNameError,
InvalidHookCommand {
command: String,
},
/// Thrown when output from a hook command could not be read
InvalidHookOutput {
command: String,
},
/// Thrown when a user does e.g. `volta install node 12` instead of
/// `volta install node@12`.
InvalidInvocation {
action: String,
name: String,
version: String,
},
/// Thrown when a user does e.g. `volta install 12` instead of
/// `volta install node@12`.
InvalidInvocationOfBareVersion {
action: String,
version: String,
},
/// Thrown when a format other than "npm" or "github" is given for yarn.index in the hooks
InvalidRegistryFormat {
format: String,
},
/// Thrown when a tool name is invalid per npm's rules.
InvalidToolName {
name: String,
errors: Vec<String>,
},
/// Thrown when unable to acquire a lock on the Volta directory
LockAcquireError,
/// Thrown when pinning or installing npm@bundled and couldn't detect the bundled version
NoBundledNpm {
command: String,
},
/// Thrown when pnpm is not set at the command-line
NoCommandLinePnpm,
/// Thrown when Yarn is not set at the command-line
NoCommandLineYarn,
/// Thrown when a user tries to install a Yarn or npm version before installing a Node version.
NoDefaultNodeVersion {
tool: String,
},
/// Thrown when there is no Node version matching a requested semver specifier.
NodeVersionNotFound {
matching: String,
},
NoHomeEnvironmentVar,
/// Thrown when the install dir could not be determined
NoInstallDir,
NoLocalDataDir,
/// Thrown when a user tries to pin a npm, pnpm, or Yarn version before pinning a Node version.
NoPinnedNodeVersion {
tool: String,
},
/// Thrown when the platform (Node version) could not be determined
NoPlatform,
/// Thrown when parsing the project manifest and there is a `"volta"` key without Node
NoProjectNodeInManifest,
/// Thrown when Yarn is not set in a project
NoProjectYarn,
/// Thrown when pnpm is not set in a project
NoProjectPnpm,
/// Thrown when no shell profiles could be found
NoShellProfile {
env_profile: String,
bin_dir: PathBuf,
},
/// Thrown when the user tries to pin Node or Yarn versions outside of a package.
NotInPackage,
/// Thrown when default Yarn is not set
NoDefaultYarn,
/// Thrown when default pnpm is not set
NoDefaultPnpm,
/// Thrown when `npm link` is called with a package that isn't available
NpmLinkMissingPackage {
package: String,
},
/// Thrown when `npm link` is called with a package that was not installed / linked with npm
NpmLinkWrongManager {
package: String,
},
/// Thrown when there is no npm version matching the requested Semver/Tag
NpmVersionNotFound {
matching: String,
},
NpxNotAvailable {
version: String,
},
/// Thrown when the command to install a global package is not successful
PackageInstallFailed {
package: String,
},
/// Thrown when parsing the package manifest fails
PackageManifestParseError {
package: String,
},
/// Thrown when reading the package manifest fails
PackageManifestReadError {
package: String,
},
/// Thrown when a specified package could not be found on the npm registry
PackageNotFound {
package: String,
},
/// Thrown when parsing a package manifest fails
PackageParseError {
file: PathBuf,
},
/// Thrown when reading a package manifest fails
PackageReadError {
file: PathBuf,
},
/// Thrown when a package has been unpacked but is not formed correctly.
PackageUnpackError,
/// Thrown when writing a package manifest fails
PackageWriteError {
file: PathBuf,
},
/// Thrown when unable to parse a bin config file
ParseBinConfigError,
/// Thrown when unable to parse a hooks.json file
ParseHooksError {
file: PathBuf,
},
/// Thrown when unable to parse the node index cache
ParseNodeIndexCacheError,
/// Thrown when unable to parse the node index
ParseNodeIndexError {
from_url: String,
},
/// Thrown when unable to parse the node index cache expiration
ParseNodeIndexExpiryError,
/// Thrown when unable to parse the npm manifest file from a node install
ParseNpmManifestError,
/// Thrown when unable to parse a package configuration
ParsePackageConfigError,
/// Thrown when unable to parse the platform.json file
ParsePlatformError,
/// Thrown when unable to parse a tool spec (`<tool>[@<version>]`)
ParseToolSpecError {
tool_spec: String,
},
/// Thrown when persisting an archive to the inventory fails
PersistInventoryError {
tool: String,
},
/// Thrown when there is no pnpm version matching a requested semver specifier.
PnpmVersionNotFound {
matching: String,
},
/// Thrown when executing a project-local binary fails
ProjectLocalBinaryExecError {
command: String,
},
/// Thrown when a project-local binary could not be found
ProjectLocalBinaryNotFound {
command: String,
},
/// Thrown when a publish hook contains both the url and bin fields
PublishHookBothUrlAndBin,
/// Thrown when a publish hook contains neither url nor bin fields
PublishHookNeitherUrlNorBin,
/// Thrown when there was an error reading the user bin directory
ReadBinConfigDirError {
dir: PathBuf,
},
/// Thrown when there was an error reading the config for a binary
ReadBinConfigError {
file: PathBuf,
},
/// Thrown when unable to read the default npm version file
ReadDefaultNpmError {
file: PathBuf,
},
/// Thrown when unable to read the contents of a directory
ReadDirError {
dir: PathBuf,
},
/// Thrown when there was an error opening a hooks.json file
ReadHooksError {
file: PathBuf,
},
/// Thrown when there was an error reading the Node Index Cache
ReadNodeIndexCacheError {
file: PathBuf,
},
/// Thrown when there was an error reading the Node Index Cache Expiration
ReadNodeIndexExpiryError {
file: PathBuf,
},
/// Thrown when there was an error reading the npm manifest file
ReadNpmManifestError,
/// Thrown when there was an error reading a package configuration file
ReadPackageConfigError {
file: PathBuf,
},
/// Thrown when there was an error opening the user platform file
ReadPlatformError {
file: PathBuf,
},
/// Thrown when unable to read the user Path environment variable from the registry
#[cfg(windows)]
ReadUserPathError,
/// Thrown when the public registry for Node or Yarn could not be downloaded.
RegistryFetchError {
tool: String,
from_url: String,
},
/// Thrown when the shim binary is called directly, not through a symlink
RunShimDirectly,
/// Thrown when there was an error setting a tool to executable
SetToolExecutable {
tool: String,
},
/// Thrown when there was an error copying an unpacked tool to the image directory
SetupToolImageError {
tool: String,
version: String,
dir: PathBuf,
},
/// Thrown when Volta is unable to create a shim
ShimCreateError {
name: String,
},
/// Thrown when Volta is unable to remove a shim
ShimRemoveError {
name: String,
},
/// Thrown when serializing a bin config to JSON fails
StringifyBinConfigError,
/// Thrown when serializing a package config to JSON fails
StringifyPackageConfigError,
/// Thrown when serializing the platform to JSON fails
StringifyPlatformError,
/// Thrown when a given feature has not yet been implemented
Unimplemented {
feature: String,
},
/// Thrown when unpacking an archive (tarball or zip) fails
UnpackArchiveError {
tool: String,
version: String,
},
/// Thrown when a package to upgrade was not found
UpgradePackageNotFound {
package: String,
manager: PackageManager,
},
/// Thrown when a package to upgrade was installed with a different package manager
UpgradePackageWrongManager {
package: String,
manager: PackageManager,
},
VersionParseError {
version: String,
},
/// Thrown when there was an error writing a bin config file
WriteBinConfigError {
file: PathBuf,
},
/// Thrown when there was an error writing the default npm to file
WriteDefaultNpmError {
file: PathBuf,
},
/// Thrown when there was an error writing the npm launcher
WriteLauncherError {
tool: String,
},
/// Thrown when there was an error writing the node index cache
WriteNodeIndexCacheError {
file: PathBuf,
},
/// Thrown when there was an error writing the node index expiration
WriteNodeIndexExpiryError {
file: PathBuf,
},
/// Thrown when there was an error writing a package config
WritePackageConfigError {
file: PathBuf,
},
/// Thrown when writing the platform.json file fails
WritePlatformError {
file: PathBuf,
},
/// Thrown when unable to write the user PATH environment variable
#[cfg(windows)]
WriteUserPathError,
/// Thrown when a user attempts to install a version of Yarn2
Yarn2NotSupported,
/// Thrown when there is an error fetching the latest version of Yarn
YarnLatestFetchError {
from_url: String,
},
/// Thrown when there is no Yarn version matching a requested semver specifier.
YarnVersionNotFound {
matching: String,
},
}
impl fmt::Display for ErrorKind {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
ErrorKind::BinaryAlreadyInstalled {
bin_name,
existing_package,
new_package,
} => write!(
f,
"Executable '{}' is already installed by {}
Please remove {} before installing {}",
bin_name, existing_package, existing_package, new_package
),
ErrorKind::BinaryExecError => write!(
f,
"Could not execute command.
See `volta help install` and `volta help pin` for info about making tools available."
),
ErrorKind::BinaryNotFound { name } => write!(
f,
r#"Could not find executable "{}"
Use `volta install` to add a package to your toolchain (see `volta help install` for more info)."#,
name
),
ErrorKind::BuildPathError => write!(
f,
"Could not create execution environment.
Please ensure your PATH is valid."
),
ErrorKind::BypassError { command } => write!(
f,
"Could not execute command '{}'
VOLTA_BYPASS is enabled, please ensure that the command exists on your system or unset VOLTA_BYPASS",
command,
),
ErrorKind::CannotFetchPackage { package } => write!(
f,
"Fetching packages without installing them is not supported.
Use `volta install {}` to update the default version.",
package
),
ErrorKind::CannotPinPackage { package } => write!(
f,
"Only node and yarn can be pinned in a project
Use `npm install` or `yarn add` to select a version of {} for this project.",
package
),
ErrorKind::CompletionsOutFileError { path } => write!(
f,
"Completions file `{}` already exists.
Please remove the file or pass `-f` or `--force` to override.",
path.display()
),
ErrorKind::ContainingDirError { path } => write!(
f,
"Could not create the containing directory for {}
{}",
path.display(),
PERMISSIONS_CTA
),
ErrorKind::CouldNotDetermineTool => write!(
f,
"Could not determine tool name
{}",
REPORT_BUG_CTA
),
ErrorKind::CouldNotStartMigration => write!(
f,
"Could not start migration process to upgrade your Volta directory.
Please ensure you have 'volta-migrate' on your PATH and run it directly."
),
ErrorKind::CreateDirError { dir } => write!(
f,
"Could not create directory {}
Please ensure that you have the correct permissions.",
dir.display()
),
ErrorKind::CreateLayoutFileError { file } => write!(
f,
"Could not create layout file {}
{}",
file.display(), PERMISSIONS_CTA
),
ErrorKind::CreateSharedLinkError { name } => write!(
f,
"Could not create shared environment for package '{}'
{}",
name, PERMISSIONS_CTA
),
ErrorKind::CreateTempDirError { in_dir } => write!(
f,
"Could not create temporary directory
in {}
{}",
in_dir.display(),
PERMISSIONS_CTA
),
ErrorKind::CreateTempFileError { in_dir } => write!(
f,
"Could not create temporary file
in {}
{}",
in_dir.display(),
PERMISSIONS_CTA
),
ErrorKind::CurrentDirError => write!(
f,
"Could not determine current directory
Please ensure that you have the correct permissions."
),
ErrorKind::DeleteDirectoryError { directory } => write!(
f,
"Could not remove directory
at {}
{}",
directory.display(),
PERMISSIONS_CTA
),
ErrorKind::DeleteFileError { file } => write!(
f,
"Could not remove file
at {}
{}",
file.display(),
PERMISSIONS_CTA
),
ErrorKind::DeprecatedCommandError { command, advice } => {
write!(f, "The subcommand `{}` is deprecated.\n{}", command, advice)
}
ErrorKind::DownloadToolNetworkError { tool, from_url } => write!(
f,
"Could not download {}
from {}
Please verify your internet connection and ensure the correct version is specified.",
tool, from_url
),
ErrorKind::ExecuteHookError { command } => write!(
f,
"Could not execute hook command: '{}'
Please ensure that the correct command is specified.",
command
),
ErrorKind::ExtensionCycleError { paths, duplicate } => {
// Detected infinite loop in project workspace:
//
// --> /home/user/workspace/project/package.json
// /home/user/workspace/package.json
// --> /home/user/workspace/project/package.json
//
// Please ensure that project workspaces do not depend on each other.
f.write_str("Detected infinite loop in project workspace:\n\n")?;
for path in paths {
if path == duplicate {
f.write_str("--> ")?;
} else {
f.write_str(" ")?;
}
writeln!(f, "{}", path.display())?;
}
writeln!(f, "--> {}", duplicate.display())?;
writeln!(f)?;
f.write_str("Please ensure that project workspaces do not depend on each other.")
}
ErrorKind::ExtensionPathError { path } => write!(
f,
"Could not determine path to project workspace: '{}'
Please ensure that the file exists and is accessible.",
path.display(),
),
ErrorKind::HookCommandFailed { command } => write!(
f,
"Hook command '{}' indicated a failure.
Please verify the requested tool and version.",
command
),
ErrorKind::HookMultipleFieldsSpecified => write!(
f,
"Hook configuration includes multiple hook types.
Please include only one of 'bin', 'prefix', or 'template'"
),
ErrorKind::HookNoFieldsSpecified => write!(
f,
"Hook configuration includes no hook types.
Please include one of 'bin', 'prefix', or 'template'"
),
ErrorKind::HookPathError { command } => write!(
f,
"Could not determine path to hook command: '{}'
Please ensure that the correct command is specified.",
command
),
ErrorKind::InstalledPackageNameError => write!(
f,
"Could not determine the name of the package that was just installed.
{}",
REPORT_BUG_CTA
),
ErrorKind::InvalidHookCommand { command } => write!(
f,
"Invalid hook command: '{}'
Please ensure that the correct command is specified.",
command
),
ErrorKind::InvalidHookOutput { command } => write!(
f,
"Could not read output from hook command: '{}'
Please ensure that the command output is valid UTF-8 text.",
command
),
ErrorKind::InvalidInvocation {
action,
name,
version,
} => {
let error = format!(
"`volta {action} {name} {version}` is not supported.",
action = action,
name = name,
version = version
);
let call_to_action = format!(
"To {action} '{name}' version '{version}', please run `volta {action} {formatted}`. \
To {action} the packages '{name}' and '{version}', please {action} them in separate commands, or with explicit versions.",
action=action,
name=name,
version=version,
formatted=tool_version(name, version)
);
let wrapped_cta = match text_width() {
Some(width) => fill(&call_to_action, width),
None => call_to_action,
};
write!(f, "{}\n\n{}", error, wrapped_cta)
}
ErrorKind::InvalidInvocationOfBareVersion {
action,
version,
} => {
let error = format!(
"`volta {action} {version}` is not supported.",
action = action,
version = version
);
let call_to_action = format!(
"To {action} node version '{version}', please run `volta {action} {formatted}`. \
To {action} the package '{version}', please use an explicit version such as '{version}@latest'.",
action=action,
version=version,
formatted=tool_version("node", version)
);
let wrapped_cta = match text_width() {
Some(width) => fill(&call_to_action, width),
None => call_to_action,
};
write!(f, "{}\n\n{}", error, wrapped_cta)
}
ErrorKind::InvalidRegistryFormat { format } => write!(
f,
"Unrecognized index registry format: '{}'
Please specify either 'npm' or 'github' for the format.",
format
),
ErrorKind::InvalidToolName { name, errors } => {
let indentation = " ";
let wrapped = match text_width() {
Some(width) => fill(&errors.join("\n"), width - indentation.len()),
None => errors.join("\n"),
};
let formatted_errs = indent(&wrapped, indentation);
let call_to_action = if errors.len() > 1 {
"Please fix the following errors:"
} else {
"Please fix the following error:"
};
write!(
f,
"Invalid tool name `{}`\n\n{}\n{}",
name, call_to_action, formatted_errs
)
}
// Note: No CTA as this error is purely informational and shouldn't be exposed to the user
ErrorKind::LockAcquireError => write!(
f,
"Unable to acquire lock on Volta directory"
),
ErrorKind::NoBundledNpm { command } => write!(
f,
"Could not detect bundled npm version.
Please ensure you have a Node version selected with `volta {} node` (see `volta help {0}` for more info).",
command
),
ErrorKind::NoCommandLinePnpm => write!(
f,
"No pnpm version specified.
Use `volta run --pnpm` to select a version (see `volta help run` for more info)."
),
ErrorKind::NoCommandLineYarn => write!(
f,
"No Yarn version specified.
Use `volta run --yarn` to select a version (see `volta help run` for more info)."
),
ErrorKind::NoDefaultNodeVersion { tool } => write!(
f,
"Cannot install {} because the default Node version is not set.
Use `volta install node` to select a default Node first, then install a {0} version.",
tool
),
ErrorKind::NodeVersionNotFound { matching } => write!(
f,
r#"Could not find Node version matching "{}" in the version registry.
Please verify that the version is correct."#,
matching
),
ErrorKind::NoHomeEnvironmentVar => write!(
f,
"Could not determine home directory.
Please ensure the environment variable 'HOME' is set."
),
ErrorKind::NoInstallDir => write!(
f,
"Could not determine Volta install directory.
Please ensure Volta was installed correctly"
),
ErrorKind::NoLocalDataDir => write!(
f,
"Could not determine LocalAppData directory.
Please ensure the directory is available."
),
ErrorKind::NoPinnedNodeVersion { tool } => write!(
f,
"Cannot pin {} because the Node version is not pinned in this project.
Use `volta pin node` to pin Node first, then pin a {0} version.",
tool
),
ErrorKind::NoPlatform => write!(
f,
"Node is not available.
To run any Node command, first set a default version using `volta install node`"
),
ErrorKind::NoProjectNodeInManifest => write!(
f,
"No Node version found in this project.
Use `volta pin node` to select a version (see `volta help pin` for more info)."
),
ErrorKind::NoProjectPnpm => write!(
f,
"No pnpm version found in this project.
Use `volta pin pnpm` to select a version (see `volta help pin` for more info)."
),
ErrorKind::NoProjectYarn => write!(
f,
"No Yarn version found in this project.
Use `volta pin yarn` to select a version (see `volta help pin` for more info)."
),
ErrorKind::NoShellProfile { env_profile, bin_dir } => write!(
f,
"Could not locate user profile.
Tried $PROFILE ({}), ~/.bashrc, ~/.bash_profile, ~/.zshenv ~/.zshrc, ~/.profile, and ~/.config/fish/config.fish
Please create one of these and try again; or you can edit your profile manually to add '{}' to your PATH",
env_profile, bin_dir.display()
),
ErrorKind::NotInPackage => write!(
f,
"Not in a node package.
Use `volta install` to select a default version of a tool."
),
ErrorKind::NoDefaultPnpm => write!(
f,
"pnpm is not available.
Use `volta install pnpm` to select a default version (see `volta help install` for more info)."
),
ErrorKind::NoDefaultYarn => write!(
f,
"Yarn is not available.
Use `volta install yarn` to select a default version (see `volta help install` for more info)."
),
ErrorKind::NpmLinkMissingPackage { package } => write!(
f,
"Could not locate the package '{}'
Please ensure it is available by running `npm link` in its source directory.",
package
),
ErrorKind::NpmLinkWrongManager { package } => write!(
f,
"The package '{}' was not installed using npm and cannot be linked with `npm link`
Please ensure it is linked with `npm link` or installed with `npm i -g {0}`.",
package
),
ErrorKind::NpmVersionNotFound { matching } => write!(
f,
r#"Could not find Node version matching "{}" in the version registry.
Please verify that the version is correct."#,
matching
),
ErrorKind::NpxNotAvailable { version } => write!(
f,
"'npx' is only available with npm >= 5.2.0
This project is configured to use version {} of npm.",
version