Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding nu version to scripts #1051

Open
TheCodeLamp opened this issue Feb 19, 2025 · 5 comments
Open

Adding nu version to scripts #1051

TheCodeLamp opened this issue Feb 19, 2025 · 5 comments

Comments

@TheCodeLamp
Copy link

Hello, a recent commit (446f06f) broke the ssh custom completion for nu version 0.99.1 (the one shipped by dnf and fedora). This isn't a huge issue and I just downloaded the previous version.
However, it got me thinking, should the version of nu the script was developed for be commented in the script?
Ideally the script should display what versions of nu it works for, but this is unfeasible, probably.

@fdncred
Copy link
Contributor

fdncred commented Feb 19, 2025

Not sure how that could happen really. Most people try to stay updated with the latest changes.

@cosineblast
Copy link

cosineblast commented Feb 19, 2025

When I need my scripts to be versioned correctly (regardless of the language I'm using), I usually use the nix tool to get the right version for the programs the script uses, it's similar to python's venv, but works with most programs.

For instance, if you want to make so that your script uses a specific version of nushell when executed, you can use a nix shebang that refers to a specific commit hash of the nix package repository:

#! /usr/bin/env nix
#! nix shell github:nixos/nixpkgs/21808d22b1cda1898b71cf1a1beb524a97add2c4#nushell --command nu

#                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# This is the commit hash of the nix revision that has the 0.101.0 version of nushell
# you can find the hashes of other versions here:
# https://lazamar.co.uk/nix-versions/?channel=nixpkgs-unstable&package=nushell

print $"hi from (nu --version)"

Then run the script:

$ chmod +x script.nu
$ ./script.nu
hi from 0.101.0

@TheCodeLamp
Copy link
Author

I was just thinking that adding a # created with nu version: 0.102.0 to the top of the file. This was just an idea to make it easier to find the last functional hash for your version.
I've actually solved this issue by just using carapace instead :P

@fdncred
Copy link
Contributor

fdncred commented Feb 19, 2025

Authors are welcome to put that in the scripts they submit.

@hongquan
Copy link
Contributor

Thank you. Those SSH completion changes were made by me. I will update my scripts to have that compatibility note.

fdncred pushed a commit that referenced this issue Feb 24, 2025
This is my response for #1051 

The syntax of this note is inspired by Rust _Cargo.toml_ and Python
_pyproject.toml_.
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

No branches or pull requests

4 participants