Skip to content

Commit 5da4033

Browse files
committed
Make ‘cabal exec’ not pass -package-env to called executable
It never did previously and it’s a bug that it started to.
1 parent 413621c commit 5da4033

File tree

6 files changed

+53
-5
lines changed

6 files changed

+53
-5
lines changed

cabal-install/src/Distribution/Client/CmdExec.hs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -200,16 +200,13 @@ execAction flags extraArgs globalFlags = do
200200

201201
( if envFilesSupported
202202
then withTempEnvFile verbosity baseCtx buildCtx buildStatus
203-
else \f ->
204-
if programIsConfiguredCompiler
205-
then f environmentPackageArgs []
206-
else f [] []
203+
else \f -> f environmentPackageArgs []
207204
)
208205
$ \argOverrides envOverrides -> do
209206
let program' =
210207
withOverrides
211208
envOverrides
212-
argOverrides
209+
(if programIsConfiguredCompiler then argOverrides else [])
213210
program
214211
invocation = programInvocation program' args
215212
dryRun =
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
2+
module Main (main) where
3+
4+
import System.Environment
5+
import System.Exit
6+
import System.IO
7+
8+
main :: IO ()
9+
main = do
10+
args <- getArgs
11+
case args of
12+
["--required", "foo"] -> pure ()
13+
other -> die $ "Unexpected arguments: " ++ show other
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# cabal v2-build
2+
Resolving dependencies...
3+
Build profile: -w ghc-<GHCVER> -O1
4+
In order, the following will be built:
5+
- my-0.1 (exe:my-executable) (first run)
6+
Configuring executable 'my-executable' for my-0.1...
7+
Preprocessing executable 'my-executable' for my-0.1...
8+
Building executable 'my-executable' for my-0.1...
9+
# cabal v2-exec
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
packages: .
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
2+
import Test.Cabal.Prelude
3+
4+
main :: IO ()
5+
main = cabalTest $ do
6+
cabal "v2-build" ["my:exe:my-executable"]
7+
8+
withPlan $ do
9+
exePath <- planExePath "my" "my-executable"
10+
11+
-- The test is to check that we’re not acceidentally passing more
12+
-- than expected.
13+
--
14+
-- Target executable may not accept any extra option cabal may pass.
15+
-- Or it may and it would lead to incorrect results and lengthy
16+
-- debugging, which is worse.
17+
cabal "v2-exec" [exePath, "--", "--required", "foo"]
18+
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
cabal-version: 3.0
2+
name: my
3+
version: 0.1
4+
license: BSD-3-Clause
5+
build-type: Simple
6+
7+
executable my-executable
8+
main-is: Main.hs
9+
build-depends: base
10+
default-language: Haskell2010

0 commit comments

Comments
 (0)