Skip to content

Commit

Permalink
use fuzzy versions in bin paths (#1060)
Browse files Browse the repository at this point in the history
Fixes #1059
Fixes #877
  • Loading branch information
jdx authored Dec 3, 2023
1 parent b6229c0 commit d89eb8b
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 4 deletions.
2 changes: 2 additions & 0 deletions e2e/test_use
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ rtx rm --all tiny
rtx i [email protected]
rtx use tiny@1
assert "rtx current tiny" "1.0.0"
rtx use tiny@3
assert "rtx current tiny" "3.1.0"
4 changes: 2 additions & 2 deletions src/plugins/core/deno.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ impl Plugin for DenoPlugin {
tv: &ToolVersion,
) -> Result<Vec<PathBuf>> {
let bin_paths = vec![
tv.install_path().join("bin"),
tv.install_path().join(".deno/bin"),
tv.install_short_path().join("bin"),
tv.install_short_path().join(".deno/bin"),
];
Ok(bin_paths)
}
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/core/python.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ impl PythonPlugin {
}

fn python_path(&self, tv: &ToolVersion) -> PathBuf {
tv.install_path().join("bin/python")
tv.install_short_path().join("bin/python")
}

fn install_default_packages(
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ pub trait Plugin: Debug + Send + Sync {
_ts: &Toolset,
tv: &ToolVersion,
) -> Result<Vec<PathBuf>> {
Ok(vec![tv.install_path().join("bin")])
Ok(vec![tv.install_short_path().join("bin")])
}
fn exec_env(
&self,
Expand Down
18 changes: 18 additions & 0 deletions src/toolset/tool_version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,18 @@ impl ToolVersion {
};
dirs::INSTALLS.join(&self.plugin_name).join(pathname)
}
pub fn install_short_path(&self) -> PathBuf {
let pathname = match &self.request {
ToolVersionRequest::Path(_, p) => p.to_string_lossy().to_string(),
_ => self.tv_short_pathname(),
};
let sp = dirs::INSTALLS.join(&self.plugin_name).join(pathname);
if sp.exists() {
sp
} else {
self.install_path()
}
}
pub fn cache_path(&self) -> PathBuf {
dirs::CACHE.join(&self.plugin_name).join(self.tv_pathname())
}
Expand All @@ -104,6 +116,12 @@ impl ToolVersion {
ToolVersionRequest::System(_) => "system".to_string(),
}
}
fn tv_short_pathname(&self) -> String {
match &self.request {
ToolVersionRequest::Version(_, v) => v.to_string(),
_ => self.tv_pathname(),
}
}

fn resolve_version(
config: &Config,
Expand Down

0 comments on commit d89eb8b

Please sign in to comment.