cabal gen-bounds fails when using Nix integration
- Dominant language
- Haskell
- Stars
- 1.7k
- Forks
- 750
- Avg merge
- 4d 3h
- Merged PRs (30d)
- 28
Description
**Describe the bug**
A clear and concise description of what the bug is.
**To Reproduce**
Steps to reproduce the behavior:
```
$ cabal init --package-name=amy --exe
Guessing dependencies...
Generating LICENSE...
Warning: unknown license type, you must put a copy in LICENSE yourself.
Generating Setup.hs...
Generating CHANGELOG.md...
Generating Main.hs...
Generating amy.cabal...
Warning: no synopsis given. You should edit the .cabal file and add one.
You may want to edit the .cabal file and add a Description field.
$ cabal2nix --shell ./. >shell.nix
$ cabal --disable-nix gen-bounds
Congratulations, all your dependencies have upper bounds!
$ cabal --enable-nix gen-bounds
error: getting status of '/home/amy/temp/bug/dist/nix/shell.drv': No such file or directory
```
If you set `nix: True` in `~/.cabal/config` you can get the same error.
```
$ cabal gen-bounds
error: getting status of '/home/amy/temp/bug/dist/nix/shell.drv': No such file or directory
```
Entering a nix shell first doesn't solve the problem.
```
$ nix-shell
(nix-shell) $ cabal gen-bounds
error: getting status of '/home/amy/temp/bug/dist/nix/shell.drv': No such file or directory
```
Here's a version with `verbose` output.
```
$ cabal gen-bounds --verbose=3
no user package environment file found at /home/amy/temp/bug
Searching for nix-shell in path.
Found nix-shell at /run/current-system/sw/bin/nix-shell
Environment: [("ASPELL_CONF","dict-dir /run/current-system/sw/lib/aspell"),("CABAL_IN_NIX_SHELL","1"),("COLORFGBG","15;0"),("CONDA_EXE","/home/amy/.conda/bin/conda"),("CONDA_PYTHON_EXE","/home/amy/.conda/bin/python"),("CONDA_SHLVL","0"),("CUPS_DATADIR","/nix/store/h0asy4z3wm6swx58w8rrizzi09lx0682-cups-progs/share/cups"),("DBUS_SESSION_BUS_ADDRESS","unix:abstract=/tmp/dbus-suCl44hswW,guid=92cdb6184e5434423b87a1a95ea1880c"),("DESKTOP_SESSION","/nix/store/drfh3rsvn5sxqkr488mxwgc6a96s8b8k-desktops/share/xsessions/none+xmonad"),("DISPLAY",":0"),("EDITOR","nano"),("GDK_PIXBUF_MODULE_FILE","/nix/store/kmhaf1l7r869z3mbf1ni1vys28qxv3bg-gdk-pixbuf-loaders.cache"),("GPG_TTY","/dev/pts/1"),("GTK_PATH","/home/amy/.nix-profile/lib/gtk-2.0:/home/amy/.nix-profile/lib/gtk-3.0:/etc/profiles/per-user/amy/lib/gtk-2.0:/etc/profiles/per-user/amy/lib/gtk-3.0:/nix/var/nix/profiles/default/lib/gtk-2.0:/nix/var/nix/profiles/default/lib/gtk-3.0:/run/current-system/sw/lib/gtk-2.0:/run/current-system/sw/lib/gtk-3.0"),("HOME","/home/amy"),("INFOPATH","/home/amy/.nix-profile/info:/home/amy/.nix-profile/share/info:/etc/profiles/per-user/amy/info:/etc/profiles/per-user/amy/share/info:/nix/var/nix/profiles/default/info:/nix/var/nix/profiles/default/share/info:/run/current-system/sw/info:/run/current-system/sw/share/info"),("JAVA_HOME","/nix/store/8zwjn10rg0pfkffp32y36i5hi5qv3rg9-openjdk-8u222-ga/lib/openjdk"),("KDEDIRS","/home/amy/.nix-profile:/etc/profiles/per-user/amy:/nix/var/nix/profiles/default:/run/current-system/sw"),("LANG","en_IE.UTF-8"),("LANGUAGE",""),("LD_LIBRARY_PATH","/run/opengl-driver/lib"),("LIBEXEC_PATH","/home/amy/.nix-profile/lib/libexec:/etc/profiles/per-user/amy/lib/libexec:/nix/var/nix/profiles/default/lib/libexec:/run/current-system/sw/lib/libexec"),("LOCALE_ARCHIVE","/run/current-system/sw/lib/locale/locale-archive"),("LOGNAME","amy"),("MOZ_PLUGIN_PATH","/home/amy/.nix-profile/lib/mozilla/plugins:/etc/profiles/per-user/amy/lib/mozilla/plugins:/nix/var/nix/profiles/default/lib/mozilla/plugins:/run/current-system/sw/lib/mozilla/plugins"),("NIXPKGS_CONFIG","/etc/nix/nixpkgs-config.nix"),("NIX_GHC","/nix/store/j3piwf6wmh8izrbw68j60jir7s89v4bi-ghc-8.6.5-with-packages/bin/ghc"),("NIX_PATH","/home/amy/.nix-defexpr/channels:nixpkgs=/nix/var/nix/profiles/per-user/root/channels/nixos:nixos-config=/etc/nixos/configuration.nix:/nix/var/nix/profiles/per-user/root/channels"),("NIX_PROFILES","/run/current-system/sw /nix/var/nix/profiles/default /etc/profiles/per-user/amy /home/amy/.nix-profile"),("NIX_USER_PROFILE_DIR","/nix/var/nix/profiles/per-user/amy"),("NO_AT_BRIDGE","1"),("OLDPWD","/home/amy/temp"),("PAGER","less -R"),("PAM_KWALLET5_LOGIN","/run/user/1000/kwallet5.socket"),("PATH","/home/amy/.conda/condabin:/home/amy/wain-tools:/home/amy/bin:/home/amy/.local/bin:/home/amy/.cabal/bin:/home/amy/bin:/run/wrappers/bin:/home/amy/.nix-profile/bin:/etc/profiles/per-user/amy/bin:/nix/var/nix/profiles/default/bin:/run/current-system/sw/bin"),("PWD","/home/amy/temp/bug"),("QML2_IMPORT_PATH","/nix/store/m8k13rs90q9gjlww2gl4v0r635a6k6wh-qtwayland-5.12.3-bin/lib/qt-5.12.3/qml:/nix/store/bsvszl5vrbddniywfmwiac4xc4wzk9dy-qtquickcontrols-5.12.3/lib/qt-5.12.3/qml:/nix/store/20xwh0i8q1drhwwa57sqnz96bgy49rq7-qtdeclarative-5.12.3-bin/lib/qt-5.12.3/qml"),("QTWEBKIT_PLUGIN_PATH","/home/amy/.nix-profile/lib/mozilla/plugins/:/etc/profiles/per-user/amy/lib/mozilla/plugins/:/nix/var/nix/profiles/default/lib/mozilla/plugins/:/run/current-system/sw/lib/mozilla/plugins/"),("QT_PLUGIN_PATH","/nix/store/m8k13rs90q9gjlww2gl4v0r635a6k6wh-qtwayland-5.12.3-bin/lib/qt-5.12.3/plugins:/nix/store/20xwh0i8q1drhwwa57sqnz96bgy49rq7-qtdeclarative-5.12.3-bin/lib/qt-5.12.3/plugins:/nix/store/rk4z6ciz36v323lgp19rxb50kjl95knd-qtsvg-5.12.3-bin/lib/qt-5.12.3/plugins:/nix/store/phh1320xs4zwgkb7adnbrwyhxqcw3yh6-qtbase-5.12.3-bin/lib/qt-5.12.3/plugins:/home/amy/.nix-profile/lib/qt4/plugins:/home/amy/.nix-profile/lib/kde4/plugins:/etc/profiles/per-user/amy/lib/qt4/plugins:/etc/profiles/per-user/amy/lib/kde4/plugins:/nix/var/nix/profiles/default/lib/qt4/plugins:/nix/var/nix/profiles/default/lib/kde4/plugins:/run/current-system/sw/lib/qt4/plugins:/run/current-system/sw/lib/kde4/plugins"),("SHELL","/run/current-system/sw/bin/bash"),("SHLVL","5"),("SSH_ASKPASS","/nix/store/mkszwkdz3lb51xbq4s0wal1762xv5azy-ksshaskpass-5.16.5/bin/ksshaskpass"),("STRIGI_PLUGIN_PATH","/home/amy/.nix-profile/lib/strigi/:/etc/profiles/per-user/amy/lib/strigi/:/nix/var/nix/profiles/default/lib/strigi/:/run/current-system/sw/lib/strigi/"),("TERM","xterm-256color"),("TERMINFO_DIRS","/home/amy/.nix-profile/share/terminfo:/etc/profiles/per-user/amy/share/terminfo:/nix/var/nix/profiles/default/share/terminfo:/run/current-system/sw/share/terminfo"),("TZDIR","/etc/zoneinfo"),("USER","amy"),("WINDOWID","0"),("XAUTHORITY","/home/amy/.Xauthority"),("XCURSOR_PATH","/home/amy/.icons:/home/amy/.nix-profile/share/icons:/etc/profiles/per-user/amy/share/icons:/nix/var/nix/profiles/default/share/icons:/run/current-system/sw/share/icons"),("XDG_CONFIG_DIRS","/etc/xdg:/home/amy/.nix-profile/etc/xdg:/etc/profiles/per-user/amy/etc/xdg:/nix/var/nix/profiles/default/etc/xdg:/run/current-system/sw/etc/xdg"),("XDG_CURRENT_DESKTOP",""),("XDG_DATA_DIRS","/nix/store/y8zw0g688v7js1sni9gndhib1nfgr3xm-qterminal-0.14.1/share:/home/amy/.nix-profile/share:/etc/profiles/per-user/amy/share:/nix/var/nix/profiles/default/share:/run/current-system/sw/share"),("XDG_DESKTOP_PORTAL_PATH","/nix/store/x13ld6p8kkahngi8ak5w4vr7l6y8pll7-xdg-desktop-portal-kde-5.16.5/share/xdg-desktop-portal/portals"),("XDG_RUNTIME_DIR","/run/user/1000"),("XDG_SEAT","seat0"),("XDG_SEAT_PATH","/org/freedesktop/DisplayManager/Seat0"),("XDG_SESSION_CLASS","user"),("XDG_SESSION_DESKTOP",""),("XDG_SESSION_ID","2"),("XDG_SESSION_PATH","/org/freedesktop/DisplayManager/Session1"),("XDG_SESSION_TYPE","x11"),("XDG_VTNR","7"),("XMONAD_XMESSAGE","/nix/store/zzi56zjrpcdk63xxikvy31v9yn67ky0l-xmessage-1.0.5/bin/xmessage"),("_","/run/current-system/sw/bin/cabal"),("_CE_CONDA",""),("_CE_M",""),("__ETC_PROFILE_DONE","1"),("__NIXOS_SET_ENVIRONMENT_DONE","1")]
/run/current-system/sw/bin/nix-shell --add-root dist/nix/gcroots/result --indirect /home/amy/temp/bug/dist/nix/shell.drv --run '/nix/store/yslccq49f6dv12ay6h5f1nidgnnf1dl4-cabal-install-3.0.0.0/bin/cabal gen-bounds '\''--verbose=3'\'''
error: getting status of '/home/amy/temp/bug/dist/nix/shell.drv': No such file or directory
/run/current-system/sw/bin/nix-shell returned ExitFailure 1
```
**Expected behavior**
I expect `cabal --enable-nix gen-bounds` to produce the same output as `cabal --disable-nix gen-bounds`. I don't understand why this this particular command would be looking for a `.drv` file. I would have thought that it only needs to examine the `.cabal` file.
**System information**
```
$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 8.6.5
$ cabal --version
cabal-install version 3.0.0.0
compiled using version 3.0.0.0 of the Cabal library
$ nix-shell -p nix-info --run "nix-info -m"
- system: `"x86_64-linux"`
- host os: `Linux 4.19.116, NixOS, 19.09.2426.9237a09d8ed (Loris)`
- multi-user?: `yes`
- sandbox: `yes`
- version: `nix-env (Nix) 2.3.3`
- channels(amy): `"nixpkgs-18.09.1676.7e88992a8c7"`
- channels(root): `"nixos-19.09.2426.9237a09d8ed"`
- nixpkgs: `/home/amy/.nix-defexpr/channels/nixpkgs`
```
**Additional context**
Add any other context about the problem here.
Contributor guide
Research direction
Start by reproducing `cabal --enable-nix gen-bounds` and compare it with `cabal --disable-nix gen-bounds`, using the verbose command output as the entry point. Inspect how `gen-bounds` handles the `.cabal` file and Nix integration; done means the enabled-Nix command produces the same dependency-bound output without requiring the missing `dist/nix/shell.drv` file.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- haskell
- Domain
- build-system, cli
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100