Problem installing Esy on Ubuntu 19.10


#1

I am having trouble getting ReasonML working with Emacs. Right now I am at the point where I am triyng to install refmt, which appears to only be bundled with reason-cli, correct? But reason-cli hasn’t been updated in 2 years according to github! It failed at trying to install esy, so I decided to install esy alone to see what the error is. Here is what I have so far:

sudo npm install -g esy

/usr/bin/esy -> /usr/lib/node_modules/esy/_build/default/bin/esy.exe                                                                  
                                                                                                                                      
> esy-solve-cudf@0.1.10 postinstall /usr/lib/node_modules/esy/node_modules/esy-solve-cudf                                             
> node ./postinstall.js                                                                                                               
                                                                                                                                      
internal/fs/utils.js:230                                                                                                              
    throw err;                                                                                                                        
    ^

Error: EACCES: permission denied, rename '/usr/lib/node_modules/esy/node_modules/esy-solve-cudf/platform-linux/esySolveCudfCommand.ex$
' -> '/usr/lib/node_modules/esy/node_modules/esy-solve-cudf/esySolveCudfCommand.exe'
    at Object.renameSync (fs.js:680:3)
    at install (/usr/lib/node_modules/esy/node_modules/esy-solve-cudf/postinstall.js:10:6)
    at Object.<anonymous> (/usr/lib/node_modules/esy/node_modules/esy-solve-cudf/postinstall.js:16:5)
    at Module._compile (internal/modules/cjs/loader.js:1147:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1167:10)
    at Module.load (internal/modules/cjs/loader.js:996:32)
    at Function.Module._load (internal/modules/cjs/loader.js:896:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
    at internal/main/run_main_module.js:17:47 {
  errno: -13,
  syscall: 'rename',
  code: 'EACCES',
  path: '/usr/lib/node_modules/esy/node_modules/esy-solve-cudf/platform-linux/esySolveCudfCommand.exe',
  dest: '/usr/lib/node_modules/esy/node_modules/esy-solve-cudf/esySolveCudfCommand.exe'
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! esy-solve-cudf@0.1.10 postinstall: `node ./postinstall.js` 
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the esy-solve-cudf@0.1.10 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2020-03-14T17_08_34_024Z-debug.log

#2

Do you have write access to /usr/bin? With the right permissions, this can be solved - sudo might help if it is an option there.

Alternatively, npm supports --prefix. You can install the esy binary to a location (like /usr/local/bin) which is already on you $PATH

$ npm i --prefix /usr/local -g esy 

Quirks Of Installation On Ubuntu
#3

@prometheansacrifice, I was just wondering, is reason-cli supposed to never be installed globally? I did a normal local install (without -g) and it worked fine. Thank you for pointing that out.


#4

So, there might be some changes in the recommended best practises - we’ll know with the next release of reason-cli. In the meantime, rest assured esy should definitely be installed globally on the machine.

For easy of distribution, esy is installed via npm. We’re working on getting esy to build from source easily and with it should be easy to distribute esy via system wide package managers like brew, apt-get etc. NPM gave us a great head start but has caused issues on some machines (like the Ubuntu issue you mention, Windows etc). Building from source should solve this

A common (unsafe) workaround that works for many is npm’s --unsafe-perm

npm i -g esy --unsafe-perms

In future if you get stuck, try it. This should work for any globally installed npm tool when there is trouble with permissions. Warning: npm advises against the usage of --unsafe-perms