cabal icon indicating copy to clipboard operation
cabal copied to clipboard

Cannot install only one of many executables in a package.

Open kindaro opened this issue 3 years ago • 8 comments

Describe the bug

I cannot install only one of many executables in a package. All of them get built and installed at once.

To Reproduce

Steps to reproduce the behavior:

Create a trivial package with 2 executables. Ask Cabal to install some one of them.

% cabal install example1 --installdir /tmp/executables
Wrote tarball sdist to /tmp/example/dist-newstyle/sdist/example-0.1.0.0.tar.gz
Resolving dependencies...
Up to date
Symlinking 'example1' to '/tmp/executables/example1'
Symlinking 'example2' to '/tmp/executables/example2'
% ls /tmp/executables
example1  example2

I never asked for example2!

Expected behavior

Exactly one executable that I named is built and installed.

System information

  • Standard issue Linux.
  • cabal-install version 3.8.1.0.

Additional context

This should have been solved in #6369?…

kindaro avatar Nov 22 '22 16:11 kindaro

have you tried using pkgname:exename syntax? i.e. cabal install mypackagename:example1 ?

gbaz avatar Nov 22 '22 16:11 gbaz

I tied various combinations of component selectors. It is not clear what the syntax of component selectors is in the first place. Last time I checked, the spelling and meaning of component selectors was not well documented.

  • example1
  • example:exe:example1
  • exe:example1
  • example:example1

— Neither of these work as expected.

I say all the ways to select the same component should work, and work to the same outcome. If you are saying that some of them work one way and others another, I say it is unexpected and confusing behaviour.

kindaro avatar Nov 22 '22 17:11 kindaro

#6369 was probably for remote packages. Can you try a package from hackage (or any other repo)?

fgaz avatar Nov 23 '22 06:11 fgaz

Yes, for packages on Hackage it works as expected… sorta… It does not accept the selector of form …:exe:…, only …:….

% cabal install gloss-examples:exe:gloss-lifespan --installdir /tmp/executables
Downloading gloss-examples:exe:gloss-lifespan
Error: cabal: '/usr/bin/curl' exited with an error:
curl: (3) URL using bad/illegal format or missing URL

% cabal install gloss-examples:gloss-lifespan --installdir /tmp/executables
Resolving dependencies...
Build profile: -w ghc-9.2.4 -O1
In order, the following will be built (use -v for more details):
 - OpenGL-3.0.3.0 (lib) (requires build)
 - GLUT-2.7.0.16 (lib) (requires build)
 - gloss-rendering-1.13.1.2 (lib) (requires build)
 - gloss-1.13.2.2 (lib) (requires build)
 - gloss-examples-1.13.0.4 (exe:gloss-lifespan) (requires download & build)
Downloading  gloss-examples-1.13.0.4
Starting     OpenGL-3.0.3.0 (lib)
Downloaded   gloss-examples-1.13.0.4
Building     OpenGL-3.0.3.0 (lib)
Installing   OpenGL-3.0.3.0 (lib)
Completed    OpenGL-3.0.3.0 (lib)
Starting     GLUT-2.7.0.16 (lib)
Building     GLUT-2.7.0.16 (lib)
Installing   GLUT-2.7.0.16 (lib)
Completed    GLUT-2.7.0.16 (lib)
Starting     gloss-rendering-1.13.1.2 (lib)
Building     gloss-rendering-1.13.1.2 (lib)
Installing   gloss-rendering-1.13.1.2 (lib)
Completed    gloss-rendering-1.13.1.2 (lib)
Starting     gloss-1.13.2.2 (lib)
Building     gloss-1.13.2.2 (lib)
Installing   gloss-1.13.2.2 (lib)
Completed    gloss-1.13.2.2 (lib)
Starting     gloss-examples-1.13.0.4 (exe:gloss-lifespan)
Building     gloss-examples-1.13.0.4 (exe:gloss-lifespan)
Installing   gloss-examples-1.13.0.4 (exe:gloss-lifespan)
Completed    gloss-examples-1.13.0.4 (exe:gloss-lifespan)
Symlinking 'gloss-lifespan' to '/tmp/executables/gloss-lifespan'
% l /tmp/executables
gloss-lifespan@

kindaro avatar Nov 23 '22 09:11 kindaro

Maintainers, please indicate to me the status of this issue. I answered your questions to the best of my ability. Now I need to know whether this issue will be worked on and what else I can do to help.

kindaro avatar Nov 23 '22 11:11 kindaro

@kindaro: metadata changes may not show up in notifications, so let me turn your attention to ^^^

We'd very much welcome a PR and it has some chance to get merged to cabal 3.10, depending on the review cycle.

Mikolaj avatar Dec 29 '22 10:12 Mikolaj

I can also repro this. This is an issue in Docker, where I'm only copying files related to executableA to maximize cache hits, but cabal is trying to build executableB and failing to find the files

brandonchinn178 avatar Jan 31 '23 18:01 brandonchinn178