chshersh / tool-sync

🧰 Download pre-built binaries of all your favourite tools with a single command
https://crates.io/crates/tool-sync
Mozilla Public License 2.0
69 stars 16 forks source link

Support executables that aren't in an archive #138

Open binyomen opened 1 year ago

binyomen commented 1 year ago

I'm thinking this would be useful for repos like marksman which store the executables as top-level assets rather than in archives.

Thanks! I was about to make this tool myself when I saw someone had just recently started it!

chshersh commented 1 year ago

@binyomen That sounds like a good idea! tool-sync already supports .exe executables on Windows that aren't in the archive.

But it makes sense to support them from other platforms as well 🙂

binyomen commented 1 year ago

Huh, weird, that doesn't seem to work for me. With the config:

store_directory = '~/bin'

[marksman]
owner = 'artempyanykh'
repo = 'marksman'
asset_name.windows = 'marksman.exe'

I get the output:

🔄  All done!
📦  Estimated total download size: 16.93 MiB
⛔  marksman 2022-09-13 [error] The system cannot find the file specified. (os error 2)                                 ✨  Successfully installed 0 tools!
📁  Installation directory: C:\Users\beweedon/bin

This is on Windows 11 and tool-sync version 0.2.0.

chshersh commented 1 year ago

@binyomen Huh, that is weird. I'd expect this work. I don't have access to Windows so I would start debugging this issue by adding a test for downloading marksman similar to the ripgrep one:

https://github.com/chshersh/tool-sync/blob/5d1a6b6010ca44ec81571c4d7b677c3cb01bb6cd/.github/workflows/ci.yml#L69-L82

At this point, I'm not even sure where exactly this is coming from so a better investigation is required 🕵🏻

binyomen commented 1 year ago

Thanks for the tip! I'll have a look at this when I get the chance!

hdhoang commented 1 year ago

somehow changing copy_file argument copies the exe correctly:

                Ok(_tool_path) => {
                    copy_file(
                        download_info.archive_path,
                        self.store_directory,
                        &tool_asset.exe_name,
                    )?;

and ~it still extracts+copies the native-support executables~. we need to branch this based on ArchiveType, i think.

Some types in sync modules can implement Debug to ease printing them out for investigating.

binyomen commented 1 year ago

It looks like the issue is that for marksman for example, the path passed to copy_file is just marksman.exe rather than the whole path (for tool it's C:\Users\binyomen\AppData\Local\Temp\tool-sync.AeusgFEbnvL2\tool.exe).

I'm working on a fix now.