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

Scripts without an .hs or .lhs extension no longer work #7910

Closed
ElderEphemera opened this issue Jan 19, 2022 · 2 comments · Fixed by #7917
Closed

Scripts without an .hs or .lhs extension no longer work #7910

ElderEphemera opened this issue Jan 19, 2022 · 2 comments · Fixed by #7917

Comments

@ElderEphemera
Copy link

Describe the bug
In cabal version 3.6.2.0 and before, scripts could be named anything. But with a cabal-install built from HEAD attempting to run any script file without an ".hs" or ".lhs" suffix fails.

To Reproduce
Save the following as a file named "script":

{- cabal:
build-depends: base
-}

main = putStrLn "Hello"

Then,

$ cabal --version
cabal-install version 3.7
compiled using version 3.7.0.0 of the Cabal library 

$ cabal v2-run script
Resolving dependencies...
Build profile: -w ghc-9.2.1 -O1
In order, the following will be built (use -v for more details):
 - fake-package-0 (exe:script) (first run)
Configuring executable 'script' for fake-package-0..
Error: cabal: The 'main-is' field must specify a '.hs' or '.lhs' file (even if
it is generated by a preprocessor), or it may specify a C/C++/obj-C source
file.

Expected behavior
Scripts should continue to work regardless of what they are named.

Although, it seems like this new behavior has fixed #5702 so error messages no longer confusingly mention "Main.hs". It would be nice to keep the new behavior but without this regression.

System information

  • cabal-install version 3.7 (built from commit 7775be8)
  • GHC version 9.2.1
  • NixOS 21.05
@fgaz
Copy link
Member

fgaz commented Jan 19, 2022

I think this is due to @bacchanalia's work in #7851

@bacchanalia
Copy link
Collaborator

Sorry about that! I'll look into it.

@bacchanalia bacchanalia self-assigned this Jan 20, 2022
bacchanalia added a commit to bacchanalia/cabal that referenced this issue Jan 20, 2022
* Pass such scripts with: -x hs script
* Disable extension check for scripts
* Disable running preprocessors for scripts because they're based on
  extension
* Add test case for script with no extension

Resolves haskell#7910
jneira pushed a commit to bacchanalia/cabal that referenced this issue Jan 25, 2022
* Pass such scripts with: -x hs script
* Disable extension check for scripts
* Disable running preprocessors for scripts because they're based on
  extension
* Add test case for script with no extension

Resolves haskell#7910
@mergify mergify bot closed this as completed in #7917 Jan 25, 2022
Kleidukos pushed a commit to Kleidukos/cabal that referenced this issue Mar 30, 2022
* Pass such scripts with: -x hs script
* Disable extension check for scripts
* Disable running preprocessors for scripts because they're based on
  extension
* Add test case for script with no extension

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

Successfully merging a pull request may close this issue.

3 participants