Ticket #720 (new defect)

Opened 3 years ago

Last modified 3 years ago

Executables fail on windows if the executable name has a dot in it

Reported by: j3h Owned by:
Priority: normal Milestone:
Component: Cabal library Version:
Severity: normal Keywords:
Cc: Difficulty: unknown
GHC Version: Platform:

Description

If an executable name has a dot in it, it is not generated with an .exe extension on Windows. It works fine under Linux. See the attached example to reproduce.

$ cabal --version
cabal-install version 0.8.2
using version 1.8.0.6 of the Cabal library 


$ cabal install
Resolving dependencies...
Configuring bad-exe-0.1...
Preprocessing executables for bad-exe-0.1...
Building bad-exe-0.1...
[1 of 1] Compiling Main             ( Main.hs, dist\build\bad.name\bad.name-tmp\Main.o )

Main.hs:1:0:
    Warning: Module `Prelude' is deprecated:
               You are using the old package `base' version 3.x.
               Future GHC versions will not support base version 3.x. You
               should update your code to use the new base version 4.x.
Linking dist\build\bad.name\bad.name ...
Installing executable(s) in C:\Users\hudson\AppData\Roaming\cabal\bin
cabal.exe: dist\build\bad.name\bad.name.exe: does not exist
cabal.exe: Error: some packages failed to install:
bad-exe-0.1 failed during the final install step. The exception was:
ExitFailure 1

Attachments

bad-exe-0.1.tar.gz Download (452 bytes) - added by j3h 3 years ago.
A trivial package with a dot in the exe file name

Change History

Changed 3 years ago by j3h

A trivial package with a dot in the exe file name

Changed 3 years ago by j3h

  • version 1.6.0.3 deleted

Changed 3 years ago by duncan

Currently the code does:

  -- exeNameReal, the name that GHC really uses (with .exe on Windows)
  let exeNameReal = exeName' <.>
                    (if null $ takeExtension exeName' then exeExtension else "")

Where as I would expect it should be simply

  -- exeNameReal, the name that GHC really uses (with .exe on Windows)
  let exeNameReal = exeName' <.> exeExtension

since p <.> "" = p.

It is not clear to me why the code is like it is now. The code was added by the patch

Mon Aug 21 15:30:21 BST 2006  Neil Mitchell
  * Make -o use the filename as GHC will, i.e. with .exe on the end for Windows.
 This fixes a GHC 6.4.2 bug with relinking every time.

the code was

  -- exeNameReal, the name that GHC really uses (with .exe on Windows)
  let exeNameReal = exeName' `joinFileExt`
                    (if null $ snd $ splitFileExt exeName' then exeExtension else "")

Previously it had relied on ghc adding the .exe extension. It is still not obvious why it is coded the way it is, if it's an oversight or something I'm missing. In principle the above allows people to make an executable that does not use the .exe extension.

Note: See TracTickets for help on using tickets.