NixOS / nix

Nix, the purely functional package manager
https://nixos.org/
GNU Lesser General Public License v2.1
12.4k stars 1.5k forks source link

Unable to open nix-shell and failed to unistall nix #7110

Open MladenLm opened 2 years ago

MladenLm commented 2 years ago

Describe the bug

I am running Ubuntu 22.04.1 LTS and have nix installed (via command sh <(curl -L https://nixos.org/nix/install) --no-daemon), but I always had to use sudo to use nix (I cannot use command nix --help, I have to use sudo nix --help).

After doing pull requests from github for plutus-apps (I am using nix to build dev enviroment for plutus) I am not able to use nix-shell anymore.

I am getting this errors if I try to run sudo nix-shell in plutus-apps folder:

unpacking sources unpacking source archive /nix/store/x4jhvxj104vdciivf1zvijncyd4rd3dp-mpc-1.2.1.tar.gz source root is mpc-1.2.1 setting SOURCE_DATE_EPOCH to timestamp 1603211536 of file mpc-1.2.1/Makefile.vc patching sources configuring fixing libtool script ./build-aux/ltmain.sh configure flags: --disable-dependency-tracking --prefix=/nix/store/kb0rk62036swph91r05160aa6mr445zb-libmpc-1.2.1 --enable-static --disable-shared --enable-static --disable-shared /nix/store/gq99qkmgw3jsa4d9y4ksia5mcyz0w4nk-bootstrap-stage3-stdenv-linux/setup: ./configure: /bin/sh: bad interpreter: No such file or directory error: builder for '/nix/store/kaxq18hbg5bxjmkrlyi714xhl6xmprry-libmpc-1.2.1.drv' failed with exit code 126 error: 1 dependencies of derivation '/nix/store/lqvdvyqdmpqf3dmf4aphawvjdgv6riff-gcc-10.3.0.drv' failed to build error: 1 dependencies of derivation '/nix/store/i53v3dfbddpshq5cz6c4jlqdd4v0ks20-bootstrap-stage4-gcc-wrapper-10.3.0.drv' failed to build error: 1 dependencies of derivation '/nix/store/5cmmfm7zc288azkdl6igb3jfygq5f2nd-stdenv-linux.drv' failed to build error: 1 dependencies of derivation '/nix/store/vvalpqri683mq80mw1a0qag7mlj1z4df-nix-tools-plan-to-nix-pkgs.drv' failed to build (use '--show-trace' to show detailed location information)

If I try to run sudo nix-shell outside of plutus-apps folder I get:

error: getting status of '/home/mladen/default.nix': No such file or directory

* Uninstalling nix

I also tried unistalling nix per instructions found here - https://nixos.org/manual/nix/stable/installation/installing-binary.html#linux

But after running all of the commands I still have nix installed.

After running sudo nix --help I get list of all of the commands

Please let me know if I need to provide additional information in order to get detailed instructions in how to fix this issue.Thank you in advance

A clear and concise description of what you expected to happen.

nix-env --version output

mladen@mladen-System-Product-Name:~$ sudo nix-env --version output nix-env (Nix) 2.6.0

Additional context

Add any other context about the problem here.

** Running sudo nix-shell with trace

trace: To make project.plan-nix for haskell-project a fixed-output derivation but not materialized, set plan-sha256 to the output of the 'calculateMaterializedSha' script in 'passthru'. trace: To materialize project.plan-nix for haskell-project entirely, pass a writable path as the materialized argument and run the 'updateMaterialized' script in 'passthru'. building '/nix/store/kaxq18hbg5bxjmkrlyi714xhl6xmprry-libmpc-1.2.1.drv'... unpacking sources unpacking source archive /nix/store/x4jhvxj104vdciivf1zvijncyd4rd3dp-mpc-1.2.1.tar.gz source root is mpc-1.2.1 setting SOURCE_DATE_EPOCH to timestamp 1603211536 of file mpc-1.2.1/Makefile.vc patching sources configuring fixing libtool script ./build-aux/ltmain.sh configure flags: --disable-dependency-tracking --prefix=/nix/store/kb0rk62036swph91r05160aa6mr445zb-libmpc-1.2.1 --enable-static --disable-shared --enable-static --disable-shared /nix/store/gq99qkmgw3jsa4d9y4ksia5mcyz0w4nk-bootstrap-stage3-stdenv-linux/setup: ./configure: /bin/sh: bad interpreter: No such file or directory error: builder for '/nix/store/kaxq18hbg5bxjmkrlyi714xhl6xmprry-libmpc-1.2.1.drv' failed with exit code 126 error: 1 dependencies of derivation '/nix/store/lqvdvyqdmpqf3dmf4aphawvjdgv6riff-gcc-10.3.0.drv' failed to build error: 1 dependencies of derivation '/nix/store/i53v3dfbddpshq5cz6c4jlqdd4v0ks20-bootstrap-stage4-gcc-wrapper-10.3.0.drv' failed to build error: 1 dependencies of derivation '/nix/store/5cmmfm7zc288azkdl6igb3jfygq5f2nd-stdenv-linux.drv' failed to build error: 1 dependencies of derivation '/nix/store/vvalpqri683mq80mw1a0qag7mlj1z4df-nix-tools-plan-to-nix-pkgs.drv' failed to build

   … while realising the context of path '/nix/store/3d7zqnhrgyj13j48ncdd8366w3zg2x3m-nix-tools-plan-to-nix-pkgs'

   at /nix/store/dv269kw7fp6y81n0k20w9s4a05s2z4f7-source/lib/import-and-filter-project.nix:18:13:

       17|   projectSubDir'' = if projectSubDir == "" then "" else projectSubDir + "/"; # With trailing /
       18|   project = import "${projectNix}${projectSubDir'}";
         |             ^
       19| in project // {

   … while evaluating anonymous lambda

   at /nix/store/dv269kw7fp6y81n0k20w9s4a05s2z4f7-source/lib/import-and-filter-project.nix:5:1:

        4| { pkgs, haskellLib }:
        5| { projectNix, sourceRepos, src }:
         | ^
        6| let

   … from call site

   at /nix/store/dv269kw7fp6y81n0k20w9s4a05s2z4f7-source/overlays/haskell.nix:501:27:

      500|               callProjectResults = callCabalProjectToNix args;
      501|               plan-pkgs = importAndFilterProject {
         |                           ^
      502|                 inherit (callProjectResults) projectNix sourceRepos src;

   … while evaluating the attribute 'hsPkgs'

   at /nix/store/dv269kw7fp6y81n0k20w9s4a05s2z4f7-source/overlays/haskell.nix:527:43:

      526|               project = addProjectAndPackageAttrs rec {
      527|                   inherit (pkg-set.config) hsPkgs;
         |                                           ^
      528|                   inherit pkg-set;

   … while evaluating the attribute 'hsPkgs'

   at /nix/store/dv269kw7fp6y81n0k20w9s4a05s2z4f7-source/overlays/haskell.nix:550:15:

      549|               # Haskell packages
      550|               hsPkgs = final.lib.mapAttrs (packageName: package':
         |               ^
      551|                 if package' == null

   … while evaluating 'cabalProject'

   at /nix/store/dv269kw7fp6y81n0k20w9s4a05s2z4f7-source/overlays/haskell.nix:781:24:

      780|
      781|         cabalProject = args: let p = cabalProject' args;
         |                        ^
      782|             in p.hsPkgs // p;

   … from call site

   at /nix/store/dv269kw7fp6y81n0k20w9s4a05s2z4f7-source/overlays/bootstrap.nix:872:11:

      871|         project =
      872|           final.haskell-nix.cabalProject ({
         |           ^
      873|             caller = "nix-tools-set";

   … while evaluating anonymous lambda

   at /nix/store/dv269kw7fp6y81n0k20w9s4a05s2z4f7-source/overlays/bootstrap.nix:902:29:

      901|             package = project.getPackage "nix-tools";
      902|           in (builtins.map (name: package.getComponent "exe:${name}") [
         |                             ^
      903|             "cabal-to-nix"

   … from call site

   … while evaluating the attribute 'paths' of the derivation 'nix-tools'

   at /nix/store/m2vv0bxfchzrjngx8wi0i7dhzb9q2g50-source/pkgs/stdenv/generic/make-derivation.nix:205:7:

      204|     // (lib.optionalAttrs (attrs ? name || (attrs ? pname && attrs ? version)) {
      205|       name =
         |       ^
      206|         let

   … while evaluating the attribute 'postFetch' of the derivation '01-index.tar.gz-at-2022-02-23T000000Z'

   at /nix/store/m2vv0bxfchzrjngx8wi0i7dhzb9q2g50-source/pkgs/stdenv/generic/make-derivation.nix:205:7:

      204|     // (lib.optionalAttrs (attrs ? name || (attrs ? pname && attrs ? version)) {
      205|       name =
         |       ^
      206|         let

   … while evaluating the attribute 'buildCommand' of the derivation 'hackage-repo-hackage.haskell.org-at-2022-02-23T000000Z'

   at /nix/store/m2vv0bxfchzrjngx8wi0i7dhzb9q2g50-source/pkgs/stdenv/generic/make-derivation.nix:205:7:

      204|     // (lib.optionalAttrs (attrs ? name || (attrs ? pname && attrs ? version)) {
      205|       name =
         |       ^
      206|         let

   … while evaluating anonymous lambda

   at /nix/store/dv269kw7fp6y81n0k20w9s4a05s2z4f7-source/overlays/haskell.nix:219:51:

      218|                 ${final.lib.concatStrings (
      219|                   final.lib.mapAttrsToList (name: index:
         |                                                   ^
      220|                 ''

   … from call site

   at /nix/store/m2vv0bxfchzrjngx8wi0i7dhzb9q2g50-source/lib/attrsets.nix:356:16:

      355|   mapAttrsToList = f: attrs:
      356|     map (name: f name attrs.${name}) (attrNames attrs);
         |                ^
      357|

   … while evaluating anonymous lambda

   at /nix/store/m2vv0bxfchzrjngx8wi0i7dhzb9q2g50-source/lib/attrsets.nix:356:10:

      355|   mapAttrsToList = f: attrs:
      356|     map (name: f name attrs.${name}) (attrNames attrs);
         |          ^
      357|

   … from call site

   … while evaluating the attribute 'buildCommand' of the derivation 'dot-cabal-hackage.haskell.org-at-2022-02-23T000000Z'

   at /nix/store/m2vv0bxfchzrjngx8wi0i7dhzb9q2g50-source/pkgs/stdenv/generic/make-derivation.nix:205:7:

      204|     // (lib.optionalAttrs (attrs ? name || (attrs ? pname && attrs ? version)) {
      205|       name =
         |       ^
      206|         let

   … while evaluating the attribute 'buildCommand' of the derivation 'haskell-project-plan-to-nix-pkgs'

   at /nix/store/m2vv0bxfchzrjngx8wi0i7dhzb9q2g50-source/pkgs/stdenv/generic/make-derivation.nix:205:7:

      204|     // (lib.optionalAttrs (attrs ? name || (attrs ? pname && attrs ? version)) {
      205|       name =
         |       ^
      206|         let

   … while realising the context of a path

   at /nix/store/dv269kw7fp6y81n0k20w9s4a05s2z4f7-source/lib/import-and-filter-project.nix:18:13:

       17|   projectSubDir'' = if projectSubDir == "" then "" else projectSubDir + "/"; # With trailing /
       18|   project = import "${projectNix}${projectSubDir'}";
         |             ^
       19| in project // {

   … while evaluating anonymous lambda

   at /nix/store/dv269kw7fp6y81n0k20w9s4a05s2z4f7-source/lib/import-and-filter-project.nix:5:1:

        4| { pkgs, haskellLib }:
        5| { projectNix, sourceRepos, src }:
         | ^
        6| let

   … from call site

   at /nix/store/dv269kw7fp6y81n0k20w9s4a05s2z4f7-source/overlays/haskell.nix:501:27:

      500|               callProjectResults = callCabalProjectToNix args;
      501|               plan-pkgs = importAndFilterProject {
         |                           ^
      502|                 inherit (callProjectResults) projectNix sourceRepos src;

   … while evaluating the attribute 'hsPkgs.shellFor'

   at /nix/store/dv269kw7fp6y81n0k20w9s4a05s2z4f7-source/overlays/haskell.nix:527:43:

      526|               project = addProjectAndPackageAttrs rec {
      527|                   inherit (pkg-set.config) hsPkgs;
         |                                           ^
      528|                   inherit pkg-set;
SuperSandro2000 commented 2 years ago

If you have sandbox enabled you need to provide the path to /bin/sh

eg not fully correct but gets the job done:

extra-sandbox-paths = $(nix-store -qR "$(nix-build '<nixpkgs>' -A bash)" | xargs echo /bin/sh="$(nix-build '<nixpkgs>