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

Filename case on macOS #4739

Open
ivan-m opened this issue Sep 4, 2017 · 11 comments
Open

Filename case on macOS #4739

ivan-m opened this issue Sep 4, 2017 · 11 comments

Comments

@ivan-m
Copy link
Collaborator

ivan-m commented Sep 4, 2017

In a project I'm working on, I have some directories in the module path consisting solely of capital letters.

When I try and build this project, I get the following warning:

<built-in>:17:10: error:
     warning: non-portable path to file '"dist/build/JBI/autogen/cabal_macros.h"'; specified path differs in case from file name on disk [-Wnonportable-include-path]
#include "dist/build/jbi/autogen/cabal_macros.h"
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         "dist/build/JBI/autogen/cabal_macros.h"
1 warning generated.

(Which I think comes from clang rather than cabal-install itself.)

I also previously had the executable file in src/jbi.hs; this resulted in a GHC error:

src/JBI.hs:11:8: error:
    File name does not match module name:
    Saw: ‘Main’
    Expected: ‘JBI’

I'm not sure if either of these can actually be fixed, or we just have to deal with the joys of caseless filesystems.

cabal-install version 2.0.0.0
compiled using version 2.0.0.2 of the Cabal library

macOS Sierra 10.12.6

@ivan-m
Copy link
Collaborator Author

ivan-m commented Sep 4, 2017

Oh, and the executable directory was then conflated with the library module path (because of course dist/build/jbi is the same as dist/build/JBI).

ivan-m added a commit to ivan-m/jbi that referenced this issue Sep 4, 2017
There's still a warning, but it can build now.

haskell/cabal#4739
@23Skidoo
Copy link
Member

So the issue is that Cabal is generating the string #include "dist/build/jbi/autogen/cabal_macros.h" which should be #include "dist/build/JBI/autogen/cabal_macros.h"?

@ivan-m
Copy link
Collaborator Author

ivan-m commented Oct 14, 2017

Yes

@tfausak
Copy link
Collaborator

tfausak commented Dec 15, 2017

I am also running into this problem.

    /Users/taylor/Documents/GitHub/rattletrap/<built-in>:15:10: error:
         error: non-portable path to file '".stack-work/dist/x86_64-osx/Cabal-2.0.1.0/build/Rattletrap/autogen/cabal_macros.h"'; specified path differs in case from file name on disk [-Werror,-Wnonportable-include-path]
    #include ".stack-work/dist/x86_64-osx/Cabal-2.0.1.0/build/rattletrap/autogen/cabal_macros.h"
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
             ".stack-work/dist/x86_64-osx/Cabal-2.0.1.0/build/Rattletrap/autogen/cabal_macros.h"
    1 error generated.
    `gcc' failed in phase `C pre-processor'. (Exit code: 1)

tfausak referenced this issue in tfausak/rattletrap Jan 5, 2018
@newmana
Copy link

newmana commented Jan 10, 2018

Is there a way to work around this problem? Or a cause?

The workaround is to remove things like -Werror.

@judah
Copy link
Contributor

judah commented Jan 15, 2018

I just ran into this (with stack-1.6.1 and Cabal-2.0.1.0 on macOS Sierra 10.12.6) and perhaps tracked down the cause a little further.

Regular output files (for example from the module Some.Module) are put in .../build/Some/Module.hi ; meanwhile autogenerated files (like Paths_* and cabal_macros.h) are put in .../build/{package-name}/autogen/...". Those can overlap (.../build/Some and .../build/{package-name}) if package-name matches a top-level module/directory; this is a little nonhermetic, but doesn't seem to break anything. But they can also overlap on a case-insensitive filesystem if the package is named some, and that causes the error in question.

Ideally we could put .hi and .o files in an unambiguous, separate directory from autogenerated files. I'm not sure if that would break any assumptions within Cabal, though.

judah added a commit to judah/pier that referenced this issue Jan 15, 2018
Needs to disable `-Werror` due to haskell/cabal#4739.  (We could also work
around it by changing the module structure.)
@hvr
Copy link
Member

hvr commented Jan 15, 2018

@judah fwiw, I think with cabal new-build the layout is different enough to avoid such accidental clashes:

The new-style folders look like

  • dist-newstyle/build/${ARCH}/${COMPILER}/${PN}-${PV}/build/autogen/Paths_${PN}.h
  • dist-newstyle/build/${ARCH}/${COMPILER}/${PN}-${PV}/build/Paths_${PN}.hi

So I don't see a potential clash between ${PN} and module names, but there might be one with the autogen/ folder, if you had module namespaces like AutoGen.Foo.

This would be easy to workaround, if we renamed autogen/ to e.g. _autogen/; this is dual to your suggestion, which actually sounds sensible as well, and may actually be more future-proof, as there's other files that might get thrown into the build/ folder which could easily case-clash with each other (like executables, or even if you name your executable autogen - c.f. #5044). We could try to move the generated module-named files into sub-folder like e.g.

  • dist-newstyle/build/${ARCH}/${COMPILER}/${PN}-${PV}/build/_/Paths_${PN}.hi

@judah
Copy link
Contributor

judah commented Jan 20, 2018

In case it helps others: I was able to work around this issue somewhat by adding -optP-Wno-nonportable-include-path to the ghc-options for my project.

@gbaz
Copy link
Collaborator

gbaz commented Feb 7, 2018

related/semi-dup: #783

grancalavera added a commit to grancalavera/labyrinth that referenced this issue Feb 17, 2018
robx added a commit to robx/postgrest that referenced this issue May 26, 2019
robx added a commit to robx/postgrest that referenced this issue May 26, 2019
robx added a commit to robx/postgrest that referenced this issue May 29, 2019
robx added a commit to robx/postgrest that referenced this issue Jun 25, 2019
See also haskell/cabal#4739.

/Users/travis/build/PostgREST/postgrest/<built-in>:15:10: error:
     error: non-portable path to file '".stack-work/dist/x86_64-osx/Cabal-2.2.0.1/build/PostgREST/autogen/cabal_macros.h"'; specified path differs in case from file name on disk [-Werror,-Wnonportable-include-path]
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         ".stack-work/dist/x86_64-osx/Cabal-2.2.0.1/build/PostgREST/autogen/cabal_macros.h"
steve-chavez pushed a commit to PostgREST/postgrest that referenced this issue Jun 27, 2019
See also haskell/cabal#4739.

/Users/travis/build/PostgREST/postgrest/<built-in>:15:10: error:
     error: non-portable path to file '".stack-work/dist/x86_64-osx/Cabal-2.2.0.1/build/PostgREST/autogen/cabal_macros.h"'; specified path differs in case from file name on disk [-Werror,-Wnonportable-include-path]
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         ".stack-work/dist/x86_64-osx/Cabal-2.2.0.1/build/PostgREST/autogen/cabal_macros.h"
@sjakobi
Copy link
Member

sjakobi commented Nov 6, 2019

I seem to have run into a variation on this issue at dhall-lang/dhall-haskell@9edbcc4:

In the same project, I have

  1. A package dhall-json that contains a module Dhall.Yaml.
  2. A package dhall-yaml that contains a module Dhall.YAML and that depends on dhall-json.

(stack) builds on both OS X and Windows failed with

    C:\projects\dhall-haskell\dhall-yaml\src\Dhall\YAML.hs:3:8: error:
        File name does not match module name:
        Saw: `Dhall.YAML'
        Expected: `Dhall.Yaml'
      |
    3 | module Dhall.YAML
      |        ^^^^^^^^^^

I ended up renaming the modules.

@andreasabel
Copy link
Member

Me too, with project https://github.com/BNFC/bnfc :

$ cabal build all
Build profile: -w ghc-8.10.3 -O1
In order, the following will be built (use -v for more details):
 - BNFC-2.9.0 (lib:BNFC, exe:bnfc) (configuration changed)
Configuring BNFC-2.9.0...
Preprocessing library for BNFC-2.9.0..
Building library for BNFC-2.9.0..
Preprocessing executable 'bnfc' for BNFC-2.9.0..
Building executable 'bnfc' for BNFC-2.9.0..

<built-in>:15:10: error:
     warning: non-portable path to file '"/Users/abel/project/open-source/bnfc/dist-newstyle/build/x86_64-osx/ghc-8.10.3/BNFC-2.9.0/build/BNFC/autogen/cabal_macros.h"'; specified path differs in case from file name on disk [-Wnonportable-include-path]
#include "/Users/abel/project/open-source/bnfc/dist-newstyle/build/x86_64-osx/ghc-8.10.3/BNFC-2.9.0/build/bnfc/autogen/cabal_macros.h"
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         "/Users/abel/project/open-source/bnfc/dist-newstyle/build/x86_64-osx/ghc-8.10.3/BNFC-2.9.0/build/BNFC/autogen/cabal_macros.h"
1 warning generated.

dan-zheng added a commit to dan-zheng/dex-lang that referenced this issue Jan 8, 2021
Disable `-Wnonportable-include-path` for executable dex in dex.cabal.

I am not sure caused this issue to surface. The same issue previously
occurred for other targets in dex.cabal.

Workaround suggested by discussion:
haskell/cabal#4739 (comment)
dan-zheng added a commit to google-research/dex-lang that referenced this issue Jan 8, 2021
Disable `-Wnonportable-include-path` for executable dex in dex.cabal.

I am not sure caused this issue to surface. The same issue previously
occurred for other targets in dex.cabal.

Workaround suggested by discussion:
haskell/cabal#4739 (comment)
monacoremo pushed a commit to monacoremo/postgrest that referenced this issue Jul 17, 2021
See also haskell/cabal#4739.

/Users/travis/build/PostgREST/postgrest/<built-in>:15:10: error:
     error: non-portable path to file '".stack-work/dist/x86_64-osx/Cabal-2.2.0.1/build/PostgREST/autogen/cabal_macros.h"'; specified path differs in case from file name on disk [-Werror,-Wnonportable-include-path]
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         ".stack-work/dist/x86_64-osx/Cabal-2.2.0.1/build/PostgREST/autogen/cabal_macros.h"
mattaudesse added a commit to reach-sh/reach-lang that referenced this issue Aug 28, 2021
mattaudesse added a commit to reach-sh/reach-lang that referenced this issue Aug 31, 2021
jeapostrophe pushed a commit to reach-sh/reach-lang that referenced this issue Aug 31, 2021
miuirussia added a commit to miuirussia/nix-flake-env that referenced this issue Jul 18, 2023
bortkomencw added a commit to bortkomencw/dex-lang that referenced this issue Jul 27, 2024
Disable `-Wnonportable-include-path` for executable dex in dex.cabal.

I am not sure caused this issue to surface. The same issue previously
occurred for other targets in dex.cabal.

Workaround suggested by discussion:
haskell/cabal#4739 (comment)
operskoj2c added a commit to operskoj2c/dex-lang that referenced this issue Aug 4, 2024
Disable `-Wnonportable-include-path` for executable dex in dex.cabal.

I am not sure caused this issue to surface. The same issue previously
occurred for other targets in dex.cabal.

Workaround suggested by discussion:
haskell/cabal#4739 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants