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

Check if target might be a project-level configuration file, not a missing directory #6033

Conversation

philderbeast
Copy link
Contributor

A rough fix for #6032. If it merits more work, I'll be happy to tidy it up, add a change log and some tests. What do you think?

The new behaviour:

$ stack build stack-yaml ghc-9.2.4.cabal2stack.yaml --dry-run

Error: [S-8506]
       Stack failed to parse the target(s).
       
       While parsing, Stack encountered the error:
       
           Directory not found: ghc-9.2.4.cabal2stack.yaml. Is this a typo? Can I suggest: --stack-yaml ghc-9.2.4.cabal2stack.yaml
       
       Stack expects a target to be a package name (e.g. my-package), a package identifier (e.g. my-package-0.1.2.3), a package component
       (e.g. my-package:test:my-test-suite), or, failing that, a relative path to a directory that is a local package directory or a parent
       directory of one or more local package directories.
$ stack build stack-yaml=ghc-9.2.4.cabal2stack.yaml --dry-run

Error: [S-8506]
       Stack failed to parse the target(s).
       
       While parsing, Stack encountered the error:
       
           Directory not found: stack-yaml=ghc-9.2.4.cabal2stack.yaml. Is this a typo? Can I suggest:
           --stack-yaml=ghc-9.2.4.cabal2stack.yaml
       
       Stack expects a target to be a package name (e.g. my-package), a package identifier (e.g. my-package-0.1.2.3), a package component
       (e.g. my-package:test:my-test-suite), or, failing that, a relative path to a directory that is a local package directory or a parent
       directory of one or more local package directories.

@mpilgrem
Copy link
Member

mpilgrem commented Jan 18, 2023

@philderbeast, that looks helpful to me. A few suggestions:

  1. I would put the hint on its own line following the problem:
    Stack failed to parse the target(s).
       
    While parsing, Stack encountered the error:
       
        Directory not found: stack-yaml=ghc-9.2.4.cabal2stack.yaml. 
    
        Is this a typo? May I suggest: --stack-yaml=ghc-9.2.4.cabal2stack.yaml.
    
  2. It is highly nuanced (see https://www.merriam-webster.com/words-at-play/when-to-use-can-and-may, for example) but 'May I ...?' may be better than 'Can I ...?' when asking permission.
  3. I am introducing proper punctuation into Stack's messages. You might add the final fullstop to the hint message.
  4. On the hint and styling, I am consistently using the Shell style for things typed, or to be typed, at the command line (rather than Dir).
  5. For your alternative test 'Does it end in .yaml?', --stack-yaml is not the only possibility. Very remotely, it could be --setup-info-yaml. I suggest to allow for that case:
    Stack failed to parse the target(s).
      
    While parsing, Stack encountered the error:
      
       Directory not found: ghc-9.2.4.cabal2stack.yaml. 
    
       Is there a typo? Did you mean to use the --stack-yaml option or, perhaps, the --setup-info-yaml option?
    
  6. If you wanted to be comprehensive, you could also cater for the setup-info-yaml=... type mistake.
  7. EDIT: Perhaps 'May I suggest: ...' is too anthropomorphic? How about 'Did you mean: ...' as the hint?

@mpilgrem
Copy link
Member

PS, I am on to the CI failing; that is nothing to do with your code. GitHub's rate limiting for its API is being triggered.

@mpilgrem mpilgrem changed the title Check if target might be a project. Check if target might be a project-level configuration file, not a missing directory Jan 18, 2023
@philderbeast philderbeast force-pushed the fix/project-mistaken-for-target-message branch from bdc2f80 to 760965c Compare January 22, 2023 19:13
@philderbeast
Copy link
Contributor Author

This is what I'm heading towards:

image

@philderbeast
Copy link
Contributor Author

Here's how it is looking now (not showing the colors or the "Stack expects a target to be ..." ending of the message):

$ stack run stack -- build stack-yaml=ghc-9.2.4.cabal2stack.yaml --dry-run
...
Error: [S-8506]
       Stack failed to parse the target(s).
       
       While parsing, Stack encountered the error:
       
             stack-yaml=ghc-9.2.4.cabal2stack.yaml is not a directory.
           --stack-yaml=ghc-9.2.4.cabal2stack.yaml might work as a project option.
$ stack run stack -- build stack-yaml ghc-9.2.4.cabal2stack.yaml --dry-run

Error: [S-8506]
       Stack failed to parse the target(s).
       
       While parsing, Stack encountered the error:
       
                        ghc-9.2.4.cabal2stack.yaml is not a directory.
           --stack-yaml ghc-9.2.4.cabal2stack.yaml might work as a project option.

@philderbeast
Copy link
Contributor Author

6. If you wanted to be comprehensive, you could also cater for the setup-info-yaml=... type mistake.

@mpilgrem I've never dealt with setup-info-yaml= and would like to move onto something else (picking up the multiple library support again) so will leave this extra case for now.

@mpilgrem mpilgrem merged commit bc7c17c into commercialhaskell:master Jan 31, 2023
@mpilgrem mpilgrem deleted the fix/project-mistaken-for-target-message branch January 31, 2023 21:33
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.

2 participants