-
Notifications
You must be signed in to change notification settings - Fork 108
OS detection is faulty #242
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
Comments
The Windows check (using fpm/fpm/src/fpm_environment.f90 Lines 36 to 39 in c68cf2f
occurs before the cygwin check (using fpm/fpm/src/fpm_environment.f90 Lines 64 to 67 in c68cf2f
but since cygwin imports all Windows environment variables, the Windows check will take precedence over the cygwin one and always return A possible fix could be to check the environment variable |
I just checked: Cygwin defines OSTYPE (to be "cygwin") whereas plain
Windows does not define it - instead it uses OS. So the logic should take
that non-existence into account. But checking OSTYPE first seems a
reasonable solution.
Op di 17 nov. 2020 om 14:37 schreef Laurence Kedward <
[email protected]>:
… The Windows check (using 'OS'):
https://github.com/fortran-lang/fpm/blob/c68cf2fbdb40c33636bd50b6a729490ae9d61654/fpm/src/fpm_environment.f90#L36-L39
occurs before the cygwin check (using 'OSTYPE'):
https://github.com/fortran-lang/fpm/blob/c68cf2fbdb40c33636bd50b6a729490ae9d61654/fpm/src/fpm_environment.f90#L64-L67
but since cygwin imports all Windows environment variables
<https://cygwin.com/cygwin-ug-net/setup-env.html>, the Windows check will
take precedence over the cygwin one and always return OS_WINDOWS.
A possible fix could be to check the environment variable 'OS' after
'OSTYPE' and not before - what do you think @interkosmos
<https://github.com/interkosmos>?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#242 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAN6YR2ALYVCXMPTJ4X7QX3SQJ4AJANCNFSM4TX3JB5A>
.
|
Hm, MinGW poses another complication: if started as mingw64.exe you have a
Linux-like environment under Windows that is compatible with plain Windows,
whereas msys64.exe takes you closer to Linux. The two environment variables
do not allow you to distinguish the two, though I think mingw64.exe is the
preferred environment
Op di 17 nov. 2020 om 14:40 schreef Arjen Markus <[email protected]
…:
I just checked: Cygwin defines OSTYPE (to be "cygwin") whereas plain
Windows does not define it - instead it uses OS. So the logic should take
that non-existence into account. But checking OSTYPE first seems a
reasonable solution.
Op di 17 nov. 2020 om 14:37 schreef Laurence Kedward <
***@***.***>:
> The Windows check (using 'OS'):
>
> https://github.com/fortran-lang/fpm/blob/c68cf2fbdb40c33636bd50b6a729490ae9d61654/fpm/src/fpm_environment.f90#L36-L39
>
> occurs before the cygwin check (using 'OSTYPE'):
>
> https://github.com/fortran-lang/fpm/blob/c68cf2fbdb40c33636bd50b6a729490ae9d61654/fpm/src/fpm_environment.f90#L64-L67
>
> but since cygwin imports all Windows environment variables
> <https://cygwin.com/cygwin-ug-net/setup-env.html>, the Windows check
> will take precedence over the cygwin one and always return OS_WINDOWS.
>
> A possible fix could be to check the environment variable 'OS' after
> 'OSTYPE' and not before - what do you think @interkosmos
> <https://github.com/interkosmos>?
>
> —
> You are receiving this because you are subscribed to this thread.
> Reply to this email directly, view it on GitHub
> <#242 (comment)>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AAN6YR2ALYVCXMPTJ4X7QX3SQJ4AJANCNFSM4TX3JB5A>
> .
>
|
Yes I agree with you @arjenmarkus. To distinguish between the mingw64.exe shell and the msys64.exe shell there should be an Aside: as an example why the two shells should be treated differently, |
I had a look at running fpm under MSYS2 and realised there's another problem with the OS detection routine. The routine looks for the |
Yes, noticed that too but you can do an "export OSTYPE" and "unset OS" as a work-around in your .bashrc as a work-around for Cygwin. If cpp -dM /dev/null |
I agree it would be good for fpm to define some preprocessor variables such as OSTYPE, it's frustrating that many useful variables defined in cpp are excluded from gfortran for no good reason. However, for fpm we need to detect OSTYPE at runtime due to complications with the various possible Windows systems; in particular, 'plain Windows' binaries (currently supported) can run on msys2/cygwin but run into issues with our filesystem routines implemented via shell commands.
Yes, also to add the Actually determining which shell command to run at the moment is the main problem on msys2/cygwin, once these routines are replaced with |
In https://github.com/urbanjost/M_io I have two routines (which(3f) and separator(3f)) which might be useful, but I have not tested them in several of those environments. The separator procedure tries to use standard Fortran and an INQUIRE on arg0 to determine if a backslash is |
@awvwgk could you please reopen this issue because MINGW still poses an issue as mentioned in #242 (comment) |
Running in a CygWin environment I had to unset the environment variable OS which was set for the MSWIndows applications and inherited by the CygWin application in order for the routine testing for system type to identify the environment as a CygWin/POSIX environment instead of a default MSWindows environment. Looks like the routine automatically assumes if the OS variable is set it is MSWindows. At least need a note to that effect somewhere; but might want to change the test. Specifically for CygWin there are several environment variables and the /usr/bin/cyg* commands that can be tested for without having to call platform-specific C routines if anyone wants a list. The routine identifying the platform is slated for replacement by a stdlib routine I believe, but that might be a ways off.
The text was updated successfully, but these errors were encountered: