I would like to install GHC 7.8.1, but would like to assign it different commands, so as not to clash with 7.6.3. For example:
runghc
with runghc7.8.1
ghci
with ghci7.8.1
Or similar. (ghci would be most important, for typed holes.) Basically, I want to be able to use GHC 7.8 and 7.6, so if there is a more direct way to do this tell me (A-B problem.)
Note: Ubuntu 13.10
Because you are on a unix-like system (Ubuntu) you can do the following:
$HOME/ghc7.8.1
or in a subfolder of /opt
like /opt/ghc7.8.1
– I would prefer the later one if you are the only user of your computer and the first one if this isn't the case). See this wikipedia article for explanations about the unix directory structure.Download the source code into that folder and follow the installation instructions:
In configure setp its important, that you set the --prefix
to the folder you have chosen above (if you don't do this, ghc will be installed in /usr/local/
which you do not want)! For example:
./configure --prefix=/opt/ghc7.8.1
After the installations look for the folder with the created binaries (it will be called bin
if you did not use another name for bindir
). Lets imagine this folder is /opt/ghc7.8.1/bin
.
Now you have two possibilities:
Solution with creating symlinks: Create symlinks in a folder which is in your $PATH
pointing to the created binaries (for example /usr/local/bin
or $HOME/bin
– I would use the first one, if you are the only user on your computer and the second if, if you are not). Therefore you have to use the command line tool ln
. For example:
sudo ln -s -T /opt/ghc7.8.1/bin/runghc /usr/local/bin/runghc7.8.1
After this command there is a file /usr/local/bin/runghc7.8.1
pointing to the binary /opt/ghc7.8.1/bin/runghc
. Executing /usr/local/bin/runghc7.8.1
via typing runghc7.8.1
will now execute the runghc
binary created in /opt
(Note: sudo
is not necessary if you create your symlink in $HOME/bin
– it is just needed because root
can create files under /usr
)
Solution with bash aliases: Write in your $HOME/.bash_aliases
(@Others: you can alternatively choose $HOME/.bashrc
or $HOME/.profile
depending of your system/preference) the following line:
alias runghc7.8.1='/opt/ghc7.8.1/bin/runghc'
Now typing runghc7.8.1
in your terminal is an shortcut (alias) for typing /opt/ghc7.8.1/bin/runghc
and will execute this binary.
Note, that with this solution typing runghc7.8.1
will just work, when you typed it into your terminal. There are cases, when it does not work (for example calling runghc7.8.1
in a script).