# Use autoPatchelf inside mkShell

**URL:** https://discourse.nixos.org/t/use-autopatchelf-inside-mkshell/18687
**Category:** Uncategorized
**Created:** [April 17, 2022, 7:59pm UTC](https://discourse.nixos.org/t/use-autopatchelf-inside-mkshell/18687 "2022-04-17T19:59:20Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![brogos](https://discourse.nixos.org/user_avatar/discourse.nixos.org/brogos/32/2660_2.png) [@brogos](https://discourse.nixos.org/u/brogos)
#### Post date: [April 17, 2022, 7:59pm UTC](https://discourse.nixos.org/t/use-autopatchelf-inside-mkshell/18687/1 "2022-04-17T19:59:21Z")

</div>

Is it possible to use `autoPatchelf` inside a `mkShell`? I want to create a `virtualenv` inside my project folder and use `autoPatchelf` to fix the problems with shared libs. I have the following `shell.nix`:

```nix
with import <nixpkgs> { };

mkShell {
  name = "test";

  buildInputs = [
    python3Packages.venvShellHook
    autoPatchelfHook
  ];
  venvDir = "my_env";
  postShellHook = ''
    pip install numpy
    autopatchelf my_env
  '';
}

```

It’s creating the `virtualenv` but `autopachelf` is not being found:

```auto
❯ nix-shell
Using venvShellHook
Executing venvHook
Creating new venv environment in path: 'my_env'
Collecting numpy
  Using cached numpy-1.22.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (16.8 MB)
Installing collected packages: numpy
Successfully installed numpy-1.22.3
autopatchelf: command not found
Finished executing venvShellHook

```

---

<div class="post-metadata">

### Author: ![TLATER](https://discourse.nixos.org/user_avatar/discourse.nixos.org/tlater/32/4257_2.png) [@TLATER](https://discourse.nixos.org/u/TLATER)
#### Post date: [April 18, 2022, 4:17am UTC](https://discourse.nixos.org/t/use-autopatchelf-inside-mkshell/18687/2 "2022-04-18T04:17:30Z")

</div>

I don’t have an exact answer, but both of these are hooks. I’d wager that the functions explicitly don’t have each other in scope; you could probably source the script directly instead though. I’d love some detailed docs on the hook mechanism in general, the nixpkgs manual doesn’t explain much, and the `setup.sh` script is as easy to understand as you’d expect a bash script with hidden dependency scripts to be…

Anyway, I’m commenting because this topic basically does what you want, and comments go over alternatives: [https://discourse.nixos.org/t/how-to-use-python-on-nixos-without-nix/](https://discourse.nixos.org/t/how-to-use-python-on-nixos-without-nix/)

---

<div class="post-metadata">

### Author: ![pbogdan](https://discourse.nixos.org/letter_avatar_proxy/v4/letter/p/e68b1a/32.png) [@pbogdan](https://discourse.nixos.org/u/pbogdan)
#### Post date: [April 18, 2022, 8:18am UTC](https://discourse.nixos.org/t/use-autopatchelf-inside-mkshell/18687/3 "2022-04-18T08:18:43Z")

</div>

Could it be a simple typo? From what I see the function is called `autoPatchelf` (with capital `P`) whereas your code refers to all lower-case `autopatchelf`.

---

<div class="post-metadata">

### Author: ![brogos](https://discourse.nixos.org/user_avatar/discourse.nixos.org/brogos/32/2660_2.png) [@brogos](https://discourse.nixos.org/u/brogos)
#### Post date: [April 18, 2022, 3:28pm UTC](https://discourse.nixos.org/t/use-autopatchelf-inside-mkshell/18687/4 "2022-04-18T15:28:47Z")

</div>

You are correct, it’s `autoPatchelf` not `autopatchelf`. Now it’s working! Many thanks!
