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

print out dependency build failure during cabal build / repl #8296

Merged
merged 1 commit into from
Oct 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cabal-install/src/Distribution/Client/CmdBuild.hs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ defaultBuildFlags = BuildFlags
--
buildAction :: NixStyleFlags BuildFlags -> [String] -> GlobalFlags -> IO ()
buildAction flags@NixStyleFlags { extraFlags = buildFlags, ..} targetStrings globalFlags
= withContextAndSelectors RejectNoTargets Nothing flags targetStrings globalFlags $ \targetCtx ctx targetSelectors -> do
= withContextAndSelectors RejectNoTargets Nothing flags targetStrings globalFlags BuildCommand $ \targetCtx ctx targetSelectors -> do
-- TODO: This flags defaults business is ugly
let onlyConfigure = fromFlag (buildOnlyConfigure defaultBuildFlags
<> buildOnlyConfigure buildFlags)
Expand Down
3 changes: 2 additions & 1 deletion cabal-install/src/Distribution/Client/CmdHaddockProject.hs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import qualified Distribution.Client.NixStyleOptions as NixStyleOptions
import Distribution.Client.ProjectOrchestration
(AvailableTarget(..)
,AvailableTargetStatus(..)
,CurrentCommand(..)
,ProjectBaseContext(..)
,ProjectBuildContext(..)
,TargetSelector(..)
Expand Down Expand Up @@ -141,7 +142,7 @@ haddockProjectAction flags _extraArgs globalFlags = do
-- we need.
--

withContextAndSelectors RejectNoTargets Nothing nixFlags ["all"] globalFlags $ \targetCtx ctx targetSelectors -> do
withContextAndSelectors RejectNoTargets Nothing nixFlags ["all"] globalFlags HaddockCommand $ \targetCtx ctx targetSelectors -> do
baseCtx <- case targetCtx of
ProjectContext -> return ctx
GlobalContext -> return ctx
Expand Down
2 changes: 1 addition & 1 deletion cabal-install/src/Distribution/Client/CmdListBin.hs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ listbinAction flags@NixStyleFlags{..} args globalFlags = do
_ -> die' verbosity "One target is required, given multiple"

-- configure and elaborate target selectors
withContextAndSelectors RejectNoTargets (Just ExeKind) flags [target] globalFlags $ \targetCtx ctx targetSelectors -> do
withContextAndSelectors RejectNoTargets (Just ExeKind) flags [target] globalFlags OtherCommand $ \targetCtx ctx targetSelectors -> do
baseCtx <- case targetCtx of
ProjectContext -> return ctx
GlobalContext -> return ctx
Expand Down
2 changes: 1 addition & 1 deletion cabal-install/src/Distribution/Client/CmdRepl.hs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ replCommand = Client.installCommand {
--
replAction :: NixStyleFlags (ReplOptions, EnvFlags) -> [String] -> GlobalFlags -> IO ()
replAction flags@NixStyleFlags { extraFlags = (replOpts, envFlags), ..} targetStrings globalFlags
= withContextAndSelectors AcceptNoTargets (Just LibKind) flags targetStrings globalFlags $ \targetCtx ctx targetSelectors -> do
= withContextAndSelectors AcceptNoTargets (Just LibKind) flags targetStrings globalFlags ReplCommand $ \targetCtx ctx targetSelectors -> do
when (buildSettingOnlyDeps (buildSettings ctx)) $
die' verbosity $ "The repl command does not support '--only-dependencies'. "
++ "You may wish to use 'build --only-dependencies' and then "
Expand Down
2 changes: 1 addition & 1 deletion cabal-install/src/Distribution/Client/CmdRun.hs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ runCommand = CommandUI
--
runAction :: NixStyleFlags () -> [String] -> GlobalFlags -> IO ()
runAction flags@NixStyleFlags {..} targetAndArgs globalFlags
= withContextAndSelectors RejectNoTargets (Just ExeKind) flags targetStr globalFlags $ \targetCtx ctx targetSelectors -> do
= withContextAndSelectors RejectNoTargets (Just ExeKind) flags targetStr globalFlags OtherCommand $ \targetCtx ctx targetSelectors -> do
(baseCtx, defaultVerbosity) <- case targetCtx of
ProjectContext -> return (ctx, normal)
GlobalContext -> return (ctx, normal)
Expand Down
4 changes: 2 additions & 2 deletions cabal-install/src/Distribution/Client/ProjectOrchestration.hs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ import System.Posix.Signals (sigKILL, sigSEGV)

-- | Tracks what command is being executed, because we need to hide this somewhere
-- for cases that need special handling (usually for error reporting).
data CurrentCommand = InstallCommand | HaddockCommand | OtherCommand
data CurrentCommand = InstallCommand | HaddockCommand | BuildCommand | ReplCommand | OtherCommand
deriving (Show, Eq)

-- | This holds the context of a project prior to solving: the content of the
Expand Down Expand Up @@ -1152,7 +1152,7 @@ dieOnBuildFailures verbosity currentCommand plan buildOutcomes
, [pkg] <- rootpkgs
, installedUnitId pkg == pkgid
, isFailureSelfExplanatory (buildFailureReason failure)
, currentCommand /= InstallCommand
, currentCommand `notElem` [InstallCommand, BuildCommand, ReplCommand]
= True
| otherwise
= False
Expand Down
7 changes: 4 additions & 3 deletions cabal-install/src/Distribution/Client/ScriptUtils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,11 @@ withContextAndSelectors
-> NixStyleFlags a -- ^ Command line flags
-> [String] -- ^ Target strings or a script and args.
-> GlobalFlags -- ^ Global flags.
-> CurrentCommand -- ^ Current Command (usually for error reporting).
-> (TargetContext -> ProjectBaseContext -> [TargetSelector] -> IO b)
-- ^ The body of your command action.
-> IO b
withContextAndSelectors noTargets kind flags@NixStyleFlags {..} targetStrings globalFlags act
withContextAndSelectors noTargets kind flags@NixStyleFlags {..} targetStrings globalFlags cmd act
= withTemporaryTempDirectory $ \mkTmpDir -> do
(tc, ctx) <- withProjectOrGlobalConfig verbosity ignoreProject globalConfigFlag with (without mkTmpDir)

Expand Down Expand Up @@ -209,11 +210,11 @@ withContextAndSelectors noTargets kind flags@NixStyleFlags {..} targetStrings gl
defaultTarget = [TargetPackage TargetExplicitNamed [fakePackageId] Nothing]

with = do
ctx <- establishProjectBaseContext verbosity cliConfig OtherCommand
ctx <- establishProjectBaseContext verbosity cliConfig cmd
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And also a good catch.

return (ProjectContext, ctx)
without mkDir globalConfig = do
distDirLayout <- establishDummyDistDirLayout verbosity (globalConfig <> cliConfig) =<< mkDir
ctx <- establishDummyProjectBaseContext verbosity (globalConfig <> cliConfig) distDirLayout [] OtherCommand
ctx <- establishDummyProjectBaseContext verbosity (globalConfig <> cliConfig) distDirLayout [] cmd
return (GlobalContext, ctx)
scriptOrError script err = do
exists <- doesFileExist script
Expand Down
1 change: 1 addition & 0 deletions cabal-testsuite/PackageTests/CustomWithoutCabal/cabal.out
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ Resolving dependencies...
Build profile: -w ghc-<GHCVER> -O1
In order, the following will be built:
- custom-setup-without-cabal-1.0 (lib:custom-setup-without-cabal) (first run)
Error: cabal: Failed to build custom-setup-without-cabal-1.0-inplace. The failure occurred during the configure step.
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ Resolving dependencies...
Build profile: -w ghc-<GHCVER> -O1
In order, the following will be built:
- custom-setup-without-cabal-defaultMain-1.0 (lib:custom-setup-without-cabal-defaultMain) (first run)
Error: cabal: Failed to build custom-setup-without-cabal-defaultMain-1.0-inplace. The failure occurred during the configure step.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ In order, the following will be built:
Configuring executable 'q' for q-0.1.0.0..
Preprocessing executable 'q' for q-0.1.0.0..
Building executable 'q' for q-0.1.0.0..
Error: cabal: Failed to build q-0.1.0.0-inplace-q.
# cabal v2-build
Resolving dependencies...
Build profile: -w ghc-<GHCVER> -O1
Expand Down
1 change: 1 addition & 0 deletions cabal-testsuite/PackageTests/NewHaddock/Fails/cabal.out
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ In order, the following will be built:
Configuring library for example-1.0..
Preprocessing library for example-1.0..
Building library for example-1.0..
Error: cabal: Failed to build example-1.0-inplace.
# cabal v2-haddock
Build profile: -w ghc-<GHCVER> -O1
In order, the following will be built:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Building library for CompileFail-0.1.0.0..
Configuring test suite 'CompileFail-test' for CompileFail-0.1.0.0..
Preprocessing test suite 'CompileFail-test' for CompileFail-0.1.0.0..
Building test suite 'CompileFail-test' for CompileFail-0.1.0.0..
Error: cabal: Failed to build CompileFail-0.1.0.0-inplace-CompileFail-test.
# cabal build
Build profile: -w ghc-<GHCVER> -O1
In order, the following will be built:
Expand Down