Unable to install purescript on Ubuntu 20.04 LTS
Opened this issue · 6 comments
Description
I am trying to install purescript on a freshly installed Ubuntu 20.04 LTS.
When I do npm install -g purescript
, it gives me an error of unable to access /usr/local/lib
and asks me to try the command with sudo. On using sudo npm install -g purescript
, it installs just fine.
But when I do purs
, it says purescript npm installer: installation failed; please try installing again
and exits.
To Reproduce
Steps to reproduce the behavior.
sudo npm install -g purescript
purs
Expected behavior
I am expecting it to do something other than above.
Additional context
Spago installs just fine with sudo, and I am able to do spago init
but spago build
does not work as it uses purs
Temporary Workaround
- Instead of installing purescript via npm, download the pre-built binary. Put it somewhere and append the path to PATH variable. Also, do
sudo apt install libncurses5
. Try doingpurs
, it should work fine. - Install spago with
sudo npm install -g spago
. It may complain about purescript version, so use whatever version is latest and compatible with it. - Everything works as expected. Just wish it would work out of the box.
Pre-built binary releases: https://github.com/purescript/purescript/releases
When I do npm install -g purescript, it gives me an error of unable to access /usr/local/lib and asks me to try the command with sudo.
There isn't anything we can do about this - this is caused by npm defaulting to installing things in /usr/local/lib
, since you usually have to be root to be allowed to create files in there. You'll have the same issue when trying to globally install anything with npm, unless you configure npm to behave differently. See https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally
I'm trying to see if I can reproduce the purescript npm installer: installation failed; please try installing again
error.
How did you install npm?
Ok, I can reproduce this on a fresh ubuntu 20.04 box with the default nodejs
and npm
packages from apt. It looks like there's a problem when you try to install globally as root. It works when I try to do a local install as root, and it also works when I try to do a global or local install as a non-privileged user. It appears that the postinstall script is failing before it produces any output, which is unfortunate; when I run npm install -g purescript
as root, there's no error message but I do get an exit code of 1, so clearly it's aware that something has failed.
Yes, installing nodejs via nvm did the trick. Earlier I was using yarn without npm or nvm.
I'm working on WSL2 with Ubuntu 20.04. Even installing node/npm via nvm still produces the error purescript npm installer: installation failed; please try installing again
foo@DESKTOP-E72FACH:~$ which node
/home/foo/.nvm/versions/node/v15.8.0/bin/node
foo@DESKTOP-E72FACH:~$ which npm
/home/foo/.nvm/versions/node/v15.8.0/bin/npm
foo@DESKTOP-E72FACH:~$ which purs
/home/foo/.nvm/versions/node/v15.8.0/bin/purs
foo@DESKTOP-E72FACH:~$ ls $HOME/.nvm/versions/node/v15.8.0/lib/node_modules
bower cnpm gulp npm purescript
foo@DESKTOP-E72FACH:~$ purs
purescript npm installer: installation failed; please try installing again