Skip to content

Addition of ‘--work-dir’ option to override working directory, #1178 #1442

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

Merged

Conversation

mrkkrp
Copy link
Collaborator

@mrkkrp mrkkrp commented Nov 28, 2015

Here I've started to work on this. Currently I've added --work-dir option represented by globalWorkDir in GlobalOpts. Please correct me if this is a wrong place to put this option.

Now my plan is:

  1. Store this option is Stack monadic environment (Config?), so functions that need to know stack working directory could query it. I think HasConfig env, MonadReader env can be used.
  2. Instead of workDirRel constant, use that value from config, this will probably add HasConfig, MonadReader env or similar constraint to some functions that previously didn't need it.
  3. Take care of ignoreDirs which specifies which directories shouldn't be searched for .cabal files. It currently lists ".stack-work". With this change it would need to construct the list more “dynamically”.

My questions:

  1. Is GlobalOpts is the right place to add --work-dir option?
  2. In case GlobalOpts is the right place, where is the best place to pass the value globalWorkDir from GlobalOpts to Config so the rest of Stack can query it?

Well, the rest seems to be pretty easy to do (at least for now).

@mgsloan
Copy link
Contributor

mgsloan commented Nov 30, 2015

Take care of ignoreDirs which specifies which directories shouldn't be searched for .cabal files. It currently lists ".stack-work". With this change it would need to construct the list more “dynamically”.

I don't think this is necessary.

  1. Is GlobalOpts is the right place to add --work-dir option?
  2. In case GlobalOpts is the right place, where is the best place to pass the value globalWorkDir from GlobalOpts to Config so the rest of Stack can query it?

How about adding it directly to Config / ConfigMonoid ? This'd mean that it'd also be a stack.yaml field, which could certainly have its uses (ensuring that different dist dirs are used for two different configs)

@mrkkrp
Copy link
Collaborator Author

mrkkrp commented Nov 30, 2015

Good, I'll take that direction.

@mrkkrp mrkkrp force-pushed the mrkkrp-configurable-stack-work branch 3 times, most recently from 0c635b6 to 438032d Compare November 30, 2015 14:46
@mrkkrp
Copy link
Collaborator Author

mrkkrp commented Nov 30, 2015

Seems to work! That was fun, please review.

Originally it was hard-coded as ‘.stack-work’. Now the directory can
also be specified in ‘stack.yaml’ file.
@mrkkrp mrkkrp force-pushed the mrkkrp-configurable-stack-work branch from 438032d to a9185c8 Compare November 30, 2015 15:52
mgsloan added a commit that referenced this pull request Dec 1, 2015
Addition of ‘--work-dir’ option to override working directory, #1178
@mgsloan mgsloan merged commit 2230f34 into commercialhaskell:master Dec 1, 2015
@mgsloan
Copy link
Contributor

mgsloan commented Dec 1, 2015

LGTM, thanks!

@mrkkrp mrkkrp deleted the mrkkrp-configurable-stack-work branch December 1, 2015 11:14
@lukexi
Copy link
Contributor

lukexi commented Dec 10, 2015

Hmm, I'm confused as to why this is restricted to child directories of the current directory. In my use-case I'd like to use ".." as the .stack-work directory for a set of uncoupled but related projects, but this is disallowed by parseRelDir since:
commercialhaskell/path@87a56a9

@mrkkrp
Copy link
Collaborator Author

mrkkrp commented Dec 10, 2015

@lukexi, See this discussion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants