Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Open sidebar
Alfredo Di Napoli
GHC
Commits
763d2855
Commit
763d2855
authored
Dec 05, 2020
by
Gauvain Roussel-Tarbouriech
Committed by
Marge Bot
Feb 18, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
directory: ensure xdg compliance (Fix #6077)
parent
2adfb404
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
33 additions
and
15 deletions
+33
-15
compiler/GHC/Driver/Session.hs
compiler/GHC/Driver/Session.hs
+1
-1
docs/users_guide/9.2.1-notes.rst
docs/users_guide/9.2.1-notes.rst
+4
-0
docs/users_guide/ghci.rst
docs/users_guide/ghci.rst
+2
-2
docs/users_guide/packages.rst
docs/users_guide/packages.rst
+6
-6
ghc/GHCi/UI.hs
ghc/GHCi/UI.hs
+16
-2
utils/ghc-pkg/Main.hs
utils/ghc-pkg/Main.hs
+4
-4
No files found.
compiler/GHC/Driver/Session.hs
View file @
763d2855
...
...
@@ -867,7 +867,7 @@ opt_i dflags= toolSettings_opt_i $ toolSettings dflags
versionedAppDir
::
String
->
ArchOS
->
MaybeT
IO
FilePath
versionedAppDir
appname
platform
=
do
-- Make sure we handle the case the HOME isn't set (see #11678)
appdir
<-
tryMaybeT
$
get
AppUserData
Directory
appname
appdir
<-
tryMaybeT
$
get
Xdg
Directory
XdgData
appname
return
$
appdir
</>
versionedFilePath
platform
versionedFilePath
::
ArchOS
->
FilePath
...
...
docs/users_guide/9.2.1-notes.rst
View file @
763d2855
...
...
@@ -101,6 +101,10 @@ GHCi
:envvar:`EDITOR`, following UNIX convention.
(:ghc-ticket:`19030`)
- GHC now follows by default the XDG Base Directory Specification. If
``$HOME/.ghc`` is found it will fallback to the old paths to give you
time to migrate. This fallback will be removed in three releases.
Runtime system
~~~~~~~~~~~~~~
...
...
docs/users_guide/ghci.rst
View file @
763d2855
...
...
@@ -2063,7 +2063,7 @@ mostly obvious.
:reverse: -fno-local-ghci-history
:category:
By default, GHCi keeps global history in ``
~/.
ghc/ghci_history`` or
By default, GHCi keeps global history in ``
$XDG_DATA_HOME/
ghc/ghci_history`` or
``%APPDATA%/<app>/ghci_history``, but you can use current directory, e.g.:
.. code-block:: none
...
...
@@ -3248,7 +3248,7 @@ they exist:
Unix or :file:`C:/Documents and Settings/user/Application
Data/ghc` on Windows.
2. :file:`$HOME/.ghci`
2. :file:`$
XDG_CONFIG_
HOME/.ghci`
3. :file:`./.ghci`
...
...
docs/users_guide/packages.rst
View file @
763d2855
...
...
@@ -393,7 +393,7 @@ GHC knows about two package databases in particular:
e
.
g
.
``/
usr
/
lib
/
ghc
-
6.12.1
/
package
.
conf
.
d
``.
-
The
*
user
package
database
*
private
to
each
user
.
On
Unix
systems
this
will
be
``$
HOME
/
.
ghc
/
arch
-
os
-
version
/
package
.
conf
.
d
``,
and
on
Windows
it
will
be
``$
XDG_DATA_
HOME
/
ghc
/
arch
-
os
-
version
/
package
.
conf
.
d
``,
and
on
Windows
it
will
be
something
like
``
C
:\
Documents
And
Settings
\
user
\
ghc
\
package
.
conf
.
d
``.
The
``
ghc
-
pkg
``
tool
knows
where
this
file
should
be
located
,
and
will
...
...
@@ -515,7 +515,7 @@ The ``GHC_PACKAGE_PATH`` environment variable
..
code
-
block
::
none
$
export
GHC_PACKAGE_PATH
=$
HOME
/.
my
-
ghc
-
packages
.
conf
:
$
export
GHC_PACKAGE_PATH
=$
XDG_DATA_
HOME
/.
my
-
ghc
-
packages
.
conf
:
To
check
whether
your
`
GHC_PACKAGE_PATH
`
setting
is
doing
the
right
thing
,
``
ghc
-
pkg
list
``
will
list
all
the
databases
in
use
,
in
the
...
...
@@ -578,7 +578,7 @@ must be relative to the location of the package environment file.
:
category
:
Use
the
package
environment
in
⟨
file
⟩
,
or
in
``$
HOME
/
.
ghc
/
arch
-
os
-
version
/
environments
/
⟨
name
⟩
``
``$
XDG_DATA_
HOME
/
ghc
/
arch
-
os
-
version
/
environments
/
⟨
name
⟩
``
If
set
to
``-``
no
package
environment
is
read
.
..
envvar
::
GHC_ENVIRONMENT
...
...
@@ -591,13 +591,13 @@ locations:
-
File
⟨
file
⟩
if
you
pass
the
option
:
ghc
-
flag
:`-
package
-
env
⟨
file
⟩
|
⟨
name
⟩
`.
-
File
``$
HOME
/
.
ghc
/
arch
-
os
-
version
/
environments
/
name
``
if
you
pass
the
-
File
``$
XDG_DATA_
HOME
/
ghc
/
arch
-
os
-
version
/
environments
/
name
``
if
you
pass
the
option
``-
package
-
env
⟨
name
⟩
``.
-
File
⟨
file
⟩
if
the
environment
variable
:
envvar
:`
GHC_ENVIRONMENT
`
is
set
to
⟨
file
⟩
.
-
File
``$
HOME
/
.
ghc
/
arch
-
os
-
version
/
environments
/
name
``
if
the
-
File
``$
XDG_DATA_
HOME
/
ghc
/
arch
-
os
-
version
/
environments
/
name
``
if
the
environment
variable
:
envvar
:`
GHC_ENVIRONMENT
`
is
set
to
⟨
name
⟩
.
Additionally
,
unless
``-
hide
-
all
-
packages
``
is
specified
``
ghc
``
will
also
...
...
@@ -606,7 +606,7 @@ look for the package environment in the following locations:
-
File
``.
ghc
.
environment
.
arch
-
os
-
version
``
if
it
exists
in
the
current
directory
or
any
parent
directory
(
but
not
the
user
's home directory).
- File ``$HOME/
.
ghc/arch-os-version/environments/default`` if it
- File ``$
XDG_DATA_
HOME/ghc/arch-os-version/environments/default`` if it
exists.
Package environments can be modified by further command line arguments;
...
...
ghc/GHCi/UI.hs
View file @
763d2855
...
...
@@ -587,7 +587,21 @@ ghciLogAction lastErrLocations old_log_action
withGhcAppData
::
(
FilePath
->
IO
a
)
->
IO
a
->
IO
a
withGhcAppData
right
left
=
do
either_dir
<-
tryIO
(
getAppUserDataDirectory
"ghc"
)
either_dir
<-
tryIO
(
getXdgDirectory
XdgData
"ghc"
)
case
either_dir
of
Right
dir
->
do
createDirectoryIfMissing
False
dir
`
catchIO
`
\
_
->
return
()
right
dir
_
->
left
withGhcConfig
::
(
FilePath
->
IO
a
)
->
IO
a
->
IO
a
withGhcConfig
right
left
=
do
old_path
<-
getAppUserDataDirectory
"ghc"
use_old_path
<-
doesPathExist
old_path
let
path
=
(
if
use_old_path
then
getAppUserDataDirectory
"ghc"
else
getXdgDirectory
XdgConfig
"ghc"
)
either_dir
<-
tryIO
(
path
)
case
either_dir
of
Right
dir
->
do
createDirectoryIfMissing
False
dir
`
catchIO
`
\
_
->
return
()
...
...
@@ -600,7 +614,7 @@ runGHCi paths maybe_exprs = do
let
ignore_dot_ghci
=
gopt
Opt_IgnoreDotGhci
dflags
app_user_dir
=
liftIO
$
withGhc
AppData
app_user_dir
=
liftIO
$
withGhc
Config
(
\
dir
->
return
(
Just
(
dir
</>
"ghci.conf"
)))
(
return
Nothing
)
...
...
utils/ghc-pkg/Main.hs
View file @
763d2855
...
...
@@ -58,8 +58,8 @@ import Distribution.Simple.Utils (toUTF8BS, writeUTF8File, readUTF8File)
import
qualified
Data.Version
as
Version
import
System.FilePath
as
FilePath
import
qualified
System.FilePath.Posix
as
FilePath.Posix
import
System.Directory
(
get
AppUserData
Directory
,
createDirectoryIfMissing
,
getModificationTime
)
import
System.Directory
(
get
Xdg
Directory
,
createDirectoryIfMissing
,
getModificationTime
,
XdgDirectory
(
XdgData
)
)
import
Text.Printf
import
Prelude
...
...
@@ -634,8 +634,8 @@ getPkgDatabases verbosity mode use_user use_cache expand_vars my_flags = do
let
no_user_db
=
FlagNoUserDb
`
elem
`
my_flags
-- get the location of the user package database, and create it if necessary
-- get
AppUserData
Directory can fail (e.g. if $HOME isn't set)
e_appdir
<-
tryIO
$
get
AppUserData
Directory
"ghc"
-- get
Xdg
Directory can fail (e.g. if $HOME isn't set)
e_appdir
<-
tryIO
$
get
Xdg
Directory
XdgData
"ghc"
mb_user_conf
<-
case
[
f
|
FlagUserConfig
f
<-
my_flags
]
of
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment