How to open a nix-shell session

I understand that’s quite frustrating. I agree, that seems like nix-shell is not there. nix-shell is provided by the same derivation as nix and nix-env on my system, so it seems like something has gone wrong in an unusual way, leading to either the nix derivation to be missing or to the executables provided are not valid for some reason. This leads me to have more questions

  1. What’s in the ~/.nix-profile/bin directory? (just in case ~ means home directory, or /home/DrTwentyOne for example)
  2. What version of Ubuntu are you using?
  3. What architecture are you using (uname -p will give you this info)?
  4. Is the /nix directory available?
  5. is the nix executable available somewhere in the /nix/store directory (find /nix/store -name nix can help with this)
2 Likes

Yeah a bit frustrating but I’m in no hurry and generally very patient :blush:
1.nix nix-collect-garbage nix-env nix-prefetch-url
nix-build nix-copy-closure nix-hash nix-shell
nix-channel nix-daemon nix-instantiate nix-store

  1. Ubuntu 20

  2. x86_64

  3. Yes, it has “store var” in it.

  4. If I type “find /nix/store -name nix” I get a big set of lines that looks like " /nix/store/4vz8sh9ngx34ivi0bw5hlycxdhvy5hvz-nix-2.3.7/share/doc/nix"
    and at the end I get “find: Failed to restore initial working directory: /root: Permission denied”

And by the way, if I copy paste in this user the command I find on the Cardano website to install nix (curl https://nixos.org/nix/install > install-nix.sh), I also get permission denied. But when I install it with the command line given by the official nix website (curl -L https://nixos.org/nix/install | sh) it works. I think there must be something seriously wrong with permission issues.

Okay, so it looks to me like nix managed to install itself, but the executables that it installed and available on the path, but are not possible to run. I’m not as familiar with how to debug this, but I have a few ideas.

I usually find that executable issues like this come up for a few reasons:

  1. Incorrect binary architecture or format. You can inspect this with some bash like:
 ➜ file $(readlink -f $(which nix))
/nix/store/vfahm96nmi8layj9cjwnv3w57xdf3jb4-nix-2.3.4/bin/nix: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /nix/store/an6bdv4phxsz14q2sk57iscl2dc7bnj1-glibc-2.30/lib/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=e8534c26cadeebff98a2ea0ed2630ccd2f913b37, not stripped

We’re specifically looking for it to say ELF 64-bit LSB executable and mention Linux as well.
2. The executable bit is not set. We can check this in bash as well:

➜ stat $(readlink -f $(which nix))
  File: /nix/store/vfahm96nmi8layj9cjwnv3w57xdf3jb4-nix-2.3.4/bin/nix
  Size: 1816736   	Blocks: 3552       IO Block: 4096   regular file
Device: 1ch/28d	Inode: 15791231    Links: 2
Access: (0555/-r-xr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2020-07-21 15:57:20.038455017 -0500
Modify: 1969-12-31 18:00:01.000000000 -0600
Change: 2020-06-05 13:13:19.346856373 -0500
 Birth: 2020-04-20 08:34:56.949489056 -0500

Here, we look at the second field within the first access member, looking for the “r” and “x” characters. Note that the permissions are duplicated 3 times; once for permissions of the file owner (root in this case), once for the group of the file (also root), and once for all other user accounts.
3. Shared libraries are missing. We can check this with bash too:

➜ ldd $(which nix)
	linux-vdso.so.1 (0x00007ffeb4bf8000)
	libsodium.so.23 => /nix/store/83a0cva7q7jgf303yv466n6v8rhx6isd-libsodium-1.0.18/lib/libsodium.so.23 (0x00007f16759f2000)
	libeditline.so.1 => /nix/store/cv6lyjsc721nv34g1nnb50zfd8zbj6xd-editline-1.17.0/lib/libeditline.so.1 (0x00007f16759e6000)
	libboost_context.so.1.69.0 => /nix/store/vfahm96nmi8layj9cjwnv3w57xdf3jb4-nix-2.3.4/lib/libboost_context.so.1.69.0 (0x00007f16759e0000)
	libboost_thread.so.1.69.0 => /nix/store/vfahm96nmi8layj9cjwnv3w57xdf3jb4-nix-2.3.4/lib/libboost_thread.so.1.69.0 (0x00007f16759b2000)
	libboost_system.so.1.69.0 => /nix/store/vfahm96nmi8layj9cjwnv3w57xdf3jb4-nix-2.3.4/lib/libboost_system.so.1.69.0 (0x00007f16759ad000)
	libnixexpr.so => /nix/store/vfahm96nmi8layj9cjwnv3w57xdf3jb4-nix-2.3.4/lib/libnixexpr.so (0x00007f1675864000)
	libgc.so.1 => /nix/store/phvdmwbnqmi8ibjsyzadjw6lblfscrsg-boehm-gc-8.0.4/lib/libgc.so.1 (0x00007f16755e2000)
	libnixmain.so => /nix/store/vfahm96nmi8layj9cjwnv3w57xdf3jb4-nix-2.3.4/lib/libnixmain.so (0x00007f16755ae000)
	libnixstore.so => /nix/store/vfahm96nmi8layj9cjwnv3w57xdf3jb4-nix-2.3.4/lib/libnixstore.so (0x00007f167535d000)
	libnixutil.so => /nix/store/vfahm96nmi8layj9cjwnv3w57xdf3jb4-nix-2.3.4/lib/libnixutil.so (0x00007f16752a6000)
	libstdc++.so.6 => /nix/store/jy89v2q2zv074mvw91jgqcvkmk7yqx69-gcc-9.3.0-lib/lib/libstdc++.so.6 (0x00007f16750c5000)
	libm.so.6 => /nix/store/an6bdv4phxsz14q2sk57iscl2dc7bnj1-glibc-2.30/lib/libm.so.6 (0x00007f1674f83000)
	libgcc_s.so.1 => /nix/store/an6bdv4phxsz14q2sk57iscl2dc7bnj1-glibc-2.30/lib/libgcc_s.so.1 (0x00007f1674f69000)
	libpthread.so.0 => /nix/store/an6bdv4phxsz14q2sk57iscl2dc7bnj1-glibc-2.30/lib/libpthread.so.0 (0x00007f1674f48000)
	libc.so.6 => /nix/store/an6bdv4phxsz14q2sk57iscl2dc7bnj1-glibc-2.30/lib/libc.so.6 (0x00007f1674d89000)
	/nix/store/an6bdv4phxsz14q2sk57iscl2dc7bnj1-glibc-2.30/lib/ld-linux-x86-64.so.2 => /nix/store/an6bdv4phxsz14q2sk57iscl2dc7bnj1-glibc-2.30/lib64/ld-linux-x86-64.so.2 (0x00007f1675a50000)
	librt.so.1 => /nix/store/an6bdv4phxsz14q2sk57iscl2dc7bnj1-glibc-2.30/lib/librt.so.1 (0x00007f1674d7f000)
	libdl.so.2 => /nix/store/an6bdv4phxsz14q2sk57iscl2dc7bnj1-glibc-2.30/lib/libdl.so.2 (0x00007f1674d78000)
	libcrypto.so.1.1 => /nix/store/g39cbah5km1rm4x0b884z2zr6ihy1p4b-openssl-1.1.1d/lib/libcrypto.so.1.1 (0x00007f1674a92000)
	libsqlite3.so.0 => /nix/store/d107q6qzjb8a7zxng5ipnmhzhjsa63v4-sqlite-3.31.1/lib/libsqlite3.so.0 (0x00007f1674970000)
	libbz2.so.1 => /nix/store/66bmzz2vhnrqwbgpp7mki4dbvqgyjhz3-bzip2-1.0.6.0.1/lib/libbz2.so.1 (0x00007f167495b000)
	libcurl.so.4 => /nix/store/8zxiz4i59h1c7qfk5zg23x1bfzzyykiq-curl-7.68.0/lib/libcurl.so.4 (0x00007f16748cd000)
	libaws-cpp-sdk-transfer.so => /nix/store/9v1c73ad4hb75mhqxs38hw6z92x4hdb8-aws-sdk-cpp-1.7.90/lib/libaws-cpp-sdk-transfer.so (0x00007f167489a000)
	libaws-cpp-sdk-s3.so => /nix/store/9v1c73ad4hb75mhqxs38hw6z92x4hdb8-aws-sdk-cpp-1.7.90/lib/libaws-cpp-sdk-s3.so (0x00007f16745c2000)
	libaws-cpp-sdk-core.so => /nix/store/9v1c73ad4hb75mhqxs38hw6z92x4hdb8-aws-sdk-cpp-1.7.90/lib/libaws-cpp-sdk-core.so (0x00007f1674499000)
	libseccomp.so.2 => /nix/store/pj478xk8048jasr40rji7ba86qwg4q3g-libseccomp-2.4.3-lib/lib/libseccomp.so.2 (0x00007f167444a000)
	liblzma.so.5 => /nix/store/zf40yxz49x74j777pn6hgk11xw0mgcv8-xz-5.2.5/lib/liblzma.so.5 (0x00007f1674420000)
	libbrotlienc.so.1 => /nix/store/mnva81a151jssss3npr3kc948qml9jja-brotli-1.0.7-lib/lib/libbrotlienc.so.1 (0x00007f1674386000)
	libbrotlidec.so.1 => /nix/store/mnva81a151jssss3npr3kc948qml9jja-brotli-1.0.7-lib/lib/libbrotlidec.so.1 (0x00007f1674377000)
	libz.so.1 => /nix/store/zsr1dksfh97yvb49k3rni00q5lppd9pd-zlib-1.2.11/lib/libz.so.1 (0x00007f167435a000)
	libnghttp2.so.14 => /nix/store/5qqcybnrmy01ddwmx9dym1qxkc7ivncn-nghttp2-1.40.0-lib/lib/libnghttp2.so.14 (0x00007f167432f000)
	libssh2.so.1 => /nix/store/537b2ywpxmshxk9q58pc1770bjnk1syq-libssh2-1.9.0/lib/libssh2.so.1 (0x00007f16742ef000)
	libssl.so.1.1 => /nix/store/g39cbah5km1rm4x0b884z2zr6ihy1p4b-openssl-1.1.1d/lib/libssl.so.1.1 (0x00007f1674259000)
	libgssapi_krb5.so.2 => /nix/store/h3jypkrycrji4dn77472slapvsswpk5v-libkrb5-1.18/lib/libgssapi_krb5.so.2 (0x00007f1674206000)
	libkrb5.so.3 => /nix/store/h3jypkrycrji4dn77472slapvsswpk5v-libkrb5-1.18/lib/libkrb5.so.3 (0x00007f167412a000)
	libk5crypto.so.3 => /nix/store/h3jypkrycrji4dn77472slapvsswpk5v-libkrb5-1.18/lib/libk5crypto.so.3 (0x00007f16740fa000)
	libcom_err.so.3 => /nix/store/h3jypkrycrji4dn77472slapvsswpk5v-libkrb5-1.18/lib/libcom_err.so.3 (0x00007f16740f4000)
	libaws-c-event-stream.so.0unstable => /nix/store/ycj4pxkzw29g41l9w8bfnvlsfafp6g26-aws-c-event-stream-0.1.1/lib/libaws-c-event-stream.so.0unstable (0x00007f16740e2000)
	libaws-checksums.so => /nix/store/ppbdv2jvh5dvlwsqpipgy9fbjff54hh7-aws-checksums-0.1.5/lib/libaws-checksums.so (0x00007f16740d4000)
	libbrotlicommon.so.1 => /nix/store/mnva81a151jssss3npr3kc948qml9jja-brotli-1.0.7-lib/lib/libbrotlicommon.so.1 (0x00007f16740af000)
	libkrb5support.so.0 => /nix/store/h3jypkrycrji4dn77472slapvsswpk5v-libkrb5-1.18/lib/libkrb5support.so.0 (0x00007f16740a0000)
	libkeyutils.so.1 => /nix/store/d3n1a9hv1vzlbvvv2fhg1p3asclmy4xh-keyutils-1.6.1-lib/lib/libkeyutils.so.1 (0x00007f1674099000)
	libresolv.so.2 => /nix/store/an6bdv4phxsz14q2sk57iscl2dc7bnj1-glibc-2.30/lib/libresolv.so.2 (0x00007f1674080000)

In this, we’re looking for any line that is missing a fle path. If it’s missing any of these deps, we probably have to add that dep to ubuntu. (at least temporarily, as nix should be able to install all of it’s own deps).

Here is what I have run and what I got:

file $(readlink -f $(which nix))
readlink: missing operand
Try ‘readlink --help’ for more information.
Usage: file [-bcCdEhikLlNnprsSvzZ0] [–apple] [–extension] [–mime-encoding]
[–mime-type] [-e ] [-F ] [-f ]
[-m ] [-P <parameter=value>] …
file -C [-m ]
file [–help]

stat $(readlink -f $(which nix))
readlink: missing operand

Try ‘readlink --help’ for more information.

stat: missing operand

Try ‘stat --help’ for more information.

ldd $(which nix)
ldd: missing file arguments

Try `ldd --help’ for more information.

But honestly I do not think the files are corrupt. Then why, even before nix installed, I get “permission denied” on “curl https://nixos.org/nix/install > install-nix.sh” in a sudo user?

I did not expect to get this diagnosis, at least did not expect that there is something wrong with my Virtual Private Server, I rather thought I was myself missing out on something. I would think this is rather plausible since it’s my first time using ubuntu, unless I’m really unlucky

you’re missing an $

readlink -f $(which nix))
2 Likes

I don’t think he suggests that the files are “corrupt”. Rather that, for a reason or another, they are of a wrong format, whether because of the architecture, because of execution rights, or maybe an issue of missing pre-requisite libraries.

And also sometimes when investing it is nice to reassure oneself that everything is in order on one side of the things. That helps moving forward a new hypothesis, and not letting the doubt in one area.

3 Likes

Following on what jonringer and stphrolland said, I’m trying to narrow down where the problem lies. It’s entirely possible that the files are corrupt, but as stphrolland said, I don’t think that’s what’s going on here. Since I’m not entirely sure what went wrong with the sub-shell substitutions that I posted, let’s use the file path you posted in the reply before that for the debugging. So, from the user account (which may have been the issue):

  1. This one would look like file ~/.nix-profile/bin/nix
  2. And this one is stat ~/.nix-profile/bin/nix
  3. And finally ldd ~/.nix-profile/bin/nix

If that’s giving you an error such as “file not found”, substitute a path that ends in bin/nix for the find command you ran earlier.

1 Like

I did not get any “file not found” error. Here are the results:

/home/drtwentyone/.nix-profile/bin/nix: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /nix/store/xg6ilb9g9zhi2zg1dpi4zcp288rhnvns-glibc-2.30/lib/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=0ad660d3ca2ab561d0ddd97fd9abeb239e2a9dae, not stripped

Usage: nix … …

Common flags:
–debug enable debug output
–help show usage information
–help-config show configuration options
–no-net disable substituters and consider all previously downloaded files up-to-date
–option set a Nix configuration option (overriding nix.conf)
-L, --print-build-logs print full build logs on stderr
–quiet decrease verbosity level
-v, --verbose increase verbosity level
–version show version information

In addition, most configuration settings can be overriden using ‘– ’.
Boolean settings can be overriden using ‘–’ or ‘–no-’. See ‘nix
–help-config’ for a list of configuration settings.

Available commands:
add-to-store add a path to the Nix store
build build a derivation or fetch a store path
cat-nar print the contents of a file inside a NAR file
cat-store print the contents of a store file on stdout
copy copy paths between Nix stores
copy-sigs copy path signatures from substituters (like binary caches)
doctor check your system for potential problems
dump-path dump a store path to stdout (in NAR format)
edit open the Nix expression of a Nix package in $EDITOR
eval evaluate a Nix expression
hash-file print cryptographic hash of a regular file
hash-path print cryptographic hash of the NAR serialisation of a path
log show the build log of the specified packages or paths, if available
ls-nar show information about the contents of a NAR file
ls-store show information about a store path
optimise-store replace identical files in the store by hard links
path-info query information about store paths
ping-store test whether a store can be opened
repl start an interactive environment for evaluating Nix expressions
run run a shell in which the specified packages are available
search query available packages
show-config show the Nix configuration
show-derivation show the contents of a store derivation
sign-paths sign the specified paths
to-base16 convert a hash to base-16 representation
to-base32 convert a hash to base-32 representation
to-base64 convert a hash to base-64 representation
to-sri convert a hash to SRI representation
upgrade-nix upgrade Nix to the latest stable version
verify verify the integrity of store paths
why-depends show why a package has another package in its closure

Note: this program is EXPERIMENTAL and subject to change.

Usage: nix … …

Common flags:
–debug enable debug output
–help show usage information
–help-config show configuration options
–no-net disable substituters and consider all previously downloaded files up-to-date
–option set a Nix configuration option (overriding nix.conf)
-L, --print-build-logs print full build logs on stderr
–quiet decrease verbosity level
-v, --verbose increase verbosity level
–version show version information

In addition, most configuration settings can be overriden using ‘– ’.
Boolean settings can be overriden using ‘–’ or ‘–no-’. See ‘nix
–help-config’ for a list of configuration settings.

Available commands:
add-to-store add a path to the Nix store
build build a derivation or fetch a store path
cat-nar print the contents of a file inside a NAR file
cat-store print the contents of a store file on stdout
copy copy paths between Nix stores
copy-sigs copy path signatures from substituters (like binary caches)
doctor check your system for potential problems
dump-path dump a store path to stdout (in NAR format)
edit open the Nix expression of a Nix package in $EDITOR
eval evaluate a Nix expression
hash-file print cryptographic hash of a regular file
hash-path print cryptographic hash of the NAR serialisation of a path
log show the build log of the specified packages or paths, if available
ls-nar show information about the contents of a NAR file
ls-store show information about a store path
optimise-store replace identical files in the store by hard links
path-info query information about store paths
ping-store test whether a store can be opened
repl start an interactive environment for evaluating Nix expressions
run run a shell in which the specified packages are available
search query available packages
show-config show the Nix configuration
show-derivation show the contents of a store derivation
sign-paths sign the specified paths
to-base16 convert a hash to base-16 representation
to-base32 convert a hash to base-32 representation
to-base64 convert a hash to base-64 representation
to-sri convert a hash to SRI representation
upgrade-nix upgrade Nix to the latest stable version
verify verify the integrity of store paths
why-depends show why a package has another package in its closure

Note: this program is EXPERIMENTAL and subject to change.

The ldd output doesn’t look right, should be something like:

$ ldd /run/current-system/sw/bin/nix
	linux-vdso.so.1 (0x00007fff82774000)
	libsodium.so.23 => /nix/store/3irnbwlmvps8c2hhx191pvzslzrzcn9n-libsodium-1.0.18/lib/libsodium.so.23 (0x00007faf48e64000)
	libeditline.so.1 => /nix/store/2vinib19ya9flrvihzylc3qjpvyc493p-editline-1.17.0/lib/libeditline.so.1 (0x00007faf48e58000)
	libboost_context.so.1.69.0 => /nix/store/sn70b9dsjr687618riaklqxjrwysylsv-nix-2.3.7/lib/libboost_context.so.1.69.0 (0x00007faf48e52000)
    ...

I’m running nixos (multi-user), so the nix cli is installed at /run/current-system/sw/bin/

You are correct. I copied the second command twice
I just rechecked it, this is what I get:
“ldd ~/.nix-profile/bin/nix”
linux-vdso.so.1 (0x00007fff88fb7000)
libsodium.so.23 => /nix/store/r8k4rjkq5sdz648abm832dnilai176sj-libsodium-1.0.18/lib/libsodium.so.23 (0x00007f30d527d000)
libeditline.so.1 => /nix/store/xvs265xd17acblb2xw83cqxlzpsqk3w0-editline-1.17.0/lib/libeditline.so.1 (0x00007f30d5271000)
libboost_context.so.1.69.0 => /nix/store/4vz8sh9ngx34ivi0bw5hlycxdhvy5hvz-nix-2.3.7/lib/libboost_context.so.1.69.0 (0x00007f30d526b000)
libboost_thread.so.1.69.0 => /nix/store/4vz8sh9ngx34ivi0bw5hlycxdhvy5hvz-nix-2.3.7/lib/libboost_thread.so.1.69.0 (0x00007f30d523d000)
libboost_system.so.1.69.0 => /nix/store/4vz8sh9ngx34ivi0bw5hlycxdhvy5hvz-nix-2.3.7/lib/libboost_system.so.1.69.0 (0x00007f30d5236000)
libnixexpr.so => /nix/store/4vz8sh9ngx34ivi0bw5hlycxdhvy5hvz-nix-2.3.7/lib/libnixexpr.so (0x00007f30d50ef000)
libgc.so.1 => /nix/store/krbh984z3lpvj614gfp2ss59b8ss2nq1-boehm-gc-8.0.4/lib/libgc.so.1 (0x00007f30d4e6d000)
libnixmain.so => /nix/store/4vz8sh9ngx34ivi0bw5hlycxdhvy5hvz-nix-2.3.7/lib/libnixmain.so (0x00007f30d4e39000)
libnixstore.so => /nix/store/4vz8sh9ngx34ivi0bw5hlycxdhvy5hvz-nix-2.3.7/lib/libnixstore.so (0x00007f30d4be8000)
libnixutil.so => /nix/store/4vz8sh9ngx34ivi0bw5hlycxdhvy5hvz-nix-2.3.7/lib/libnixutil.so (0x00007f30d4b31000)
libstdc++.so.6 => /nix/store/danv012gh0aakh8xnk2b35vahklz72mk-gcc-9.2.0-lib/lib/libstdc++.so.6 (0x00007f30d494f000)
libm.so.6 => /nix/store/xg6ilb9g9zhi2zg1dpi4zcp288rhnvns-glibc-2.30/lib/libm.so.6 (0x00007f30d480f000)
libgcc_s.so.1 => /nix/store/xg6ilb9g9zhi2zg1dpi4zcp288rhnvns-glibc-2.30/lib/libgcc_s.so.1 (0x00007f30d47f5000)
libpthread.so.0 => /nix/store/xg6ilb9g9zhi2zg1dpi4zcp288rhnvns-glibc-2.30/lib/libpthread.so.0 (0x00007f30d47d4000)
libc.so.6 => /nix/store/xg6ilb9g9zhi2zg1dpi4zcp288rhnvns-glibc-2.30/lib/libc.so.6 (0x00007f30d4615000)
/nix/store/xg6ilb9g9zhi2zg1dpi4zcp288rhnvns-glibc-2.30/lib/ld-linux-x86-64.so.2 => /lib64/ld-linux-x86-64.so.2 (0x00007f30d52db000)
librt.so.1 => /nix/store/xg6ilb9g9zhi2zg1dpi4zcp288rhnvns-glibc-2.30/lib/librt.so.1 (0x00007f30d4609000)
libdl.so.2 => /nix/store/xg6ilb9g9zhi2zg1dpi4zcp288rhnvns-glibc-2.30/lib/libdl.so.2 (0x00007f30d4604000)
libcrypto.so.1.1 => /nix/store/0x3bf23q5lmdq77x5icr7c0ngvz25ms3-openssl-1.1.1g/lib/libcrypto.so.1.1 (0x00007f30d4318000)
libsqlite3.so.0 => /nix/store/avrfjzdw3x7gwyn2lhdlyafwb12sgk5m-sqlite-3.32.2/lib/libsqlite3.so.0 (0x00007f30d41f1000)
libbz2.so.1 => /nix/store/ipcp5xyxmmzdz5z7q3x574si2j7j7py2-bzip2-1.0.6.0.1/lib/libbz2.so.1 (0x00007f30d41de000)
libcurl.so.4 => /nix/store/r34dgxr3c55ygn617pdhz1ir7q4jn70c-curl-7.70.0/lib/libcurl.so.4 (0x00007f30d414f000)
libaws-cpp-sdk-transfer.so => /nix/store/f7wwm99s0bvzwmnrdmg9ny3nbglkchfz-aws-sdk-cpp-1.7.90/lib/libaws-cpp-sdk-transfer.so (0x00007f30d411c000)
libaws-cpp-sdk-s3.so => /nix/store/f7wwm99s0bvzwmnrdmg9ny3nbglkchfz-aws-sdk-cpp-1.7.90/lib/libaws-cpp-sdk-s3.so (0x00007f30d3e44000)
libaws-cpp-sdk-core.so => /nix/store/f7wwm99s0bvzwmnrdmg9ny3nbglkchfz-aws-sdk-cpp-1.7.90/lib/libaws-cpp-sdk-core.so (0x00007f30d3d19000)
libseccomp.so.2 => /nix/store/y9r40mvhgi7hka0xhpml9dq3z1k9g0f5-libseccomp-2.4.2-lib/lib/libseccomp.so.2 (0x00007f30d3ccc000)
liblzma.so.5 => /nix/store/jj7dqm9m5cav4gqmwqpkf1z66g0ipwv6-xz-5.2.4/lib/liblzma.so.5 (0x00007f30d3ca2000)
libbrotlienc.so.1 => /nix/store/qm39nciyhn5qvnn7ahq578k9m5k0cq1i-brotli-1.0.7-lib/lib/libbrotlienc.so.1 (0x00007f30d3c08000)
libbrotlidec.so.1 => /nix/store/qm39nciyhn5qvnn7ahq578k9m5k0cq1i-brotli-1.0.7-lib/lib/libbrotlidec.so.1 (0x00007f30d3bfa000)
libz.so.1 => /nix/store/msp4hm62a75pdidlc3s2ymma2g5hsjjk-zlib-1.2.11/lib/libz.so.1 (0x00007f30d3bdb000)
libnghttp2.so.14 => /nix/store/5nhlxcjqzwcyj0kqjpnrcds53paw8j08-nghttp2-1.40.0-lib/lib/libnghttp2.so.14 (0x00007f30d3bb2000)
libssh2.so.1 => /nix/store/fnn6zvyds5sy7mgvl4h2qslmlsaf0dc8-libssh2-1.9.0/lib/libssh2.so.1 (0x00007f30d3b72000)
libssl.so.1.1 => /nix/store/0x3bf23q5lmdq77x5icr7c0ngvz25ms3-openssl-1.1.1g/lib/libssl.so.1.1 (0x00007f30d3adc000)
libgssapi_krb5.so.2 => /nix/store/bxjyac4385pw8cwrlgm7d18bmmndf4p5-libkrb5-1.17/lib/libgssapi_krb5.so.2 (0x00007f30d3a8c000)
libkrb5.so.3 => /nix/store/bxjyac4385pw8cwrlgm7d18bmmndf4p5-libkrb5-1.17/lib/libkrb5.so.3 (0x00007f30d39ac000)
libk5crypto.so.3 => /nix/store/bxjyac4385pw8cwrlgm7d18bmmndf4p5-libkrb5-1.17/lib/libk5crypto.so.3 (0x00007f30d3979000)
libcom_err.so.3 => /nix/store/bxjyac4385pw8cwrlgm7d18bmmndf4p5-libkrb5-1.17/lib/libcom_err.so.3 (0x00007f30d3973000)
libaws-c-event-stream.so.0unstable => /nix/store/2nr2gr8gy4j0clgiy3ac8gkxz3b3ln86-aws-c-event-stream-0.1.1/lib/libaws-c-event-stream.so.0unstable (0x00007f30d3961000)
libaws-checksums.so => /nix/store/qha2qqxwgs2ygsq0badjaipgcjmmwm3i-aws-checksums-0.1.5/lib/libaws-checksums.so (0x00007f30d3951000)
libbrotlicommon.so.1 => /nix/store/qm39nciyhn5qvnn7ahq578k9m5k0cq1i-brotli-1.0.7-lib/lib/libbrotlicommon.so.1 (0x00007f30d392e000)
libkrb5support.so.0 => /nix/store/bxjyac4385pw8cwrlgm7d18bmmndf4p5-libkrb5-1.17/lib/libkrb5support.so.0 (0x00007f30d391f000)
libkeyutils.so.1 => /nix/store/9xv0mxb6sbd5sz8a0i4xi6z0h8762cdp-keyutils-1.6.1-lib/lib/libkeyutils.so.1 (0x00007f30d3918000)
libresolv.so.2 => /nix/store/xg6ilb9g9zhi2zg1dpi4zcp288rhnvns-glibc-2.30/lib/libresolv.so.2 (0x00007f30d38fd000)

So, it seems that you ran the program instead of running stat on the program. The fact that you got usage back indicates that your nix installed correctly and that there is nothing wrong with it. Perhaps it was a misunderstanding?

Could you try cloning the repo you were trying to build from the user account and running nix-shell from the user account as well?

I am sorry I do not understand your post. What shall I do exactly? Cloning the repo you mean installing nix?

The good news is that theotherjimmy is saying that nix seems to have installed correctly. The reason for this is that when you run:

~/.nix-profile/bin/nix

then the terminal is displaying the default output of the nix executable, which is simply to give the instructions on what parameter to feed the nix executable so as to perform some operations.

When I run the nix command on my system I get the same exact result as you do:

Usage: nix … …

Common flags:
–debug enable debug output
–help show usage information
–help-config show configuration options
–no-net disable substituters and consider all previously downloaded files up-to-date
–option set a Nix configuration option (overriding nix.conf)
-L, --print-build-logs print full build logs on stderr
–quiet decrease verbosity level
-v, --verbose increase verbosity level
–version show version information


Consequence, theotherjimmy suggests that the repository (code source of the cardano node that you are trying to build) you are wanting to build may have permission issue after you downloaded it. So he is suggesting that you do git clone with the same user that you launch nix-shell with. Did you use git clone, or did you get the sources by another means ?

But I did not even touch the Cardano Node. I was just trying to run “nix-shell” for which I get “permission denied”. I am blocked at the phase when I should open a nix-shell session

Or maybe I’m getting it wrong? Shall I just install nix on the user and then clone the repository? I mean am I automatically in a nix-shell session once I install it on my user or should I OPEN a nix-shell session? I understood that I should OPEN a nix-shell session.

Like stphrolland said, your nix install in the user seems to work. The big picture version of what I’m suggesting is that you can continue following the instructions, from within the user account.

Shall I just install nix on the user and then clone the repository?

You already have nix installed on the user, so you may proceed to clone the repository (Cardano Node in this case) as the user. You could also move the repository to the user’s account and make it accessible to them. I recommended git clone ... (... is a placeholder for the rest of the arguments) because I got the feeling that would be simpler.

I mean am I automatically in a nix-shell session once I install it on my user or should I OPEN a nix-shell session?

You’re in a shell with nix installed, which is not the same thing as being in a nix-shell session. A nix-shell is an environment where you have access to your project’s dependencies without installing them, as well as the programs in the user profile (that ~/.nix-proile/bin directory we were working with before). That is to say that outside of a nix-shell you would not have access to that project’s dependencies. This can be useful if, for example, you have multiple projects with dependencies that would conflict with dependencies of other projects or the programs in your user profile. nix-shell allows you to have multiple, isolated environments that don’t conflict. Opening a nix-shell session can be as simple as running nix-shell from within a project’s directory.

I understood that I should OPEN a nix-shell session.

Yes. Taking the content from the prior answer, you would do something such as (where you substitute <project-dir> for the directory where your project is located):

$ cd <project-dir>
$ nix-shell

This may print a lot of information, telling you that it’s downloading and building dependencies. It may also sit for a bit doing what appears to be nothing. When it completes, you should be returned to a bash prompt. This bash prompt will have a modified $PATH variable, when compared to the bash that invoked nix-shell.

Ok I successfully cloned the repository (with “git clone”), changed the directory with “sudo -s cd ” (because “cd” or “sudo cd” doesn’t work (command not found), seems like because “cd” is not an executable that could run with “sudo”, and with “cd” alone it’s permission denied).

And now when it comes to “nix-build”, here we go again, “command not found”, I get this:
“nix-build -A scripts.mainnet.node -o mainnet-node-local”
nix-build: command not found

I think there is just something rather simple I am missing but I don’t know what… It can’t be that complicated. Maybe there’s a file or executable I should put in PATH but I don’t know how or what.

Why did you try to sudo cd? What user did you clone from?

“cd” is not an executable

That’s true; it’s a shell builtin, because it must affect the state of the shell. executables can’t affect the state of the shell, except through the return code $?.

And now when it comes to “nix-build”, here we go again, “command not found”, I get this:
“nix-build -A scripts.mainnet.node -o mainnet-node-local”
nix-build: command not found

What user did you try to execute nix-shell from?

I think there is just something rather simple I am missing but I don’t know what… It can’t be that complicated. Maybe there’s a file or executable I should put in PATH but I don’t know how or what.

My guess is that you need to execute this from the user you created. root does not have any nix tools it it’s path.

1 Like

Not a diversion, just a complementary test, not involving a repository to retrieve, neither to cd into.

We can get 100% confirmation if nix-shell works with your normal user (which is not root) writing this on the command line:
nix-shell -p hello
then type:
hello

For the user you installed nix with, it should output: Hello, world!

With this command, nix-shell -p hello should do as if you had installed the program hello. For me, it’s one of the killer feature of nix, you can just test any available official nixpkgs packages on the fly like that.

1 Like

It’s worth noting that GNU hello is localized, so the returned text is dependent on the locale that’s set for the user.

2 Likes