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

pattern matching on symlinks use the final path of symlink ? #218

Closed
teto opened this issue Jul 2, 2020 · 4 comments
Closed

pattern matching on symlinks use the final path of symlink ? #218

teto opened this issue Jul 2, 2020 · 4 comments
Labels
type: bug Something isn't working

Comments

@teto
Copy link
Contributor

teto commented Jul 2, 2020

hi,

I have this folder with a bunch of folders and only one or 2 relevant to ghcide, e.g:

$ ls
_generated/
bazel-bin/ 
...
project/

What i would like to do is ignore all folders but "project". Hence I've written the following hie.yaml:

# Configuration for hie/ghcide.
# See https://github.com/mpickering/hie-bios/blob/master/README.md for the
# documentation
cradle:
    multi:
        # we default to none because of all the non-haskell folders at the root
        - path: "./"
          config: { cradle: { none:  } }
        - path: "./project"
          config:
              cradle:
                  bios:
                      program: ".hie-bios"
                      dependency-program: ".hie-bios-dependencies"

Now if I run $ hie-bios debug _generated/, I get the message Cradle failed to load. It looks like a real error since I see "No prefixes matched" but I would expec "./" to match ./_generated".

hie-bios debug _generated/
Cradle failed to load
Exit Code: ExitSuccess
Stderr: Multi Cradle: No prefixes matched
pwd: /home/teto/nova/jinko2
filepath: /nix/store/llxkyzbl2z06d5ndm2yp2cvl8fyfrxha-jinko-generated-folder
prefixes:
("./",None)
("./project",Bios {prog = ".hie-bios", depsProg = Just ".hie-bios-dependencies"})

Now relooking at the error, seems like it compares prefixes against the resolved filepath and because ./_generated is a symlink to /nix/store/llxkyzbl2z06d5ndm2yp2cvl8fyfrxha-jinko-generated-folder, it won't match the prefix. Is that correct ? I would expect to match against the symlink path rather its resolved path.

@fendor
Copy link
Collaborator

fendor commented Jul 2, 2020

Can confirm, looks like a bug to me.

I think that we are too loosely using canonicalizePath here: https://github.com/mpickering/hie-bios/blob/master/src/HIE/Bios/Cradle.hs#L245
Maybe a makeAbsolute is sufficient?

EDIT: same for this occurrence: https://github.com/mpickering/hie-bios/blob/master/src/HIE/Bios/Cradle.hs#L304

@teto
Copy link
Contributor Author

teto commented Jul 2, 2020

If I modify the path to

        - path: "./_generated"
          config: { cradle: { none:  } }

it works better:

hie-bios debug _generated/
No cradle

though I would prefer the message to be "Matched the None cradle" or sthg similar.

@fendor fendor added the type: bug Something isn't working label Jul 3, 2020
@fendor
Copy link
Collaborator

fendor commented Jul 12, 2020

Should be fixed in current master!

@fendor fendor closed this as completed Jul 12, 2020
@teto
Copy link
Contributor Author

teto commented Jul 12, 2020

nice thank you !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants