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

Invalid option `--internal-re-exec-version=2.1.3.1' #5008

Open
freeman42x opened this issue Aug 18, 2019 · 11 comments
Open

Invalid option `--internal-re-exec-version=2.1.3.1' #5008

freeman42x opened this issue Aug 18, 2019 · 11 comments

Comments

@freeman42x
Copy link

Steps to reproduce

Expected

Build to succeed.

Actual

[neo@nixos:~/Forks/postgresql-simple-migration-patches]$ stack build --verbose
2.1.3.1 x86_64 hpack-0.31.2
2019-08-18 19:55:01.453556: [debug] Checking for project config at: /home/neo/Forks/postgresql-simple-migration-patches/stack.yaml
2019-08-18 19:55:01.454475: [debug] Loading project config file stack.yaml
2019-08-18 19:55:01.462554: [debug] SELECT COUNT(*) FROM "last_performed" WHERE ("action"=?) AND ("timestamp">=?); [PersistInt64 1,PersistUTCTime 2019-08-17 18:55:01.462516984 UTC]
2019-08-18 19:55:01.463412: [debug] Using package location completions from a lock file
2019-08-18 19:55:01.716822: [debug] PATH is: Just "/home/neo/bin:/run/wrappers/bin:/home/neo/.local/bin:/home/neo/.nix-profile/bin:/etc/profiles/per-user/neo/bin:/nix/var/nix/profiles/default/bin:/run/current-system/sw/bin"
2019-08-18 19:55:01.716996: [debug] Using a nix-shell environment from file: /home/neo/Forks/postgresql-simple-migration-patches/shell.nix
2019-08-18 19:55:01.717263: [debug] Run process: /run/current-system/sw/bin/nix-shell /home/neo/Forks/postgresql-simple-migration-patches/shell.nix --arg ghc "with (import <nixpkgs> {}); haskell.compiler.ghc822" --run "'/nix/store/3gmxrznhj9gb3n2vj0cyp7a529755kwk-stack-2.1.3.1/bin/stack' $STACK_IN_NIX_EXTRA_ARGS '--internal-re-exec-version=2.1.3.1' 'build' '--verbose'"
2.1.3.1 x86_64 hpack-0.31.2
2019-08-18 19:55:04.120020: [debug] Checking for project config at: /home/neo/Forks/postgresql-simple-migration-patches/stack.yaml
2019-08-18 19:55:04.120310: [debug] Loading project config file stack.yaml
2019-08-18 19:55:04.134596: [debug] SELECT COUNT(*) FROM "last_performed" WHERE ("action"=?) AND ("timestamp">=?); [PersistInt64 1,PersistUTCTime 2019-08-17 18:55:04.134297709 UTC]
2019-08-18 19:55:04.136239: [debug] Using package location completions from a lock file
2019-08-18 19:55:04.384929: [debug] PATH is: Just "/nix/store/mn4jdnhkz12a6yd6jg6wvb4mqpxf8q1f-bash-interactive-4.4-p23/bin:/nix/store/qw1ryidvqidw3wgniy2m5369840jblpy-ghc-8.6.4-with-packages/bin:/nix/store/gvshp9yvc6gql09r3cyryj2zgsnfk6br-ghc-8.6.4/bin:/nix/store/ghzg4kg0sjif58smj2lfm2bdvjwim85y-gcc-wrapper-7.4.0/bin:/nix/store/d4n93jn9fdq8fkmkm1q8f32lfagvibjk-gcc-7.4.0/bin:/nix/store/f5wl80zkrd3fc1jxsljmnpn7y02lz6v1-glibc-2.27-bin/bin:/nix/store/d9s1kq1bnwqgxwcvv4zrc36ysnxg8gv7-coreutils-8.30/bin:/nix/store/rbpyfy6413aqpik9aj6p3a2syd1mda68-binutils-wrapper-2.31.1/bin:/nix/store/0y7jmqnj48ikjh37n3dl9kqw9hnn68nq-binutils-2.31.1/bin:/nix/store/f5wl80zkrd3fc1jxsljmnpn7y02lz6v1-glibc-2.27-bin/bin:/nix/store/d9s1kq1bnwqgxwcvv4zrc36ysnxg8gv7-coreutils-8.30/bin:/nix/store/mym79p27mpwc9ll22xfvchb3pizy4khw-remove-references-to/bin:/nix/store/s7p0wfbdfbq307zgifhnh6w8sfjvy64y-patchelf-0.9/bin:/nix/store/gis2bz09gr9sgv1xiimyszcgv2grknpj-ncurses-6.1-20190112/bin:/nix/store/gis2bz09gr9sgv1xiimyszcgv2grknpj-ncurses-6.1-20190112/bin:/nix/store/gvshp9yvc6gql09r3cyryj2zgsnfk6br-ghc-8.6.4/bin:/nix/store/ghzg4kg0sjif58smj2lfm2bdvjwim85y-gcc-wrapper-7.4.0/bin:/nix/store/d4n93jn9fdq8fkmkm1q8f32lfagvibjk-gcc-7.4.0/bin:/nix/store/f5wl80zkrd3fc1jxsljmnpn7y02lz6v1-glibc-2.27-bin/bin:/nix/store/d9s1kq1bnwqgxwcvv4zrc36ysnxg8gv7-coreutils-8.30/bin:/nix/store/rbpyfy6413aqpik9aj6p3a2syd1mda68-binutils-wrapper-2.31.1/bin:/nix/store/0y7jmqnj48ikjh37n3dl9kqw9hnn68nq-binutils-2.31.1/bin:/nix/store/f5wl80zkrd3fc1jxsljmnpn7y02lz6v1-glibc-2.27-bin/bin:/nix/store/d9s1kq1bnwqgxwcvv4zrc36ysnxg8gv7-coreutils-8.30/bin:/nix/store/gvshp9yvc6gql09r3cyryj2zgsnfk6br-ghc-8.6.4/bin:/nix/store/mym79p27mpwc9ll22xfvchb3pizy4khw-remove-references-to/bin:/nix/store/gis2bz09gr9sgv1xiimyszcgv2grknpj-ncurses-6.1-20190112/bin:/nix/store/gis2bz09gr9sgv1xiimyszcgv2grknpj-ncurses-6.1-20190112/bin:/nix/store/d9s1kq1bnwqgxwcvv4zrc36ysnxg8gv7-coreutils-8.30/bin:/nix/store/krhqmaqal0gklh15rs2bwrqzz8mg9lrn-findutils-4.6.0/bin:/nix/store/pmzw4y4465zmq0dc8r4xbwyrqsaj4s70-diffutils-3.7/bin:/nix/store/x1khw8x0465xhkv6w31af75syyyxc65j-gnused-4.7/bin:/nix/store/wnjv27b3j6jfdl0968xpcymlc7chpqil-gnugrep-3.3/bin:/nix/store/vvwggp5mni64yavsfqmbwvm1mn692ssn-gawk-4.2.1/bin:/nix/store/wmxqm38g1y1y7sd7s9vg7an3klffaiyz-gnutar-1.31/bin:/nix/store/ix2q5vnynzfgsi4nqj8pmcbx2kf78wrm-gzip-1.10/bin:/nix/store/b7x2qjfs6k1xk4p74zzs9kyznv29zap6-bzip2-1.0.6.0.1-bin/bin:/nix/store/8n7v99ii7cg694pz0cfch422zvkdqfv4-gnumake-4.2.1/bin:/nix/store/cinw572b38aln37glr0zb8lxwrgaffl4-bash-4.4-p23/bin:/nix/store/kafrvdnj0gadm2p9alh20xiimkmw8xwz-patch-2.7.6/bin:/nix/store/zrazw25gy012ip7vcqddw6lcc393qvcg-xz-5.2.4-bin/bin:/home/neo/bin:/run/wrappers/bin:/home/neo/.local/bin:/home/neo/.nix-profile/bin:/etc/profiles/per-user/neo/bin:/nix/var/nix/profiles/default/bin:/run/current-system/sw/bin"
2019-08-18 19:55:04.385137: [debug] Using a nix-shell environment from file: /home/neo/Forks/postgresql-simple-migration-patches/shell.nix
2019-08-18 19:55:04.386245: [debug] Run process: /run/current-system/sw/bin/nix-shell /home/neo/Forks/postgresql-simple-migration-patches/shell.nix --arg ghc "with (import <nixpkgs> {}); haskell.compiler.ghc822" --run "'/nix/store/3gmxrznhj9gb3n2vj0cyp7a529755kwk-stack-2.1.3.1/bin/stack' $STACK_IN_NIX_EXTRA_ARGS '--internal-re-exec-version=2.1.3.1' '--internal-re-exec-version=2.1.3.1' 'build' '--verbose'"
Invalid option `--internal-re-exec-version=2.1.3.1'

Usage: stack [--help] [--version] [--numeric-version] [--hpack-numeric-version]
             [--docker*] [--nix*] ([--verbosity VERBOSITY] | [-v|--verbose] |
             [--silent]) [--[no-]time-in-log] [--stack-root STACK-ROOT]
             [--work-dir WORK-DIR] [--[no-]system-ghc] [--[no-]install-ghc]
             [--arch ARCH] [--ghc-variant VARIANT] [--ghc-build BUILD]
             [-j|--jobs JOBS] [--extra-include-dirs DIR] [--extra-lib-dirs DIR]
             [--with-gcc PATH-TO-GCC] [--with-hpack HPACK]
             [--[no-]skip-ghc-check] [--[no-]skip-msys] [--local-bin-path DIR]
             [--[no-]modify-code-page] [--[no-]allow-different-user]
             [--[no-]dump-logs] [--color|--colour WHEN] [--resolver RESOLVER]
             [--compiler COMPILER] [--[no-]terminal]
             [--stack-colors|--stack-colours STYLES] [--terminal-width INT]
             [--stack-yaml STACK-YAML] [--lock-file ARG] COMMAND|FILE

Stack version

$ stack --version
2.1.3.1 x86_64 hpack-0.31.2

Method of installation

Installed using Nix.

@mattaudesse
Copy link
Member

As with #5007 I believe this is related to #5000 as well.

@srghma
Copy link

srghma commented Dec 25, 2019

I have reproduced this error in input-output-hk/haskell.nix#384 (comment)

The problem is that

/nix/store/dj2ylmvx2c288h51yx8ljg4h6bh5vyla-nix-2.3/bin/nix-shell --pure /home/srghma/projects/generate-all-tests/stack-shell.nix --arg ghc "with (import <nixpkgs> {}); haskell.compiler.ghc865" --run "'/nix/store/f9lqnmvfbq9367jazh14qv147aawlphb-stack-2.1.3.1/bin/stack' $STACK_IN_NIX_EXTRA_ARGS '--internal-re-exec-version=2.1.3.1' '--internal-re-exec-version=2.1.3.1' 'build' '--verbose' '--only-configure'"

is running two times recursively

because nix-shell is executed with --pure, stack is not seeing the STACK_IN_NIX_SHELL env variable, passes --internal-re-exec-version=2.1.3.1 TWO times, and that's why the parsing error is thrown on second time

@srghma
Copy link

srghma commented Dec 25, 2019

possible fix

IF STACK_IN_NIX_SHELL is present AND nix-shell will be called with pure THEN add export STACK_IN_NIX_SHELL=true; to command

e.g.

/nix/store/dj2ylmvx2c288h51yx8ljg4h6bh5vyla-nix-2.3/bin/nix-shell --pure /home/srghma/projects/generate-all-tests/stack-shell.nix --arg ghc "with (import <nixpkgs> {}); haskell.compiler.ghc865" --run "export STACK_IN_NIX_SHELL=true; '/nix/store/f9lqnmvfbq9367jazh14qv147aawlphb-stack-2.1.3.1/bin/stack' '--internal-re-exec-version=2.1.3.1' 'build' '--verbose' '--only-configure'"


Update, actually maybe it's better to always to call it with export STACK_IN_NIX_SHELL=true;

@srghma
Copy link

srghma commented Dec 25, 2019

The other way is to ask users to add STACK_IN_NIX_SHELL=true to their mkDerivation

this worked for me too (I'm using haskell.nix)

hsPkgs.shellFor {
  # Shell will provide the dependencies, but not packages themselves.
  packages = ps: with ps; [ generate-all-tests ];
  # This adds cabal-install to the shell, which helps tests because
  # they use a nix-shell --pure. Normally you would BYO cabal-install.
  buildInputs = with pkgs; [ cabal-install nix zlib ];
  exactDeps = true;
  STACK_IN_NIX_SHELL = true;
}

srghma added a commit to srghma/stack that referenced this issue Dec 25, 2019
…on" error when using "nix" with options "enable: true", "pure: true", "shell-file: .." -> prevent entering "nix-shell --pure" recursively by exporting STACK_IN_NIX_SHELL properly
srghma added a commit to srghma/stack that referenced this issue Dec 25, 2019
…on" error when using "nix" with options "enable: true", "pure: true", "shell-file: .." -> prevent entering "nix-shell --pure" recursively by exporting STACK_IN_NIX_SHELL properly
srghma added a commit to srghma/stack that referenced this issue Dec 25, 2019
…on" error when using "nix" with options "enable: true", "pure: true", "shell-file: .." -> prevent entering "nix-shell --pure" recursively by exporting STACK_IN_NIX_SHELL properly
srghma added a commit to srghma/stack that referenced this issue Dec 26, 2019
…on" error when using "nix" with options "enable: true", "pure: true", "shell-file: .." -> prevent entering "nix-shell --pure" recursively by exporting STACK_IN_NIX_SHELL properly
srghma added a commit to srghma/stack that referenced this issue Feb 4, 2020
…on" error when using "nix" with options "enable: true", "pure: true", "shell-file: .." -> dont set inNixShellEnvVar second time if shell.nix is not used
@qrilka
Copy link
Contributor

qrilka commented Feb 5, 2020

@razvan-flavius-panda I think the problem in your case is (as I said it in #5131 (comment) ) that your shell file doesn't use buildStackProject but that one is required for proper integration.
I think there's not so much to fix on Stack's side about it.

@freeman42x
Copy link
Author

I just run into the same issue again on a different project.
The shell.nix is the following: https://github.com/fairy-tale-agi-solutions/haskell-editor-setup/blob/master/shell.nix
@srghma I do not know what changes I would need to make to it to add: STACK_IN_NIX_SHELL=true to it.

@srghma
Copy link

srghma commented Jun 20, 2020

change

drv.env.overrideAttrs (shellEnv: {
  buildInputs = shellEnv.buildInputs ++ [
    nwjs-sdk
    atom
    git
    cabal2nix
    nixpkgsCabal3.haskell.packages.${ghcVersion}.cabal-install
    hie
    (vscode-utils.vscodeEnv {
      #usually this path go to tmp but feel free to change it wherever you think it is good place to the "fake" global folder
      #putting it on empty string will leave the default one.
      user-data-dir = "./.vscode-globalUserData";
      #this file will be updated/created automaticly by vscode in result of using vscode GUI to install/uninstall extensions(can be changed manually to)
      mutableExtensionsFile = ./mutable-extensions.nix;
      #this extensions will be stored in the nix store and cannot be modified from vscode GUI
      nixExtensions = [
        { name = "vscode-hie-server"; publisher = "alanz"; version = "0.0.40"; sha256 = "1cmlgidjma41s5zq5161gcxxmk5lfzcm8dvznls04y5l7q9b0gca";  }
        { name = "language-haskell"; publisher = "justusadam"; version = "3.2.0"; sha256 = "190h1hky2yy5n00ncqf15mmaizgpm3w9pzvasmi2gangpg4qb6y5";  }
      ];

      # configuration for settings files- those will be overrides/create over the one in .vscode folder
      # settings = {};
      # keybindings ={};
    })
  ];

  shellHook = ''
  '';
})

to

drv.env.overrideAttrs (shellEnv: {
  buildInputs = shellEnv.buildInputs ++ [
    nwjs-sdk
    atom
    git
    cabal2nix
    nixpkgsCabal3.haskell.packages.${ghcVersion}.cabal-install
    hie
    (vscode-utils.vscodeEnv {
      #usually this path go to tmp but feel free to change it wherever you think it is good place to the "fake" global folder
      #putting it on empty string will leave the default one.
      user-data-dir = "./.vscode-globalUserData";
      #this file will be updated/created automaticly by vscode in result of using vscode GUI to install/uninstall extensions(can be changed manually to)
      mutableExtensionsFile = ./mutable-extensions.nix;
      #this extensions will be stored in the nix store and cannot be modified from vscode GUI
      nixExtensions = [
        { name = "vscode-hie-server"; publisher = "alanz"; version = "0.0.40"; sha256 = "1cmlgidjma41s5zq5161gcxxmk5lfzcm8dvznls04y5l7q9b0gca";  }
        { name = "language-haskell"; publisher = "justusadam"; version = "3.2.0"; sha256 = "190h1hky2yy5n00ncqf15mmaizgpm3w9pzvasmi2gangpg4qb6y5";  }
      ];

      # configuration for settings files- those will be overrides/create over the one in .vscode folder
      # settings = {};
      # keybindings ={};
    })
  ];
  STACK_IN_NIX_SHELL = true;
  shellHook = ''
  '';
})

@freeman42x
Copy link
Author

freeman42x commented Jun 21, 2020

I did that, and the build progressed further, run into another issue regarding zlib.
After adding zlib to stack.yaml, it went back to failing with the same error, and now whatever I do, the error is cached. I deleted the entire stack folder in home and the stack work folders, and there is still some cache somewhere that instantly gives the error in this ticket no matter what stack.yaml changes I make to nix.

If anyone wants to give building it a try, it is the branch here: https://github.com/fairy-tale-agi-solutions/haskell-editor-setup/tree/stack-fk

@srghma
Copy link

srghma commented Jun 21, 2020

I see you added zlib to packages https://github.com/fairy-tale-agi-solutions/haskell-editor-setup/blob/3faeb4593ac138a1d619c9e2cb19ffbab04233ef/stack.yaml#L204-L206 and disabled shell-file: "shell.nix" option

That's right, you can use either packages OR shell-file

If you opt to shell-file - you probably should add

  zlib.dev
  zlib.out

to you build inputs buildInputs.

I had the impression that shell-file fixed --internal-re-exec-version=2.1.3.1 issue for you (I did that, and the build progressed further), probably you should enable it again and try with zlib in it

@freeman42x
Copy link
Author

There is nothing I can do about it currently since it just errors whatever I change, and I dedicated enough time to it.

@domenkozar
Copy link
Contributor

I wonder if #5524 fixes this too?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants