Skip to content

Commit 19fcd19

Browse files
authored
Merge pull request #1715 from dwijnand/rm-multirust-and-compat
Remove old multirust & compat code
2 parents 174e272 + 91af98b commit 19fcd19

File tree

10 files changed

+11
-951
lines changed

10 files changed

+11
-951
lines changed

Cargo.toml

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,22 @@
11
[package]
2-
32
name = "rustup"
43
version = "1.17.0"
54
edition = "2018"
65
authors = [ "Diggory Blake <[email protected]>" ]
76
description = "Manage multiple rust installations with ease"
8-
9-
documentation = "http://rust-lang.github.io/rustup.rs/rustup/index.html"
7+
documentation = "https://rust-lang.github.io/rustup.rs/rustup/index.html"
108
homepage = "https://github.com/rust-lang/rustup.rs"
119
repository = "https://github.com/rust-lang/rustup.rs"
12-
1310
readme = "README.md"
14-
1511
keywords = ["rustup", "multirust", "install", "proxy"]
16-
1712
license = "MIT OR Apache-2.0"
18-
1913
build = "build.rs"
2014

2115
[features]
22-
2316
default = ["curl-backend", "reqwest-backend"]
24-
2517
curl-backend = ["download/curl-backend"]
2618
reqwest-backend = ["download/reqwest-backend"]
2719
vendored-openssl = ['openssl/vendored']
28-
2920
# Include in the default set to disable self-update and uninstall.
3021
no-self-update = []
3122

src/cli/main.rs

Lines changed: 1 addition & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ mod setup_mode;
2929
mod term2;
3030

3131
use crate::errors::*;
32-
use rustup::dist::dist::TargetTriple;
3332
use rustup::env_var::RUST_RECURSION_COUNT_MAX;
3433
use std::alloc::System;
3534
use std::env;
@@ -51,9 +50,6 @@ fn run_rustup() -> Result<()> {
5150
// bugs in rustup.
5251
do_recursion_guard()?;
5352

54-
// Do various hacks to clean up past messes
55-
do_compatibility_hacks();
56-
5753
// The name of arg0 determines how the program is going to behave
5854
let arg0 = env::args().next().map(PathBuf::from);
5955
let name = arg0
@@ -63,11 +59,7 @@ fn run_rustup() -> Result<()> {
6359

6460
match name {
6561
Some("rustup") => rustup_mode::main(),
66-
Some(n)
67-
if n.starts_with("multirust-setup")
68-
|| n.starts_with("rustup-setup")
69-
|| n.starts_with("rustup-init") =>
70-
{
62+
Some(n) if n.starts_with("rustup-setup") || n.starts_with("rustup-init") => {
7163
// NB: The above check is only for the prefix of the file
7264
// name. Browsers rename duplicates to
7365
// e.g. rustup-setup(2), and this allows all variations
@@ -79,24 +71,6 @@ fn run_rustup() -> Result<()> {
7971
// rustup deletes its own exe
8072
self_update::complete_windows_uninstall()
8173
}
82-
Some(n) if n.starts_with("multirust-") => {
83-
// This is for compatibility with previous revisions of
84-
// multirust-rs self-update, which expect multirust-rs to
85-
// be available on the server, downloads it to
86-
// ~/.multirust/tmp/multirust-$random, and execute it with
87-
// `self install` as the arguments. FIXME: Verify this
88-
// works.
89-
let opts = self_update::InstallOpts {
90-
default_host_triple: TargetTriple::from_host_or_build().to_string(),
91-
default_toolchain: "stable".to_string(),
92-
no_modify_path: false,
93-
};
94-
if cfg!(windows) {
95-
self_update::install(false, false, opts)
96-
} else {
97-
self_update::install(true, false, opts)
98-
}
99-
}
10074
Some(_) => proxy_mode::main(),
10175
None => {
10276
// Weird case. No arg0, or it's unparsable.
@@ -116,70 +90,3 @@ fn do_recursion_guard() -> Result<()> {
11690

11791
Ok(())
11892
}
119-
120-
fn do_compatibility_hacks() {
121-
make_environment_compatible();
122-
fix_windows_reg_key();
123-
delete_multirust_bin();
124-
}
125-
126-
// Convert any MULTIRUST_ env vars to RUSTUP_ and warn about them
127-
fn make_environment_compatible() {
128-
let ref vars = ["HOME", "TOOLCHAIN", "DIST_ROOT", "UPDATE_ROOT", "GPG_KEY"];
129-
for var in vars {
130-
let ref mvar = format!("MULTIRUST_{}", var);
131-
let ref rvar = format!("RUSTUP_{}", var);
132-
let mval = env::var_os(mvar);
133-
let rval = env::var_os(rvar);
134-
135-
match (mval, rval) {
136-
(Some(mval), None) => {
137-
env::set_var(rvar, mval);
138-
warn!("environment variable {} is deprecated. Use {}.", mvar, rvar);
139-
}
140-
_ => (),
141-
}
142-
}
143-
}
144-
145-
// #261 We previously incorrectly set HKCU/Environment/PATH to a
146-
// REG_SZ type, when it should be REG_EXPAND_SZ. Silently fix it.
147-
#[cfg(windows)]
148-
fn fix_windows_reg_key() {
149-
use winreg::enums::{RegType, HKEY_CURRENT_USER, KEY_READ, KEY_WRITE};
150-
use winreg::RegKey;
151-
152-
let root = RegKey::predef(HKEY_CURRENT_USER);
153-
let env = root.open_subkey_with_flags("Environment", KEY_READ | KEY_WRITE);
154-
155-
let env = if let Ok(e) = env { e } else { return };
156-
157-
let path = env.get_raw_value("PATH");
158-
159-
let mut path = if let Ok(p) = path { p } else { return };
160-
161-
if path.vtype == RegType::REG_EXPAND_SZ {
162-
return;
163-
}
164-
165-
path.vtype = RegType::REG_EXPAND_SZ;
166-
167-
let _ = env.set_raw_value("PATH", &path);
168-
}
169-
170-
#[cfg(not(windows))]
171-
fn fix_windows_reg_key() {}
172-
173-
// rustup used to be called 'multirust'. This deletes the old bin.
174-
fn delete_multirust_bin() {
175-
use rustup::utils::utils;
176-
use std::env::consts::EXE_SUFFIX;
177-
use std::fs;
178-
179-
if let Ok(home) = utils::cargo_home() {
180-
let legacy_bin = home.join(format!("bin/multirust{}", EXE_SUFFIX));
181-
if legacy_bin.exists() {
182-
let _ = fs::remove_file(legacy_bin);
183-
}
184-
}
185-
}

src/cli/self_update.rs

Lines changed: 0 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -262,14 +262,10 @@ pub fn install(no_prompt: bool, verbose: bool, mut opts: InstallOpts) -> Result<
262262
}
263263

264264
let install_res: Result<()> = (|| {
265-
cleanup_legacy()?;
266265
install_bins()?;
267266
if !opts.no_modify_path {
268267
do_add_to_path(&get_add_path_methods())?;
269268
}
270-
// Create ~/.rustup and a compatibility ~/.multirust symlink.
271-
// FIXME: Someday we can stop setting up the symlink, and when
272-
// we do that we can stop creating ~/.rustup as well.
273269
utils::create_rustup_home()?;
274270
maybe_install_rust(&opts.default_toolchain, &opts.default_host_triple, verbose)?;
275271

@@ -340,9 +336,6 @@ fn rustc_or_cargo_exists_in_path() -> Result<()> {
340336
!path
341337
.components()
342338
.any(|c| c == Component::Normal(".cargo".as_ref()))
343-
&& !path
344-
.components()
345-
.any(|c| c == Component::Normal(".multirust".as_ref()))
346339
}
347340

348341
if let Some(paths) = env::var_os("PATH") {
@@ -381,62 +374,13 @@ fn check_existence_of_rustc_or_cargo_in_path(no_prompt: bool) -> Result<()> {
381374
}
382375

383376
fn do_pre_install_sanity_checks() -> Result<()> {
384-
let multirust_manifest_path = PathBuf::from("/usr/local/lib/rustlib/manifest-multirust");
385377
let rustc_manifest_path = PathBuf::from("/usr/local/lib/rustlib/manifest-rustc");
386378
let uninstaller_path = PathBuf::from("/usr/local/lib/rustlib/uninstall.sh");
387-
let multirust_meta_path = utils::home_dir().map(|d| d.join(".multirust"));
388-
let multirust_version_path = multirust_meta_path.as_ref().map(|p| p.join("version"));
389379
let rustup_sh_path = utils::home_dir().map(|d| d.join(".rustup"));
390380
let rustup_sh_version_path = rustup_sh_path.as_ref().map(|p| p.join("rustup-version"));
391381

392-
let multirust_exists = multirust_manifest_path.exists() && uninstaller_path.exists();
393382
let rustc_exists = rustc_manifest_path.exists() && uninstaller_path.exists();
394383
let rustup_sh_exists = rustup_sh_version_path.map(|p| p.exists()) == Some(true);
395-
let old_multirust_meta_exists = if let Some(ref multirust_version_path) = multirust_version_path
396-
{
397-
multirust_version_path.exists() && {
398-
let version = utils::read_file("old-multirust", multirust_version_path);
399-
let version = version.unwrap_or(String::new());
400-
let version = version.parse().unwrap_or(0);
401-
let cutoff_version = 12; // First rustup version
402-
403-
version < cutoff_version
404-
}
405-
} else {
406-
false
407-
};
408-
409-
match (multirust_exists, old_multirust_meta_exists) {
410-
(true, false) => {
411-
warn!("it looks like you have an existing installation of multirust");
412-
warn!("rustup cannot be installed alongside multirust");
413-
warn!(
414-
"run `{}` as root to uninstall multirust before installing rustup",
415-
uninstaller_path.display()
416-
);
417-
return Err("cannot install while multirust is installed".into());
418-
}
419-
(false, true) => {
420-
warn!("it looks like you have existing multirust metadata");
421-
warn!("rustup cannot be installed alongside multirust");
422-
warn!(
423-
"delete `{}` before installing rustup",
424-
multirust_meta_path.expect("").display()
425-
);
426-
return Err("cannot install while multirust is installed".into());
427-
}
428-
(true, true) => {
429-
warn!("it looks like you have an existing installation of multirust");
430-
warn!("rustup cannot be installed alongside multirust");
431-
warn!(
432-
"run `{}` as root and delete `{}` before installing rustup",
433-
uninstaller_path.display(),
434-
multirust_meta_path.expect("").display()
435-
);
436-
return Err("cannot install while multirust is installed".into());
437-
}
438-
(false, false) => (),
439-
}
440384

441385
if rustc_exists {
442386
warn!("it looks like you have an existing installation of Rust");
@@ -666,36 +610,6 @@ fn customize_install(mut opts: InstallOpts) -> Result<InstallOpts> {
666610
Ok(opts)
667611
}
668612

669-
// Before rustup-rs installed bins to $CARGO_HOME/bin it installed
670-
// them to $RUSTUP_HOME/bin. If those bins continue to exist after
671-
// upgrade and are on the $PATH, it would cause major confusion. This
672-
// method silently deletes them.
673-
fn cleanup_legacy() -> Result<()> {
674-
let legacy_bin_dir = legacy_multirust_home_dir()?.join("bin");
675-
676-
for tool in TOOLS.iter().cloned().chain(vec!["multirust", "rustup"]) {
677-
let ref file = legacy_bin_dir.join(&format!("{}{}", tool, EXE_SUFFIX));
678-
if file.exists() {
679-
utils::remove_file("legacy-bin", file)?;
680-
}
681-
}
682-
683-
return Ok(());
684-
685-
#[cfg(unix)]
686-
fn legacy_multirust_home_dir() -> Result<PathBuf> {
687-
Ok(utils::legacy_multirust_home()?)
688-
}
689-
690-
#[cfg(windows)]
691-
fn legacy_multirust_home_dir() -> Result<PathBuf> {
692-
use rustup::utils::raw::windows::{get_special_folder, FOLDERID_LocalAppData};
693-
694-
// FIXME: This looks bogus. Where is the .multirust dir?
695-
Ok(get_special_folder(&FOLDERID_LocalAppData).unwrap_or(PathBuf::from(".")))
696-
}
697-
}
698-
699613
fn install_bins() -> Result<()> {
700614
let ref bin_path = utils::cargo_home()?.join("bin");
701615
let ref this_exe_path = utils::current_exe()?;
@@ -845,8 +759,6 @@ pub fn uninstall(no_prompt: bool) -> Result<()> {
845759

846760
info!("removing rustup home");
847761

848-
utils::delete_legacy_multirust_symlink()?;
849-
850762
// Delete RUSTUP_HOME
851763
let ref rustup_dir = utils::rustup_home()?;
852764
if rustup_dir.exists() {
@@ -1631,12 +1543,5 @@ pub fn cleanup_self_updater() -> Result<()> {
16311543
utils::remove_file("setup", setup)?;
16321544
}
16331545

1634-
// Transitional
1635-
let ref old_setup = cargo_home.join(&format!("bin/multirust-setup{}", EXE_SUFFIX));
1636-
1637-
if old_setup.exists() {
1638-
utils::remove_file("setup", old_setup)?;
1639-
}
1640-
16411546
Ok(())
16421547
}

src/config.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,6 @@ impl Cfg {
5656
utils::ensure_dir_exists("home", &rustup_dir, &|n| notify_handler(n.into()))?;
5757

5858
let settings_file = SettingsFile::new(rustup_dir.join("settings.toml"));
59-
// Convert from old settings format if necessary
60-
settings_file.maybe_upgrade_from_legacy(&rustup_dir)?;
6159

6260
let toolchains_dir = rustup_dir.join("toolchains");
6361
let update_hash_dir = rustup_dir.join("update-hashes");

src/settings.rs

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ use crate::utils::utils;
55
use std::cell::RefCell;
66
use std::collections::BTreeMap;
77
use std::path::{Path, PathBuf};
8-
use std::str::FromStr;
98

109
pub const SUPPORTED_METADATA_VERSIONS: [&'static str; 2] = ["2", "12"];
1110
pub const DEFAULT_METADATA_VERSION: &'static str = "12";
@@ -61,52 +60,6 @@ impl SettingsFile {
6160
self.write_settings()?;
6261
Ok(result)
6362
}
64-
pub fn maybe_upgrade_from_legacy(&self, multirust_dir: &Path) -> Result<()> {
65-
// Data locations
66-
let legacy_version_file = multirust_dir.join("version");
67-
if utils::is_file(&legacy_version_file) {
68-
fn split_override<T: FromStr>(s: &str, separator: char) -> Option<(T, T)> {
69-
s.find(separator).and_then(|index| {
70-
match (T::from_str(&s[..index]), T::from_str(&s[index + 1..])) {
71-
(Ok(l), Ok(r)) => Some((l, r)),
72-
_ => None,
73-
}
74-
})
75-
}
76-
77-
let override_db = multirust_dir.join("overrides");
78-
let default_file = multirust_dir.join("default");
79-
// Legacy upgrade
80-
self.with_mut(|s| {
81-
s.version = utils::read_file("version", &legacy_version_file)?
82-
.trim()
83-
.to_owned();
84-
85-
if utils::is_file(&default_file) {
86-
s.default_toolchain = Some(
87-
utils::read_file("default", &default_file)?
88-
.trim()
89-
.to_owned(),
90-
);
91-
}
92-
if utils::is_file(&override_db) {
93-
let overrides = utils::read_file("overrides", &override_db)?;
94-
for o in overrides.lines() {
95-
if let Some((k, v)) = split_override(o, ';') {
96-
s.overrides.insert(k, v);
97-
}
98-
}
99-
}
100-
Ok(())
101-
})?;
102-
103-
// Failure to delete these is not a fatal error
104-
let _ = utils::remove_file("version", &legacy_version_file);
105-
let _ = utils::remove_file("default", &default_file);
106-
let _ = utils::remove_file("overrides", &override_db);
107-
}
108-
Ok(())
109-
}
11063
}
11164

11265
#[derive(Clone, Debug, PartialEq)]

0 commit comments

Comments
 (0)