cabal-install-3.8.1.0: The command-line interface for Cabal and Hackage.
Copyright(c) Duncan Coutts 2008
LicenseBSD-like
Maintainercabal-devel@haskell.org
Stabilityprovisional
Portabilityportable
Safe HaskellNone
LanguageHaskell2010

Distribution.Client.InstallSymlink

Description

Managing installing binaries with symlinks.

Synopsis

Documentation

symlinkBinaries :: Platform -> Compiler -> OverwritePolicy -> ConfigFlags -> InstallFlags -> InstallPlan -> BuildOutcomes -> IO [(PackageIdentifier, UnqualComponentName, FilePath)] Source #

We would like by default to install binaries into some location that is on the user's PATH. For per-user installations on Unix systems that basically means the ~bin directory. On the majority of platforms the ~bin directory will be on the user's PATH. However some people are a bit nervous about letting a package manager install programs into ~bin.

A compromise solution is that instead of installing binaries directly into ~bin, we could install them in a private location under ~.cabalbin and then create symlinks in ~bin. We can be careful when setting up the symlinks that we do not overwrite any binary that the user installed. We can check if it was a symlink we made because it would point to the private dir where we install our binaries. This means we can install normally without worrying and in a later phase set up symlinks, and if that fails then we report it to the user, but even in this case the package is still in an OK installed state.

This is an optional feature that users can choose to use or not. It is controlled from the config file. Of course it only works on POSIX systems with symlinks so is not available to Windows users.

symlinkBinary Source #

Arguments

:: OverwritePolicy

Whether to force overwrite an existing file

-> FilePath

The canonical path of the public bin dir eg homeuser/bin

-> FilePath

The canonical path of the private bin dir eg homeuser.cabalbin

-> FilePath

The name of the executable to go in the public bin dir, eg foo

-> String

The name of the executable to in the private bin dir, eg foo-1.0

-> IO Bool

If creating the symlink was successful. False if there was another file there already that we did not own. Other errors like permission errors just propagate as exceptions.

Symlink binary.

The paths are take in pieces, so we can make relative link when possible.

trySymlink :: Verbosity -> IO Bool Source #

Try to make a symlink in a temporary directory.

If this works, we can try to symlink: even on Windows.