Skip to content

Commit

Permalink
Wrong platform build friendlier message
Browse files Browse the repository at this point in the history
  • Loading branch information
mosteo committed Aug 30, 2024
1 parent c576565 commit ba16f9f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
9 changes: 8 additions & 1 deletion src/alire/alire-platforms-common.ads
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,14 @@ private package Alire.Platforms.Common is
---------------------

function Unix_Home_Folder return String
is (OS_Lib.Getenv ("HOME", Default => "/tmp"));
is (if OS_Lib.Getenv ("HOME", "unset") = "unset" and then
GNAT.OS_Lib.Directory_Separator = '\'
then
raise Checked_Error with
"$HOME is not set, you might be running an"
& " `alr` built for a non-Windows OS"
else
OS_Lib.Getenv ("HOME", Default => "/tmp"));

----------------------
-- Unix_Temp_Folder --
Expand Down
15 changes: 14 additions & 1 deletion src/alire/os_windows/alire-platforms-folders__windows.adb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ with Ada.Directories;

with Alire.OS_Lib;

with GNAT.OS_Lib;

package body Alire.Platforms.Folders is

use OS_Lib.Operators;
Expand All @@ -11,7 +13,18 @@ package body Alire.Platforms.Folders is
----------

function Home return Absolute_Path
is (OS_Lib.Getenv ("USERPROFILE"));
is
begin
if OS_Lib.Getenv ("USERPROFILE", "unset") = "unset" and then
GNAT.OS_Lib.Directory_Separator = '/'
then
Raise_Checked_Error
("$USERPROFILE not set "
& "(might you be running an `alr` built for Windows?)");
else
return OS_Lib.Getenv ("USERPROFILE");
end if;
end Home;

-----------
-- Cache --
Expand Down

0 comments on commit ba16f9f

Please sign in to comment.