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

Stack rebuilds project when its location in the file-system is changed #3461

Closed
vlopezj opened this issue Sep 29, 2017 · 1 comment
Closed

Comments

@vlopezj
Copy link

vlopezj commented Sep 29, 2017

stack will recompile packages when the root of a project is moved. This hinders use cases where, in a CI system, a big project is recompiled each time in a different directory, but one would still like to cache the .stack-work directory to speed-up builds.

A possible solution is to use relative rather than absolute paths for directories that are at the same level or below the stack.yaml file. Keep paths that are specified as absolute in the stack.yaml file as absolute, and ditto for relative paths.

Steps to reproduce

  1. Go into any stack project, remove .stack-work directory.
  2. Run command stack build
  3. Stuff happens.
  4. Run command stack build again.
  5. Nothing happens, because all the work has been done already.
  6. Go to parent directory. Rename the directory containing the stack project to something else.
  7. Go back into the stack project.
  8. Run stack buildagain.

Expected

Nothing happens, because there is no more work to do.

Actual

<project-name>-<project-version>: unregistering (switching from <old-dir-name> to <new-dir-name>)

Afterwards the entire project is recompiled.

Stack version

$ stack --version
Version 1.5.1 x86_64

Installed via stack upgrade.

@mgsloan
Copy link
Contributor

mgsloan commented Sep 29, 2017

I understand the desire to be able to do this. Unfortunately it is not feasible for a couple reasons:

  • Cabal generates a Paths_* module for each package which includes absolute paths to the install location. This kinda sucks, but it's how things work currently. See this issue about making packages relocatable - Support relocatable packages haskell/cabal#462
  • In Local version of package is not rebuild / removed #2147 , there's an issue where changing package location is included in the project doesn't cause rebuild. This is because each package got built and so is considered to be not dirty. Fix for now is to pay attention to if the path changed.

It would take quite a bit of upstream and stack work to make this happen.

This hinders use cases where, in a CI system, a big project is recompiled each time in a different directory, but one would still like to cache the .stack-work directory to speed-up builds.

Why is this happening? I don't get it, why would you recompile it with different directoreis? You should be able to cache .stack-work directories. Note that you will also probably want to cache the ones that are relative to the package dirs themselves.

Closing as wontfix for now.

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

No branches or pull requests

2 participants