fornwall / rust-script

Run Rust files and expressions as scripts without any setup or compilation step.
https://rust-script.org
Apache License 2.0
1.21k stars 41 forks source link

rust-script fails to install file association #57

Closed azzamsa closed 1 year ago

azzamsa commented 1 year ago

Hi.

rust-script fails to install file association.

❯ rust-script --install-file-association
error: Found argument '--install-file-association' which wasn't expected, or isn't valid in this context

        If you tried to supply `--install-file-association` as a value rather than a flag, use `-- --install-file-association`

USAGE:
    rust-script [OPTIONS] [--] [script]...

For more information try --help

bin/bin/public on  master [!]
❯ rust-script --version
rust-script 0.21.0
OS: Fedora Linux 36 (Workstation Edition) x86_64
Kernel: 5.19.11-200.fc36.x86_64
Shell: zsh 5.8.1
DE: GNOME 42.5
WM: Mutter
memark commented 1 year ago

You can only (and only need to) do this on Windows. On your system adding a shebang to your script should be enough.

From docs at https://rust-script.org/#executable-scripts:

Executable Scripts

On Unix systems, you can use #!/usr/bin/env rust-script as a shebang line in a Rust script. This will allow you to execute a script files (which don’t need to have the .rs file extension) directly.

If you are using Windows, you can associate the .ers extension (executable Rust - a renamed .rs file) with rust-script. This allows you to execute Rust scripts simply by naming them like any other executable or script.

This can be done using the rust-script --install-file-association command. Uninstall the file association with rust-script --uninstall-file-association.

If you want to make a script usable across platforms, use both a shebang line and give the file a .ers file extension.
azzamsa commented 1 year ago

You can only (and only need to) do this on Windows. On your system adding a shebang to your script should be enough.

Oh, Thank you!