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

Moving a stack directory tree #4530

Closed
dgh1000 opened this issue Jan 23, 2019 · 7 comments
Closed

Moving a stack directory tree #4530

dgh1000 opened this issue Jan 23, 2019 · 7 comments

Comments

@dgh1000
Copy link

dgh1000 commented Jan 23, 2019

Can a stack project directory tree be moved to another location? I tried it, and a lot of stuff broke. It seems unable to find the 'src' directory when doing a "stack build". Not sure what I need to do or if I messed something else up another way.

Intero on Emacs also broke. When loading a file from the new location, it just gave an error about being unable to start intero.

Mike

@mihaimaruseac
Copy link
Contributor

You can try using --stack-root, for example stack --stack-root=/tmp/new-dir build, but make sure you use an absolute path.

Would be able to provide more information if you give more details, such as what you're running and what errors you get

@dgh1000
Copy link
Author

dgh1000 commented Jan 23, 2019

First I'm just asking if it's supposed to be possible. I just want to move it to a new location and use it there in the same way as before.

So is it supposed to work that way, or does the stack configuration have absolute paths stored in it?

@mihaimaruseac
Copy link
Contributor

mihaimaruseac commented Jan 23, 2019

See --stack-root, --stack-yaml, #4378, #2205, #990, #4032 and https://github.com/bitemyapp/makefiles/blob/master/Haskell.makefile

Together, these options should provide what you need, based on what little information was provided

@dgh1000
Copy link
Author

dgh1000 commented Jan 23, 2019

I'm confused. I'm asking a yes or no question. If it doesn't just work to move a project to a new location, then the answer is "no". If all these things you are providing are necessary, then it sounds like it doesn't simply work. So is the answer "No"?

To clarify, previously I have always built a stack project by cd'ing to somewhere in the tree and typing "stack build." It has never been necessary to specify --stack-root, change any makefiles, etc. So what I'm asking is whether that is supposed to work when I've moved the stack project location. Again, if you are providing six suggestions, then it sounds like you are saying "no", but please clarify.

@mihaimaruseac
Copy link
Contributor

There are multiple ways your question can be interpreted and you refuse to clarify. So I gave options for all of those.

Perhaps you want to do the following?

[4530] λ stack new test
...
Writing configuration to file: test/stack.yaml
All done.
[4530] λ cd test
[test] λ stack build
Building all executables for `test' once. After a successful build of all of them, only specified executables will be rebuilt.
...
Registering library for test-0.1.0.0..
[test] λ cd ..
[4530] λ mv test test-2
[4530] λ cd test-2
[test-2] λ stack build
test-0.1.0.0: unregistering (switching from /tmp/mm/4530/test/ to /tmp/mm/4530/test-2/)
...
Registering library for test-0.1.0.0..

Or maybe instead of moving source code to a different location you only want the directory that stack uses or the stack.yaml file to be in some other location? Or maybe you want two different directories for stack generated artefacts to have different compilation options and not rebuild between them? Or maybe you want to generate the final binary in a different location than the normal one, by changing a prefix of the install path?

Without knowing exactly what you want since you refuse to clarify, it's hard to reply

@dgh1000
Copy link
Author

dgh1000 commented Jan 23, 2019

Although my question may not have been 100% clear, that's still an insulting way to respond to me. Asking if there are absolute paths in the stack configuration should have made my question clear for anyone still wondering what I was asking.

We'll try this a different way.

I created a stack project as follows:
cd /Users/Mike/stack
stack init A

A project can be built via
cd /Users/Mike/stack/A
stack build

Later I did
cd /Users/Mike/stack
mv A ../B
cd A ../B
stack build

is that supposed to break it? There's no point to chasing down any possible bugs or workarounds until I get a clear understanding of that.

@mihaimaruseac
Copy link
Contributor

mihaimaruseac commented Jan 23, 2019

Thank you for clarifying what you have done. You should have provided that in the opening of the issue instead of making us guess.

Anyway, that is the example i showed in my last comment and code compiled successfully even after the move.

Closing this as your question is now answered. Feel free to reopen if you have more information, and please provide more logs and output of errors if you reopen.

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

3 participants