setup-hook: No such file or directory
Closed this issue · 12 comments
Here's my sdk.nix (copied from readme):
{ pkgs ? import <nixpkgs> { } }:
with pkgs;
let
androidSdkPackages = callPackage <android> {
# Default; can also choose "beta", "preview", or "canary".
channel = "stable";
};
in
androidSdkPackages.sdk (apkgs: with apkgs; [
cmdline-tools-latest
build-tools-30-0-2
platform-tools
platforms-android-30
emulator
])
Then I run:
$ nix-shell sdk.nix
Using Android SDK root: /nix/store/14l19x60cmdm19qydfsq15xy4pbha3v5-android-sdk-env/share/android-sdk
bash: /nix/store/14l19x60cmdm19qydfsq15xy4pbha3v5-android-sdk-env/nix-support/setup-hook: No such file or directory
[nix-shell:~]$
And I get that "no such file" error. Also the ANDROID_HOME var isn't set correctly (it's set to what it is in my global bash env from which I ran nix-shell.
Can you run tree /nix/store/14l19x60cmdm19qydfsq15xy4pbha3v5-android-sdk-env/
and copy the output here?
The directory isn't there (I checked both inside and outside of the nix-shell). It's weird because I do see other pkgs in there like
[nix-shell:~]$ find /nix/store/1dlvcbs6hl3ys3925lbhqc74dby1qjhn-libtool-2.4.6-lib
/nix/store/1dlvcbs6hl3ys3925lbhqc74dby1qjhn-libtool-2.4.6-lib
/nix/store/1dlvcbs6hl3ys3925lbhqc74dby1qjhn-libtool-2.4.6-lib/lib
/nix/store/1dlvcbs6hl3ys3925lbhqc74dby1qjhn-libtool-2.4.6-lib/lib/libltdl.la
/nix/store/1dlvcbs6hl3ys3925lbhqc74dby1qjhn-libtool-2.4.6-lib/lib/libltdl.dylib
/nix/store/1dlvcbs6hl3ys3925lbhqc74dby1qjhn-libtool-2.4.6-lib/lib/libltdl.7.dylib
There's a .drv file.
[nix-shell:/nix/store]$ ls|grep android
3ypdlbq6q5r0aychzqav1np7gq5lnag9-android-sdk-env.drv
89nwqr1cp8rz2ixnnk1jgqv43kbl31jz-android
bbz63ah0gb4vyy5zlm5ppzvw4gyxlvaw-android-licenses.drv
ccbg60ggbvyd7g883xciqghqff6a8sac-android-nixpkgs
dg8xbnrp1nxmamf6jkmbw64bip4i2cxg-android-sdk-preview-license.drv
fab5kjnjd8j1ax92ijxk2f529yafbawi-android-sdk-license.drv
g6nn4xf1cx3l3piy5vrh776n39bah1r7-platforms-android-30-3
i09vdjs4kc7mblkn5wibwk92rfs0avkm-platforms-android-30-3.drv
k43480l3p3wk4glwwbrd5vnhz8gnqx1d-android.drv
kqa0mqhb91yimz4gj9xn67fm6qm0mi6b-android-sdk-license
q55gn4wnsi3achb9x0px20zrdqqw6xv9-platforms-android-30.xml
qmvj0izcjnng2204yl0ws871pbb8xj8h-android-licenses
ynsq7160wz4sli3qk9r5w1ypa5q1p33h-android-sdk-preview-license
EDIT: I'm on a mac. Some sys info:
$ nix-shell --version
nix-shell (Nix) 2.4
$ system_profiler SPSoftwareDataType
Software:
System Software Overview:
System Version: macOS 11.6.1 (20G224)
Kernel Version: Darwin 20.6.0
Boot Volume: Macintosh HD
Boot Mode: Normal
Computer Name: foo
User Name: foo
Secure Virtual Memory: Enabled
System Integrity Protection: Enabled
Time since boot: 7 days 2:05
Ah, interesting. Can you try this script instead?
{ pkgs ? import <nixpkgs> { } }:
with pkgs;
let
android-nixpkgs = callPackage (import (builtins.fetchGit {
url = "https://github.com/tadfisher/android-nixpkgs.git";
ref = "main"; # Or "stable", "beta", "preview", "canary"
})) { };
in
android-nixpkgs.sdk (sdkPkgs: with sdkPkgs; [
cmdline-tools-latest
build-tools-32-0-0
platform-tools
platforms-android-31
emulator
])
It creates different packages but hits the same issue:
$ nix-shell sdk2.nix
these 4 derivations will be built:
/nix/store/l6n68ivgcsl0vnlgq2zn7glkphdf4x7r-platform-31_r01.zip.drv
/nix/store/gk73xr4p60k8glryj1pygnqz1ak2ad6f-platforms-android-31-1.drv
/nix/store/mzby6mvs2r0rfzsfa0fxbrn0kxi3pgm6-5219cc671e844de73762e969ace287c29d2e14cd.build-tools_r32-macosx.zip.drv
/nix/store/q8pa0jwl1gw3g2ra72bjzy4mxcvi76s1-build-tools-32-0-0-32.drv
building '/nix/store/mzby6mvs2r0rfzsfa0fxbrn0kxi3pgm6-5219cc671e844de73762e969ace287c29d2e14cd.build-tools_r32-macosx.zip.drv'...
trying https://dl.google.com/android/repository/5219cc671e844de73762e969ace287c29d2e14cd.build-tools_r32-macosx.zip
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 50.4M 100 50.4M 0 0 35.8M 0 0:00:01 0:00:01 --:--:-- 35.8M
building '/nix/store/l6n68ivgcsl0vnlgq2zn7glkphdf4x7r-platform-31_r01.zip.drv'...
trying https://dl.google.com/android/repository/platform-31_r01.zip
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 53.8M 100 53.8M 0 0 24.6M 0 0:00:02 0:00:02 --:--:-- 24.6M
building '/nix/store/q8pa0jwl1gw3g2ra72bjzy4mxcvi76s1-build-tools-32-0-0-32.drv'...
unpacking sources
unpacking source archive /nix/store/g8fpm5rq1w3f1kqibrc1pkmvaa2lpw6i-5219cc671e844de73762e969ace287c29d2e14cd.build-tools_r32-macosx.zip
source root is /nix/store/1nycrzr7nxpfizaw8amzf8ipb7dl8a1k-build-tools-32-0-0-32
setting SOURCE_DATE_EPOCH to timestamp 1637312022 of file /nix/store/1nycrzr7nxpfizaw8amzf8ipb7dl8a1k-build-tools-32-0-0-32/aidl
patching sources
configuring
no configure script, doing nothing
building
no Makefile, doing nothing
installing
post-installation fixup
strip is /nix/store/854jyvxrvpdpbfn2zaba1v2qgqkxipyh-cctools-binutils-darwin-949.0.1/bin/strip
stripping (with command strip and flags -S) in /nix/store/1nycrzr7nxpfizaw8amzf8ipb7dl8a1k-build-tools-32-0-0-32/lib /nix/store/1nycrzr7nxpfizaw8amzf8ipb7dl8a1k-build-tools-32-0-0-32/lib64
patching script interpreter paths in /nix/store/1nycrzr7nxpfizaw8amzf8ipb7dl8a1k-build-tools-32-0-0-32
/nix/store/1nycrzr7nxpfizaw8amzf8ipb7dl8a1k-build-tools-32-0-0-32/lld: interpreter directive changed from "#!/bin/bash" to "/nix/store/3npg6a8nc5vpcyw98v085cmlz7f78kgs-bash-5.1-p12/bin/bash"
/nix/store/1nycrzr7nxpfizaw8amzf8ipb7dl8a1k-build-tools-32-0-0-32/d8: interpreter directive changed from "#!/bin/bash" to "/nix/store/3npg6a8nc5vpcyw98v085cmlz7f78kgs-bash-5.1-p12/bin/bash"
/nix/store/1nycrzr7nxpfizaw8amzf8ipb7dl8a1k-build-tools-32-0-0-32/mainDexClasses: interpreter directive changed from "#!/bin/bash" to "/nix/store/3npg6a8nc5vpcyw98v085cmlz7f78kgs-bash-5.1-p12/bin/bash"
/nix/store/1nycrzr7nxpfizaw8amzf8ipb7dl8a1k-build-tools-32-0-0-32/apksigner: interpreter directive changed from "#!/bin/bash" to "/nix/store/3npg6a8nc5vpcyw98v085cmlz7f78kgs-bash-5.1-p12/bin/bash"
moving /nix/store/1nycrzr7nxpfizaw8amzf8ipb7dl8a1k-build-tools-32-0-0-32/lib64/* to /nix/store/1nycrzr7nxpfizaw8amzf8ipb7dl8a1k-build-tools-32-0-0-32/lib
building '/nix/store/gk73xr4p60k8glryj1pygnqz1ak2ad6f-platforms-android-31-1.drv'...
unpacking sources
unpacking source archive /nix/store/vg4fcnw1d8psna1wws654p5xzwm2vy7a-platform-31_r01.zip
source root is /nix/store/v2hdggx6bl4z4gpvv01lbgs9x7c4cyws-platforms-android-31-1
setting SOURCE_DATE_EPOCH to timestamp 1625271263 of file /nix/store/v2hdggx6bl4z4gpvv01lbgs9x7c4cyws-platforms-android-31-1/templates/strings.template
Using Android SDK root: /nix/store/g0ncdpfm0z5h7g7rwcbgr1almzrchkyp-android-sdk-env/share/android-sdk
bash: /nix/store/g0ncdpfm0z5h7g7rwcbgr1almzrchkyp-android-sdk-env/nix-support/setup-hook: No such file or directory
It still created a .drv in /nix/store:
3ypdlbq6q5r0aychzqav1np7gq5lnag9-android-sdk-env.drv
4izm88bnd93ki4nvs3zzfpln56qy6xq2-android-sdk-env.drv
I may be misunderstanding how shell hooks work. It appears that nix-shell is running the shellHook before building android-sdk-env
, which won't work when it's sourcing something from the package that hasn't been built.
I should have a fix for this up shortly.
Thanks Tad. I just found Nix yesterday so I know nothing. My impression was I would use this by putting sdk.nix into my android project root and then when someone wants to work on the android app they would do "nix-shell sdk.nix" and then they'd have a shell with everything setup. Is there a different way that most people would do this?
Typically you'd use mkShell
in a shell.nix
, so running nix-shell
with no arguments gets you going in a dev environment. But the sdk.nix example works too.
Can you try that snippet again and see if it works now?
Nice, it's fixed!
[nix-shell:~]$ echo $ANDROID_SDK
/Users/foo/Library/Android/sdk
[nix-shell:~]$ echo $ANDROID_HOME
/nix/store/b0x0qnflfidcc74cwqz2sz5q8zcwk0n6-android-sdk-env/share/android-sdk
looks like ANDROID_SDK isn't updated though, I think we should update that too with the same path.
$ANDROID_SDK
isn't a standard environment variable. Perhaps you mean ANDROID_SDK_ROOT
? See https://developer.android.com/studio/command-line/variables for a list.
Ah you're right, I didn't realize that. Looks good to me then. Thanks for fixing this so quickly.