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

Remove obsolete jq --argfile option #43

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

sixtysecrun
Copy link

The jq option --argfile was deprecated for a long time and it was finally removed from jq 1.7, which is causing the following error in activation script:

jq: Unknown option --argfile

The alternative is to use --slurpfile option which basically behaves in a same way.

References:

The jq option --argfile was deprecated for a long time and it was
finally removed from jq 1.7, which is causing the following error in
activation script:

jq: Unknown option --argfile

The alternative is to use --slurpfile option which basically behaves in
a same way.

References:
- jqlang/jq#2768
- https://github.com/jqlang/jq/releases/tag/jq-1.7
@ParetoOptimalDev
Copy link

Until this is merged anyone who needs it sooner can use this as their homeage input:

    homeage = {
      url = "github:jordanisaacs/homeage/pull/43/head";
      inputs.nixpkgs.follows = "nixpkgs";
    };

@ParetoOptimalDev
Copy link

I'm not sure if related to this or I have another error, but I get:

Nov 01 12:30:19 tower2 hm-activate-pareto[10302]: jq: error (at <stdin>:1): Cannot index array with string "path"

I think it is at this piece of code:

path=$(echo "$c" | ${jq} --raw-output '.path')

I mention this since I'm unsure if slurpfile may have different behavior causing this to now be an array rather than a string.

@ParetoOptimalDev
Copy link

Yes, this piece has to be updated and maybe other consumers that used -arg-file it seems:


    --argfile variable-name filename:

Do not use. Use --slurpfile instead.

(This option is like --slurpfile, but when the file has just one text, then that is used, else an array of texts is used as in --slurpfile.)

I think this took advantage of the file having one text. I don't know jq very well but I think that means here it was taking advantage of the single line behavior and it needs to be updated to .path[0].

@ParetoOptimalDev
Copy link

This prevents it from failing but needs to be changed to loop over all paths, right now it just cleans up [0]:

modified   module/default.nix
@@ -140,9 +140,11 @@ with lib; let
       ${pkgs.gnused}/bin/sed \
         "s/\$UID/$(id -u)/g" |
       while IFS=$"\n" read -r c; do
-        path=$(echo "$c" | ${jq} --raw-output '[0].path')
-        symlinks=$(echo "$c" | ${jq} --raw-output '.symlinks[]')
-        copies=$(echo "$c" | ${jq} --raw-output '.copies[]')
+        echo "c is: $c"
+        echo "debug: $(echo "$c" | ${jq} --raw-output '.[0]')"
+        path=$(echo "$c" | ${jq} --raw-output '.[0].path')
+        symlinks=$(echo "$c" | ${jq} --raw-output '.[0].symlinks[]')
+        copies=$(echo "$c" | ${jq} --raw-output '.[0].copies[]')

@andrewhamon
Copy link

@jordanisaacs it would be great to get this merged! I'm seeing this same issue.

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.

3 participants