Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cabal gen-bounds fails when using Nix integration #6731

Open
mhwombat opened this issue Apr 23, 2020 · 11 comments
Open

cabal gen-bounds fails when using Nix integration #6731

mhwombat opened this issue Apr 23, 2020 · 11 comments
Labels
cabal-install: cmd/gen-bounds cabal-install: nix integration can-workaround There is a (maybe partial) workaround for the issue or missing feature type: bug

Comments

@mhwombat
Copy link

mhwombat commented Apr 23, 2020

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.

@23Skidoo
Copy link
Member

/cc @mightybyte

@mhwombat
Copy link
Author

mhwombat commented Jul 25, 2021

I'm still experiencing this issue. In the meantime, I'm using the cabal --disable-nix gen-bounds workaround.

@Kleidukos
Copy link
Member

This bug is still around

@Kleidukos Kleidukos added the 3.8 label Feb 10, 2022
@Mikolaj
Copy link
Member

Mikolaj commented Feb 10, 2022

Does anybody have an idea if this is blocked on something? Did someone mention exact-print as the blocker?

@gbaz
Copy link
Collaborator

gbaz commented Feb 10, 2022

I don't think it is blocked on anything. That said, I'm not sure it is a bug. When --enable-nix is set, all commands are run in a subprocess, after nix-shell has been entered, using shell.drv.

So any cabal command enters the nix-shell this way when --enable-nix is set. Correspondingly any cabal command would fail this way if the drv were missing.

In which case this bug report is just that this particular command fails that way?

@Kleidukos Kleidukos removed the 3.8 label Mar 12, 2022
@Mikolaj
Copy link
Member

Mikolaj commented Aug 5, 2022

Is gen-bounds a v2- command? Because --enable-nix is supposed to be ignored by v2- commands (or is supposed to be broken with v2- commands?). See, e.g., #6444 and #4646.

@fgaz
Copy link
Member

fgaz commented Aug 5, 2022

It doesn't have a v1-/v2- distinction. It's a very simple command that reads a single cabal file and doesn't accept any flag except global ones
edit: i guess you could call it v1- since it doesn't work in projects

@Mikolaj Mikolaj added the can-workaround There is a (maybe partial) workaround for the issue or missing feature label Aug 5, 2022
@Mikolaj
Copy link
Member

Mikolaj commented Aug 5, 2022

@mhwombat: I'm trying to understand what severity this issue has and so if the workaround is sufficient. Is the main problem for you that you want to keep nix: True in ~/.cabal/config permanently, but run some commands (e.g., gen-bounds) as if you had nix: False, because nix: True requires some setup per package checkout that you may not need to perform otherwise? Or is the burden more general or heavier?

@Mikolaj
Copy link
Member

Mikolaj commented Aug 5, 2022

BTW, people report in #4646 and other tickets with the nix label that nix: True is useless for them. Are you sure it still has any value for you with newer cabal versions?

@mhwombat
Copy link
Author

mhwombat commented Aug 5, 2022

@Mikolaj Thank you for following up on this. For me, it's just a minor annoyance to have to specify --disable-nix for this command. I didn't expect this particular command to need the .drv file, so the error message didn't help me, and the only way I found the solution was by searching the web.

My suggestions for resolving this are, in decreasing order of preference:

  1. Don't go looking for a .drv file (so don't enter a shell?) unless you need to.
  2. Have the error message suggest the --disable-nix workaround.
  3. Document the workaround in, say, https://cabal.readthedocs.io/en/3.6/cabal-package.html?highlight=gen-bounds#generating-dependency-version-bounds.
  4. Close the issue as "won't fix". Once you know the workaround, it's only an annoyance.

I don't bother with the nix: True flag these days.

@Mikolaj
Copy link
Member

Mikolaj commented Aug 5, 2022

I'm asking, in particular, because we recently debated whether to remove --enable-nix (will probably happen in the long run) or to improve the docs and we ended up with #8333, which is probably incorrect in light of your experience. Or at least could be improved, which would also be a way to put this ticket to rest and make it easier for people to find an answer in a similar situation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cabal-install: cmd/gen-bounds cabal-install: nix integration can-workaround There is a (maybe partial) workaround for the issue or missing feature type: bug
Projects
None yet
Development

No branches or pull requests

7 participants