haskell / cabal

Official upstream development repository for Cabal and cabal-install
https://haskell.org/cabal
Other
1.61k stars 691 forks source link

v2-install on tarball URL fails to find executable in package #7360

Open zachjs opened 3 years ago

zachjs commented 3 years ago

Describe the bug

Running cabal v2-install https://hackage.haskell.org/package/hlint-3.3/hlint-3.3.tar.gz fails, while manually running cabal v2-install in the unpacked tarball works just fine. This does not appear to be specific to hlint.

To Reproduce

cabal v2-install https://hackage.haskell.org/package/hlint-3.3/hlint-3.3.tar.gz

yields

Downloading http://hackage.haskell.org/package/hlint-3.3/hlint-3.3.tar.gz
Resolving dependencies...
cabal: Cannot build all the executables in the project because none of the
packages contain any executables. Check the .cabal files for the packages and
make sure that they properly declare the components that you expect.

Expected behavior

Downloading and installing packages using tarball URLs should succeed.

System information

Additional context

The installation appears to work if I manually grab the tarball instead.

wget https://hackage.haskell.org/package/hlint-3.3/hlint-3.3.tar.gz
tar -xzvf hlint-3.3.tar.gz
cd hlint-3.3
cabal v2-install

Running the troublesome command with -v shows that cabal seems to correctly resolve the dependencies.

fgaz commented 3 years ago

apparently HEAD rejects the url outright:

cabal: Cannot build the package https, it is not in this project (either
directly or indirectly). If you want to add it to the project then edit the
cabal.project file.

Not sure if it's supposed to support installing packages from URLs

phadej commented 3 years ago

@fgaz it is. https://github.com/haskell/cabal/issues/6393 and https://github.com/haskell/cabal/pull/6576

Something changed in argument parsing code?

(EDIT: It is a new feature in cabal-install-3.4, but looks like it was broken after implemented but before released :( )

phadej commented 3 years ago

Using an example from above issues:

% cabal install 'https://hackage.haskell.org/package/cabal-fmt-0.1.2/cabal-fmt-0.1.2.tar.gz#sha256=aae556efbcaddfd65c6a1c1811b122b0d8c8d00624c8c2e36aabb5e9f9ea9840' -v 
Reading available packages of hackage.haskell.org...
Using most recent state specified from most recent cabal update
index-state(hackage.haskell.org) = 2021-04-05T12:39:25Z
/opt/ghc/bin/ghc --numeric-version
looking for tool ghc-pkg near compiler in /opt/ghc/bin
found ghc-pkg in /opt/ghc/bin/ghc-pkg
/opt/ghc/bin/ghc-pkg --version
/opt/ghc/bin/ghc --supported-languages
/opt/ghc/bin/ghc --info
creating /tmp/cabal-install.-43500/dist-newstyle
creating /tmp/cabal-install.-43500/dist-newstyle/cache
Downloading
https://hackage.haskell.org/package/cabal-fmt-0.1.2/cabal-fmt-0.1.2.tar.gz#sha256=aae556efbcaddfd65c6a1c1811b122b0d8c8d00624c8c2e36aabb5e9f9ea9840
creating /tmp/cabal-install.-43500/dist-newstyle/src
/usr/bin/curl 'https://hackage.haskell.org/package/cabal-fmt-0.1.2/cabal-fmt-0.1.2.tar.gz#sha256=aae556efbcaddfd65c6a1c1811b122b0d8c8d00624c8c2e36aabb5e9f9ea9840' --output /tmp/cabal-install.-43500/dist-newstyle/src/cabal-fmt_-60b06e9cf24c539.tar43500-0.gz --location --write-out '%{http_code}' --user-agent 'cabal-install/3.4.0.0 (linux; x86_64)' --silent --show-error --dump-header /tmp/cabal-install.-43500/dist-newstyle/src/curl-headers43500-1.txt
Downloaded to
/tmp/cabal-install.-43500/dist-newstyle/src/cabal-fmt_-60b06e9cf24c539.tar.gz
Compiler settings changed, reconfiguring...
/opt/ghc/bin/ghc --numeric-version
looking for tool ghc-pkg near compiler in /opt/ghc/bin
found ghc-pkg in /opt/ghc/bin/ghc-pkg
/opt/ghc/bin/ghc-pkg --version
/opt/ghc/bin/ghc --supported-languages
/opt/ghc/bin/ghc --info
/opt/ghc/bin/ghc --print-global-package-db
Reading available packages of hackage.haskell.org...
Using most recent state specified from most recent cabal update
index-state(hackage.haskell.org) = 2021-04-05T12:39:25Z
/usr/bin/pkg-config --version
/usr/bin/pkg-config --variable pc_path pkg-config
/usr/bin/pkg-config --version
/usr/bin/pkg-config --list-all
/usr/bin/pkg-config --modversion Qt5DBus lapack-openblas Qt5WebChannel pixman-1 iso-codes gmodule-export-2.0 libtcmalloc_debug cairo-svg libdrm_intel recordproto nettle gnutls libpcreposix lapack-netlib atk-bridge-2.0 cairo-tee applewmproto dri dbus-1 mobile-broadband-provider-info xcb-render fftw3 xkbcommon dri3proto systemd libcap adwaita-icon-theme cairo-png libunwind ibus-1.0 libcurl wayland-cursor pangoxft xcursor Qt5WebKit xft libtcmalloc xcmiscproto glu 'gtk+-x11-3.0' mircookie libunwind-ptrace gdk-pixbuf-2.0 xf86vidmodeproto xtrans lapack caca damageproto Qt5Sql libpulse kbproto expat videoproto cairo-xlib gnutls-dane xf86dgaproto valgrind bluez fontutil xcb-dri2 xcb-dri3 panel libtcmalloc_minimal randrproto Qt5QuickTest xrandr wayland-egl dleyna-server-1.0 bash-completion Qt5Sensors Qt5Quick scrnsaverproto xcomposite libtasn1 sdl dri2proto icu-i18n sm cwiid xorg-sgml-doctools cairo-ps p11-kit-1 libpulse-mainloop-glib fixesproto protobuf-lite Qt5Positioning mirclient gmodule-2.0 gdk-pixbuf-xlib-2.0 SDL2_ttf libdrm_radeon libdrm slang libpulse-simple pango Qt5WebEngineCore geoclue-2.0 flac libsodium pangoft2 atspi-2 fontsproto gobject-introspection-no-export-1.0 gdk-3.0 jack compositeproto panelw openblas icu-uc libsystemd xf86bigfontproto Qt5PrintSupport blas-openblas Qt5Test libpcre libpcre16 xineramaproto webkit2gtk-4.0 cairo-xcb-shm glproto cairo-pdf pangocairo Qt5QuickWidgets dmxproto Qt5Core x11-xcb libpq gthread-2.0 xcb-glx 'gtk+-broadway-3.0' Qt5Svg wayland-protocols libssl xf86driproto libpcrecpp cairo-xcb menu gl ibus-table egl libxml-2.0 libcrypto libdrm_nouveau alsa yelp-xsl sndfile cairo-gobject gmodule-no-export-2.0 wayland-client libtcmalloc_minimal_debug xextproto libdrm_amdgpu x11 xtst bigreqsproto gobject-introspection-1.0 libpcre32 gsl Qt5UiTools hogweed javascriptcoregtk-4.0 poppler-data gdk-broadway-3.0 wayland-server libsoup-2.4 resourceproto xi dleyna-server-service-1.0 vte-2.91 Qt5Xml libR udev xbitmaps xt cairo-fc xv glib-2.0 cairo Qt5Qml gdk-wayland-3.0 mirclientcpp Qt5Network icu-io cairo-ft xcb-sync gio-unix-2.0 vorbisfile Qt5WebSockets glesv2 Qt5WebKitWidgets libglvnd 'ncurses++w' xfixes vorbisenc presentproto xcb-xfixes 'gtk+-unix-print-3.0' tic sdl2 xinerama epoxy Qt5Help tinfo Qt5WebEngine formw libpng usbutils blas-netlib Qt5Gui 'gtk+-wayland-3.0' xshmfence xcb-randr libudev freetype2 cairo-script xext libjpeg harfbuzz dleyna-connector-dbus-1.0 xau fftw3f xcb-present ice xdamage atk fftw3l openssl xkbcomp xxf86vm libuv fftw3q webkit2gtk-web-extension-4.0 vorbis ncursesw icu-le libffi wayland-scanner libunwind-coredump xkeyboard-config xcb-shape harfbuzz-icu pthread-stubs 'caca++' shared-mime-info xrender xproto windowswmproto inputproto icu-lx xcb-shm xscrnsaver libpng16 libunwind-generic protobuf xcb mircore Qt5OpenGL graphite2 liblzma gdk-x11-3.0 Qt5Designer ogg Qt5WebEngineWidgets ncurses form fontconfig cairo-xlib-xrender 'gtk+-3.0' ruby-2.5 avahi-client harfbuzz-gobject libquvi-scripts-0.9 Qt5OpenGLExtensions zlib libcap-ng libprofiler Qt5Widgets 'ncurses++' icu-le-hb menuw gobject-2.0 m17n-db Qt5Concurrent libidn2 gio-2.0 ruby xdmcp blas renderproto
Resolving dependencies...

...

Component graph for cabal-fmt-0.1.2:
    component lib:cabal-fmt-internal
    component exe:cabal-fmt dependency lib:cabal-fmt-internal
component cabal-fmt-0.1.2-l-cabal-fmt-internal-8d2c179fafc0fc2ee981d1643c9406f510a950efa27b0601abe3319835e09497
    include Cabal-3.0.2.0-b8550634597a8e937a50e21f04fdf39ab34ebdd0442db0caca9fe4722f1dfaab
    include base-4.12.0.0
    include bytestring-0.10.8.2
    include containers-0.6.0.1
    include directory-1.3.3.0
    include filepath-1.4.2.1
    include mtl-2.2.2
    include parsec-3.1.13.0
    include pretty-1.1.3.6
unit cabal-fmt-0.1.2-l-cabal-fmt-internal-8d2c179fafc0fc2ee981d1643c9406f510a950efa27b0601abe3319835e09497
    include Cabal-3.0.2.0-b8550634597a8e937a50e21f04fdf39ab34ebdd0442db0caca9fe4722f1dfaab
    include base-4.12.0.0
    include bytestring-0.10.8.2
    include containers-0.6.0.1
    include directory-1.3.3.0
    include filepath-1.4.2.1
    include mtl-2.2.2
    include parsec-3.1.13.0
    include pretty-1.1.3.6
    CabalFmt=cabal-fmt-0.1.2-l-cabal-fmt-internal-8d2c179fafc0fc2ee981d1643c9406f510a950efa27b0601abe3319835e09497:CabalFmt,CabalFmt.Comments=cabal-fmt-0.1.2-l-cabal-fmt-internal-8d2c179fafc0fc2ee981d1643c9406f510a950efa27b0601abe3319835e09497:CabalFmt.Comments,CabalFmt.Error=cabal-fmt-0.1.2-l-cabal-fmt-internal-8d2c179fafc0fc2ee981d1643c9406f510a950efa27b0601abe3319835e09497:CabalFmt.Error,CabalFmt.Fields=cabal-fmt-0.1.2-l-cabal-fmt-internal-8d2c179fafc0fc2ee981d1643c9406f510a950efa27b0601abe3319835e09497:CabalFmt.Fields,CabalFmt.Fields.BuildDepends=cabal-fmt-0.1.2-l-cabal-fmt-internal-8d2c179fafc0fc2ee981d1643c9406f510a950efa27b0601abe3319835e09497:CabalFmt.Fields.BuildDepends,CabalFmt.Fields.Extensions=cabal-fmt-0.1.2-l-cabal-fmt-internal-8d2c179fafc0fc2ee981d1643c9406f510a950efa27b0601abe3319835e09497:CabalFmt.Fields.Extensions,CabalFmt.Fields.Modules=cabal-fmt-0.1.2-l-cabal-fmt-internal-8d2c179fafc0fc2ee981d1643c9406f510a950efa27b0601abe3319835e09497:CabalFmt.Fields.Modules,CabalFmt.Fields.TestedWith=cabal-fmt-0.1.2-l-cabal-fmt-internal-8d2c179fafc0fc2ee981d1643c9406f510a950efa27b0601abe3319835e09497:CabalFmt.Fields.TestedWith,CabalFmt.Monad=cabal-fmt-0.1.2-l-cabal-fmt-internal-8d2c179fafc0fc2ee981d1643c9406f510a950efa27b0601abe3319835e09497:CabalFmt.Monad,CabalFmt.Options=cabal-fmt-0.1.2-l-cabal-fmt-internal-8d2c179fafc0fc2ee981d1643c9406f510a950efa27b0601abe3319835e09497:CabalFmt.Options,CabalFmt.Parser=cabal-fmt-0.1.2-l-cabal-fmt-internal-8d2c179fafc0fc2ee981d1643c9406f510a950efa27b0601abe3319835e09497:CabalFmt.Parser,CabalFmt.Pragma=cabal-fmt-0.1.2-l-cabal-fmt-internal-8d2c179fafc0fc2ee981d1643c9406f510a950efa27b0601abe3319835e09497:CabalFmt.Pragma,CabalFmt.Refactoring=cabal-fmt-0.1.2-l-cabal-fmt-internal-8d2c179fafc0fc2ee981d1643c9406f510a950efa27b0601abe3319835e09497:CabalFmt.Refactoring

component cabal-fmt-0.1.2-e-cabal-fmt-36ae38b678109b7b041bc0189e915707554863572ce27c9207a51b3f9c1ac329
    include base-4.12.0.0
    include bytestring-0.10.8.2
    include cabal-fmt-0.1.2-l-cabal-fmt-internal-8d2c179fafc0fc2ee981d1643c9406f510a950efa27b0601abe3319835e09497
    include directory-1.3.3.0
    include filepath-1.4.2.1
    include optparse-applicative-0.15.1.0-646da4e32bd9785c99fa2e2ee91a8048c108cf144b43e2dfc80a90fe4b50209e
unit cabal-fmt-0.1.2-e-cabal-fmt-36ae38b678109b7b041bc0189e915707554863572ce27c9207a51b3f9c1ac329
    include base-4.12.0.0
    include bytestring-0.10.8.2
    include cabal-fmt-0.1.2-l-cabal-fmt-internal-8d2c179fafc0fc2ee981d1643c9406f510a950efa27b0601abe3319835e09497
    include directory-1.3.3.0
    include filepath-1.4.2.1
    include optparse-applicative-0.15.1.0-646da4e32bd9785c99fa2e2ee91a8048c108cf144b43e2dfc80a90fe4b50209e

cabal: Cannot build all the executables in the project because none of the
packages contain any executables. Check the .cabal files for the packages and
make sure that they properly declare the components that you expect.

So clearly the tarball is downloaded and solver is run (successfully) , but then something goes wrong.

fgaz commented 2 years ago

Removing this line fixes the problem, but probably breaks something else

https://github.com/haskell/cabal/blob/25589279336976bb20c1bbf9291650f11ba1a6fc/cabal-install/src/Distribution/Client/ProjectOrchestration.hs#L600=

Mikolaj commented 2 years ago

Huh, strangely this code and the code it calls ~2 levels deep hasn't been changed in 5 years.

dcoutts commented 1 year ago

The issue is that in the v2 commands, all the targets are expected to refer to things within the project. So though we can have remote urls as things defined in the cabal.project file, on the command line those would be referred to by package name not their original URL.

The conceptual mismatch here is that users sometimes want to install something that isn't defined in their project. It's a UI/UX question of what we should do in that case. Perhaps an error message to advise the user to add the target into their cabal.project file, and then use build (for local) or install (for user wide).