Yesod-platform installation failing because of Alex package
-
21-12-2019 - |
Question
I'm trying to update the yesod platform to the latest version. In order to do this, I have executed the following commands:
cabal update
cabal install yesod-platform yesod-bin
To which I eventually get the following error:
Resolving dependencies...
Configuring language-javascript-0.5.13...
cabal: The program alex version >=3.0.5 is required but the version found at /usr/bin/alex is version 3.0.1
cabal: Error: some packages failed to install:
hjsmin-0.1.4.6 depends on language-javascript-0.5.13 which failed to install
language-javascript-0.5.13 failed during the configure step. The exception was:
ExitFailure 1
yesod-platform-1.2.12.2 depends on language-javascript-0.5.13 which failed to install
yesod-static-1.2.4 depends on language-javascript-0.5.13 which failed to install
After a bit of research, I have stumbled on the following post which mentions I should install a few more dependencies manually before doing the cabal install yesod-platform yesod-bin
command. Those dependencies include alex
amongst others. This, unfortunately, did not help as I got the same errors when I tried again.
I have then noticed that the version of alex
in my /usr/bin/alex
is still 3.0.1 after the manual install of alex
version 3.0.5. After a bit of research, it seems when installing that package, it installs it in the $HOME/.cabal/bin
and that path was not in my $PATH
variable, so I added it in the /etc/environment
file before the the entry /usr/bin/
. After a reboot of my server, I have once again tried, but still get the same error.
Even if I added $HOME/.cabal/bin
before /usr/bin/
, it still goes in the latter to look for alex
, which seems to be the problem. Other than copying the executable of alex
version 3.0.5 from $HOME/.cabal/bin
to /usr/bin/
manually (which I'm scared would cause me some problems, and headaches when wanting to update in the future), what could I do? Is this the real problem here?
Also, as a side question, when I echo $PATH
, the $HOME is not resolved to /home/<myusername>
(I see $HOME/...
), is this normal?
EDIT: Tried renaming alex
to alex.bak
in /usr/bin/
to try and "force" ubuntu to take the one from $HOME/.cabal/bin
, but it now cannot find any program named alex
. Why is it not finding it in $HOME/.cabal/bin
?
Solution
As it turned out the problem was just the usual path problems.
Cabal
installs new executables like alex
into
/home/[you]/.cabal/bin
(or ~/.cabal/bin
) on linux
So you should set up your path to look there first.
You can to this temporary by writing
export PATH=/home/[you]/.cabal/bin:$PATH
in your terminal before doing any Haskell stuff but normaly you might want to add this to a login-script.
The best place for this is IMO /home/[you]/.profile
(or ~/.profile
) so edit this file (or create it if it does not exist) and add these lines to the end of the file:
if [ -d "$HOME/.cabal/bin" ] ; then
PATH="$HOME/.cabal/bin:$PATH"
fi
As this one takes care of the $HOME
var to it should work just fine.
Of course this one will only work after you loged in again.
You can test it with
whereis alex
and alex --ver
- the first one should point you to this path too, the second one should print out your current version of alex.
Have fun.
PS: replace [you]
with your name within Linux everywhere of course ;)