Skip to content

Install josh binaries into a local directory#53

Open
Kobzol wants to merge 3 commits into
rust-lang:mainfrom
Kobzol:installation-progress
Open

Install josh binaries into a local directory#53
Kobzol wants to merge 3 commits into
rust-lang:mainfrom
Kobzol:installation-progress

Conversation

@Kobzol

@Kobzol Kobzol commented Jun 29, 2026

Copy link
Copy Markdown
Member

This PR changes josh-sync so that it install josh binaries into a .josh-sync/cargo directory in the user's HOME directory, to avoid clashing with global Cargo installed binaries.
It also shows the installation progress, to avoid a long duration without any output.

It still installs the commands globally on CI, to make more effective use of caching (via rust-cache).

Fixes: #50

@tgross35

Copy link
Copy Markdown
Contributor

Could this be in ~/.local/bin/josh-sync/ or similar? To avoid some home directory pollution

@Kobzol

Kobzol commented Jun 29, 2026

Copy link
Copy Markdown
Member Author

That would be this, right? I don't just want to hardcode it for Linux :P

@tgross35

Copy link
Copy Markdown
Contributor

I was thinking this one https://docs.rs/dirs/latest/dirs/fn.executable_dir.html but maybe data dir is better since this needs a subdirectory. The same ~/.local directory should be fine on Mac and Windows too, at least I have a number of CLI utils that opted for that.

Or configurable via env would be fine, just preferably some way to avoid a new top-level directory in ~ :)

@Kobzol

Kobzol commented Jun 30, 2026

Copy link
Copy Markdown
Member Author

I wanted to avoid depending on a new dependency, only to find out that we already depend on directories 😆 So I just used its data local directory.

Comment thread src/josh.rs
Comment on lines +107 to +113
pub fn try_install_josh_proxy(verbose: bool) -> Option<JoshProxy> {
try_install_josh_program(JoshProgram::Proxy, verbose).map(JoshProxy::from_path)
}

pub fn try_install_josh_filter(verbose: bool) -> Option<JoshFilter> {
// The josh-filter binary is included in the josh-cli crate
run_command(
&[
"cargo",
"+stable",
"install",
"--locked",
"--git",
"https://github.com/josh-project/josh",
"--tag",
JOSH_VERSION,
"josh-cli",
],
try_install_josh_program(JoshProgram::Filter, verbose).map(JoshFilter::from_path)
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need both of these?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

josh-filter is used only if the config file specifies a subtree-filter, which can be used to further transform the extracted subtree, if the subrepo contains also other stuff.

I expect that once we move to josh-cli completely, we can get rid of both josh-proxy and josh-filter and do everything via the new shared josh CLI command.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I didn't even realize we had such a feature. :D Unfortunate that we need to install two things for that, given how long josh takes to build, but I guess long-term this will go away when we use josh-cli completely and until then there's not much else we can do.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't worry, josh-filter is only installed when you use this niche feature. It is currently only used in rustc-public, AFAIK, so josh-filter shouldn't be installed for e.g. miri.

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

Successfully merging this pull request may close these issues.

josh-sync should not just silently invoke cargo install

3 participants