Skip to content

Commit

Permalink
Minor fixes post merge of PR #1780
Browse files Browse the repository at this point in the history
- changed the order of stack init options help - bring DIRS to front
- add a note in the doc guide
  • Loading branch information
harendra-kumar committed Feb 11, 2016
1 parent 218e7dd commit 239b378
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 16 deletions.
16 changes: 10 additions & 6 deletions doc/GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,7 @@ stack init does quite a few things for you behind the scenes:
nightly, other LTS versions in that order

Assuming it finds a match, it will write your stack.yaml file, and everything
will work.
will work.

#### External Dependencies

Expand Down Expand Up @@ -737,7 +737,7 @@ Selecting the best among 6 snapshots...
.
Selected resolver: lts-4.1
*** Resolver lts-4.1 will need external packages:
*** Resolver lts-4.1 will need external packages:
acme-missiles not found
- yackage requires -any
- yackage flags: upload = True
Expand Down Expand Up @@ -803,7 +803,7 @@ Selecting the best among 6 snapshots...
*** Failed to arrive at a workable build plan.
*** Ignoring package: yackage-test
*** Resolver lts-4.2 will need external packages:
*** Resolver lts-4.2 will need external packages:
acme-missiles not found
- yackage requires ==0.3
- yackage flags: upload = True
Expand Down Expand Up @@ -840,7 +840,7 @@ the other one.
Packages may get excluded due to conflicting requirements among user packages
or due to conflicting requirements between a user package and the resolver
compiler. If all of the packages have a conflict with the compiler then all of
them may get commented out.
them may get commented out.

When packages are commented out you will see a warning every time you run a
command which needs the config file. The warning can be disabled by editing the
Expand All @@ -863,6 +863,10 @@ You can install the required compiler if not already installed by using the

#### Miscellaneous and diagnostics

_Add selected packages_: If you want to use only selected packages from your
project directory you can do so by explicitly specifying the package directories
on the command line.

_Duplicate package names_: If multiple packages under the directory tree have
same name, stack init will report those and automatically ignore one of them.

Expand All @@ -875,8 +879,8 @@ a cabal package file. You may want to pay attention to the warnings as
sometimes they may result in incomprehensible errors later on during dependency
solving.

_Packages with no names_: If the `Name` field in a cabal file is empty or not
present then stack init will refuse to continue.
_Package naming_: If the `Name` field defined in a cabal file does not match
with the cabal file name then `stack init` will refuse to continue.

_Cabal install errors_: stack init uses `cabal-install` to determine external
dependencies. When cabal-install encounters errors, cabal errors are displayed
Expand Down
15 changes: 7 additions & 8 deletions src/Stack/Init.hs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ initProject
initProject currDir initOpts mresolver = do
let dest = currDir </> stackDotYaml

dirs <- mapM (resolveDir' . T.unpack) (searchDirs initOpts)
reldest <- toFilePath `liftM` makeRelativeToCurrentDir dest

exists <- doesFileExist dest
Expand All @@ -66,12 +65,12 @@ initProject currDir initOpts mresolver = do
" exists, use 'stack solver' to fix the existing config file or \
\'--force' to overwrite it.")

dirs <- mapM (resolveDir' . T.unpack) (searchDirs initOpts)
let noPkgMsg = "In order to init, you should have an existing .cabal \
\file. Please try \"stack new\" instead."
let findCabalFiles' = findCabalFiles (includeSubDirs initOpts)
cabalfps <- if null dirs
then findCabalFiles' currDir
else liftM concat $ mapM findCabalFiles' dirs
find = findCabalFiles (includeSubDirs initOpts)
dirs' = if null dirs then [currDir] else dirs
cabalfps <- liftM concat $ mapM find dirs'
(bundle, dupPkgs) <- cabalPackagesCheck cabalfps noPkgMsg Nothing

(r, flags, extraDeps, rbundle) <- getDefaultResolver dest initOpts
Expand Down Expand Up @@ -438,14 +437,14 @@ getRecommendedSnapshots snapshots = do
]

data InitOpts = InitOpts
{ useSolver :: Bool
{ searchDirs :: ![T.Text]
-- ^ List of sub directories to search for .cabal files
, useSolver :: Bool
-- ^ Use solver to determine required external dependencies
, omitPackages :: Bool
-- ^ Exclude conflicting or incompatible user packages
, forceOverwrite :: Bool
-- ^ Overwrite existing stack.yaml
, includeSubDirs :: Bool
-- ^ If True, include all .cabal files found in any sub directories
, searchDirs :: ![T.Text]
-- ^ List of sub directories to search for .cabal files
}
4 changes: 2 additions & 2 deletions src/Stack/Options.hs
Original file line number Diff line number Diff line change
Expand Up @@ -675,9 +675,9 @@ globalOptsFromMonoid defaultTerminal GlobalOptsMonoid{..} = GlobalOpts

initOptsParser :: Parser InitOpts
initOptsParser =
InitOpts <$> solver <*> omitPackages
InitOpts <$> searchDirs
<*> solver <*> omitPackages
<*> overwrite <*> fmap not ignoreSubDirs
<*> searchDirs
where
searchDirs =
many (textArgument
Expand Down

0 comments on commit 239b378

Please sign in to comment.