General summary/comments (optional)
When, at the top level of my project, I symlink to a stack.yaml in a
subdir, the way stack interprets the paths in that stack.yaml
depends on whether I explicitly tell stack where to find the YAML
file. I.e., a plain stack build succeeds, interpreting the paths in
the YAML file relative to the location of the symlink, whereas
the explicit stack --stack-yaml=stack.yaml build and
STACK_YAML=stack.yaml stack build both fail, interpreting the paths
in the YAML file relative the location of the target of the
symlink.
I would prefer that all three invocations interpret the paths relative
the location of the symlink -- because that avoids having to add a
bunch of ../ prefixes, and makes the actual YAML file robust to
mvs as long as the symlink is updated accordingly -- but the bug is
that the three invocations don't all behave the same.
Steps to reproduce
$ stack --version
Version 1.7.1, Git revision 681c800873816c022739ca7ed14755e85a579565 (5807 commits) x86_64 hpack-0.28.2
# Create a dir to work in
$ mkdir -p /var/tmp/tmp/stack-symlink-path-bug
$ cd /var/tmp/tmp/stack-symlink-path-bug
# Download a package to refer to in the stack.yaml file
$ stack unpack microlens --to deps
# Create stack.yaml
$ stack init --resolver lts-11.9
$ grep -v '^#' stack.yaml
resolver: lts-11.9
packages:
- deps/microlens-0.4.9.1
# Move stack.yaml into subdir and create a symlink to it at top level
$ mkdir stack-yamls
$ mv stack.yaml stack-yamls
$ ln -s stack-yamls/stack.yaml ./
# Build with implicit stack.yaml: success
$ stack build
[success]
# Build with explicit stack.yaml: failure
$ stack --stack-yaml=stack.yaml build
/var/tmp/tmp/stack-symlink-path-bug/stack-yamls/deps/microlens-0.4.9.1/: getDirectoryContents:openDirStream: does not exist (No such file or directory)
# Build with explicit stack.yaml: failure
$ STACK_YAML=stack.yaml stack build
Getting project config file from STACK_YAML environment
/var/tmp/tmp/stack-symlink-path-bug/stack-yamls/deps/microlens-0.4.9.1/: getDirectoryContents:openDirStream: does not exist (No such file or directory)
Expected
I expect that all three stack build invocations would behave the same.
Actual
The stack build using the implicit stack.yaml behaves differently
from the two stack build invocations with an explicit stack.yaml.
Method of installation
Via stack upgrade.
General summary/comments (optional)
When, at the top level of my project, I symlink to a
stack.yamlin asubdir, the way
stackinterprets the paths in thatstack.yamldepends on whether I explicitly tell
stackwhere to find the YAMLfile. I.e., a plain
stack buildsucceeds, interpreting the paths inthe YAML file relative to the location of the symlink, whereas
the explicit
stack --stack-yaml=stack.yaml buildandSTACK_YAML=stack.yaml stack buildboth fail, interpreting the pathsin the YAML file relative the location of the target of the
symlink.
I would prefer that all three invocations interpret the paths relative
the location of the symlink -- because that avoids having to add a
bunch of
../prefixes, and makes the actual YAML file robust tomvs as long as the symlink is updated accordingly -- but the bug isthat the three invocations don't all behave the same.
Steps to reproduce
Expected
I expect that all three
stack buildinvocations would behave the same.Actual
The
stack buildusing the implicitstack.yamlbehaves differentlyfrom the two
stack buildinvocations with an explicitstack.yaml.Method of installation
Via
stack upgrade.