purescript / npm-installer Goto Github PK
View Code? Open in Web Editor NEWLicense: ISC License
License: ISC License
A clear and concise description of what the bug is.
I want to try purescript, and try to install on my void linux musl with yarn and get error instead
Steps to reproduce the behavior.
yarn global add purescript
output:
Command: install-purescript --purs-ver=0.13.8
Arguments:
Directory: /home/gasacchi/.config/yarn/global/node_modules/purescript
Output:
[ SUCCESS ] Check if a prebuilt 0.13.8 binary is provided for linux (4s)
[ SUCCESS ] Download the prebuilt PureScript binary (55s)
[ FAILURE ] Verify the prebuilt binary works correctly
Error: spawn /home/gasacchi/xxx/.dev/gsclinux/.config/yarn/global/node_modules/purescript/purs.bin ENOENT
at Process.ChildProcess._handle.onexit (internal/child_process.js:269:19)
at onErrorNT (internal/child_process.js:465:16)
at processTicksAndRejections (internal/process/task_queues.js:80:21)
↓ Fallback: building from source
[ FAILURE ] Check if 'stack' command is available
Error: Command failed with exit code 2 (ENOENT): stack --allow-different-user --numeric-version
spawn stack ENOENT
at Process.ChildProcess._handle.onexit (internal/child_process.js:269:19)
at onErrorNT (internal/child_process.js:465:16)
at processTicksAndRejections (internal/process/task_queues.js:80:21)
info Visit https://yarnpkg.com/en/docs/cli/global for documentation about this command.
A clear and concise description of what you expected to happen.
purescript success installed
Add any other context about the problem here.
running on Void linux with musl libc
0.13.8
I am following the instructions for installing PureScript via the NPM installer. I ran sudo npm install -g purescript
, which gave the following output:
npm WARN deprecated [email protected]: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated [email protected]: this library is no longer supported
/usr/local/bin/purs -> /usr/local/lib/node_modules/purescript/purs.bin
> [email protected] postinstall /usr/local/lib/node_modules/purescript
> install-purescript --purs-ver=0.14.0
However, when I run purs
to check the installation, the following message is logged:
purescript npm installer: installation failed; please try installing again
I am on a PC running Windows 10 with Ubuntu 20.04 LTS installed via WSL (Windows Subsystem for Linux). All of the commands listed above are on Bash in WSL.
I tried to install PureScript in a Docker container with a GraalVM backend. But because of some hacky postinstall steps it fails. Check out oracle/graaljs#157 (comment) for details.
Can we simplify this?
It would be useful to have the ability to skip purescript binary installation in certain scenarios.
For example, if the binary is supplied using another method, or just not needed. For example, in my case I have purescript
as npm dependency in the project and it is used on host system, also packages declared in project are installed in docker container, but I don't run purs there, though the package should be is installed. But as I use alpine based images installations throws with error. So currently have to use a hacky way to avoid running purescirpt install.
The solution could be not to perform install operation if a env variable i.e. SKIP_INSTALL_PURESCRIPT
is set. This is kind a common solution used by packages that require binary which may cause issues just as an example pupeeter uses PUPPETEER_SKIP_CHROMIUM_DOWNLOAD
env for such case.
Acording to official purescript docs, npm i -g purescript
is the official way to install purescript. However it fails with a syntax error and I think it is because this package:
➜ npm i -g purescript
/Users/danielo/.nvm/versions/node/v8.15.0/bin/purs -> /Users/danielo/.nvm/versions/node/v8.15.0/lib/node_modules/purescript/purs.bin
> [email protected] postinstall /Users/danielo/.nvm/versions/node/v8.15.0/lib/node_modules/purescript
> install-purescript --purs-ver=0.13.0
/Users/danielo/.nvm/versions/node/v8.15.0/lib/node_modules/purescript/node_modules/install-purescript-cli/index.js:97
} catch {
^
SyntaxError: Unexpected token {
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Module._compile (module.js:617:28)
at Object.Module._extensions..js (module.js:664:10)
at Module.load (module.js:566:32)
at tryModuleLoad (module.js:506:12)
at Function.Module._load (module.js:498:3)
at Function.Module.runMain (module.js:694:10)
at startup (bootstrap_node.js:204:16)
at bootstrap_node.js:625:3
npm ERR! code ELIFECYCLE
I'm using node 8.15.0
Regards
Right now, whenever we fall back to building the compiler from source, we don't include the output from stack
while building. This is very inconvenient if stack
fails. For example, this can be seen in both #16 (comment) and in #21 (comment).
For systems which aren't based on glibc, such as Alpine, or for systems like Nix which put the glibc dynamic loader in a weird place, the installer fails with this rather unhelpful error:
✖ Verify the prebuilt binary works correctly
/home/skykanin/.npm-global/lib/node_modules/purescript/purs.bin --version
Error: spawn /home/skykanin/.npm-global/lib/node_modules/purescript/purs.bin ENOENT
at Process.ChildProcess._handle.onexit (internal/child_process.js:268:19)
This was observed in both #16 and #21. I would like to improve this error by catching ENOENT, checking that purs.bin
does in fact exist (just in case), and if it does, checking whether its dynamic loader is a file which exists. If it doesn't, we could output a message along the lines of:
The prebuilt binary does not appear to be suitable for your system (specifically, the dynamic loader /lib64/ld-linux-x86-64.so.2 was not found).
and then fall back to building from source. We'll have to depend on an ELF parser to manage this but I think it's justifiable.
Installing purescript 0.15.5+ fails intermittently inside Docker. This happens on node:14
and node:16
but not as frequently on node:16
.
Sending build context to Docker daemon 2.048kB
Step 1/3 : FROM node:14
---> 2779c31a94ee
Step 2/3 : WORKDIR /app
---> Running in b065f91136c7
Removing intermediate container b065f91136c7
---> c63b2cb29798
Step 3/3 : RUN npm install purescript@"0.15.6"
---> Running in f99acf33f1da
> [email protected] postinstall /app/node_modules/purescript
> install-purescript --purs-ver=0.15.6
[ SUCCESS ] Check if a prebuilt 0.15.6 binary is provided for linux (899ms)
[ SUCCESS ] Download the prebuilt PureScript binary (2s)
[ FAILURE ] Verify the prebuilt binary works correctly
Error: spawn ETXTBSY
at ChildProcess.spawn (internal/child_process.js:408:11)
at spawn (child_process.js:677:9)
at execFile (child_process.js:311:17)
at child_process.js:221:29
at Object.complete (/app/node_modules/purescript-installer/download-or-build-purescript/index.js:182:31)
at notifySubscription (/app/node_modules/zen-observable/lib/Observable.js:145:18)
at onNotify (/app/node_modules/zen-observable/lib/Observable.js:179:3)
at SubscriptionObserver.complete (/app/node_modules/zen-observable/lib/Observable.js:245:7)
at /app/node_modules/purescript-installer/dl-tar/index.js:222:15
at /app/node_modules/purescript-installer/cancelable-pump/index.js:34:3
at internal/util.js:435:14
at finish (internal/streams/pipeline.js:162:7)
at internal/util.js:435:14
at InternalUnpack.<anonymous> (internal/streams/pipeline.js:65:7)
at InternalUnpack.<anonymous> (internal/util.js:435:14)
at InternalUnpack.onfinish (internal/streams/end-of-stream.js:94:46)
See troubleshooting suggestions in https://github.com/purescript/purescript/blob/master/INSTALL.md
↓ Fallback: building from source
[ FAILURE ] Check if 'stack' command is available
Error: Command failed with exit code 2 (ENOENT): stack --allow-different-user --numeric-version
spawn stack ENOENT
at Process.ChildProcess._handle.onexit (internal/child_process.js:277:19)
at onErrorNT (internal/child_process.js:472:16)
at processTicksAndRejections (internal/process/task_queues.js:82:21)
See troubleshooting suggestions in https://github.com/purescript/purescript/blob/master/INSTALL.md
npm WARN enoent ENOENT: no such file or directory, open '/app/package.json'
npm WARN app No description
npm WARN app No repository field.
npm WARN app No README data
npm WARN app No license field.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] postinstall: `install-purescript --purs-ver=0.15.6`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] 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/2022-10-21T09_38_51_311Z-debug.log
The command '/bin/sh -c npm install purescript@"0.15.6"' returned a non-zero code: 1
docker build --no-cache . 5,67s user 0,32s system 15% cpu 37,687 total
Steps to reproduce:
Dockerfile
FROM node:14
WORKDIR /app
RUN npm install purescript@"0.15.6"
build Dockerfile
docker build --no-cache .
repeat until you get the error.
I think it might have to do with changes made to the installer between 0.2.6 and 0.3.1 as purescript 0.15.4 uses version 0.2.6 of the installer and works perfectly every time.
Docker versions tested:
Docker version 20.10.19, build d85ef84533
Docker version 20.10.12, build 20.10.12-0ubuntu4
Raised as a possibility in #21 . Currently, building purs
on Nix is unlikely to work, as stack setup
reports:
I don't know how to install GHC on your system configuration, please install manually
I honestly have no idea how good of an idea this is; if we can't do this reliably then I think it could easily cause more pain than it would solve. Perhaps we should just not support Nix at all; Nix users do have other options for installing the compiler.
The purescript
npm package currently has an engines
constraint of >= 10.16.0
, but this does not appear to be sufficient to stop people getting confused when the installer fails on older node versions, see e.g. purescript/purescript#3677. I think this is because npm
only warns on an unsatisfied engines
constraint by default rather than erroring.
We can make these failures easier to understand (and also not reliant on details of the particular npm client in use) by checking for them manually in this package and generating the appropriate errors ourselves.
This greatly slows down the process of installing purescript and isn't really necessary (especially since we need to uncompress the binary later on in order to actually use it).
Please can a custom binaries url be supported for use in the enterprise.
Setting a Path variable like chromedriver would work well.
Thanks
Node 8 is still officially supported until january 2020: https://nodejs.org/en/about/releases/
Over the past few months a few folks have popped in to the PureScript chat and Discourse to ask about the warnings emitted when installing PureScript via NPM, most recently:
https://discourse.purescript.org/t/warnings-when-installing-the-compiler
We should update this package to provide a better first experience to new PureScripters.
I don't have the right silicon to experiment with this myself, but we should have the installer detect and download the new linux-arm64 and macos-arm64 binaries. @f-f
Installing purescript through npm i -g purescript
fails with output shown underneath. Also tried installing the package in a local project, but got the same error.
Full debug log here
npm WARN deprecated [email protected]: request has been deprecated, see https://github.com/request/request/issues/3142
/home/skykanin/.npm-global/bin/purs -> /home/skykanin/.npm-global/lib/node_modules/purescript/purs.bin
> [email protected] postinstall /home/skykanin/.npm-global/lib/node_modules/purescript
> install-purescript --purs-ver=0.13.6
✔ Check if a prebuilt 0.13.6 binary is provided for linux (1s)
✔ Download the prebuilt PureScript binary (9s)
✖ Verify the prebuilt binary works correctly
/home/skykanin/.npm-global/lib/node_modules/purescript/purs.bin --version
Error: spawn /home/skykanin/.npm-global/lib/node_modules/purescript/purs.bin ENOENT
at Process.ChildProcess._handle.onexit (internal/child_process.js:268:19)
at onErrorNT (internal/child_process.js:468:16)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
▬ Save the downloaded binary to the npm cache directory
↓ Fallback: building from source
✖ Check if 'stack' command is available
stack --allow-different-user --numeric-version
Error: Command failed with exit code 2 (ENOENT): stack --allow-different-user --numeric-version
spawn stack ENOENT
at Process.ChildProcess._handle.onexit (internal/child_process.js:268:19)
at onErrorNT (internal/child_process.js:468:16)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
▬ Download the PureScript 0.13.6 source
▬ Ensure the appropriate GHC is installed
▬ Build a binary from source
▬ Save the built binary to the npm cache directory
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] postinstall: `install-purescript --purs-ver=0.13.6`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] 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! /home/skykanin/.npm/_logs/2020-05-07T17_45_44_600Z-debug.log
npm i -g purescript
I expect the package to install correctly without failure.
OS Info:
Npm info:
prefix=~/.npm-global
Allows npm packages to be installed globally on NixOS
0.13.6
Trying to run
npm i -g purescript
On alpine:3.10.1 in a docker container.
node v10.16.0
npm v6.9.0
716 verbose stack Error: [email protected] postinstall: install-purescript --purs-ver=0.13.2
716 verbose stack Exit status 1
716 verbose stack at EventEmitter. (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:301:16)
716 verbose stack at EventEmitter.emit (events.js:198:13)
716 verbose stack at ChildProcess. (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
716 verbose stack at ChildProcess.emit (events.js:198:13)
716 verbose stack at maybeClose (internal/child_process.js:982:16)
716 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
Also attaching a log file:
2019-07-14T03_13_09_728Z-debug.log
Full log at https://gist.github.com/bbarker/dc27562e3919883b09982d31fe11dbad
$ npm install purescript --save-dev
npm WARN deprecated [email protected]: request has been deprecated, see https://github.com/request/request/issues/3142
> [email protected] postinstall /wd/node_modules/purescript
> install-purescript --purs-ver=0.13.6
internal/modules/cjs/loader.js:797
throw err;
^
Error: Cannot find module 'psl'
Require stack:
- /wd/node_modules/tough-cookie/lib/pubsuffix-psl.js
- /wd/node_modules/tough-cookie/lib/cookie.js
- /wd/node_modules/request/lib/cookies.js
- /wd/node_modules/request/index.js
- /wd/node_modules/purescript-installer/dl-tar/index.js
- /wd/node_modules/purescript-installer/download-purescript-source/index.js
- /wd/node_modules/purescript-installer/build-purescript/index.js
- /wd/node_modules/purescript-installer/download-or-build-purescript/index.js
- /wd/node_modules/purescript-installer/install-purescript/index.js
- /wd/node_modules/purescript-installer/index.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:794:15)
at Function.Module._load (internal/modules/cjs/loader.js:687:27)
at Module.require (internal/modules/cjs/loader.js:849:19)
at require (internal/modules/cjs/helpers.js:74:18)
at Object.<anonymous> (/wd/node_modules/tough-cookie/lib/pubsuffix-psl.js:32:11)
at Module._compile (internal/modules/cjs/loader.js:956:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:973:10)
at Module.load (internal/modules/cjs/loader.js:812:32)
at Function.Module._load (internal/modules/cjs/loader.js:724:14)
at Module.require (internal/modules/cjs/loader.js:849:19)
at require (internal/modules/cjs/helpers.js:74:18)
at Object.<anonymous> (/wd/node_modules/tough-cookie/lib/cookie.js:35:17)
at Module._compile (internal/modules/cjs/loader.js:956:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:973:10)
at Module.load (internal/modules/cjs/loader.js:812:32)
at Function.Module._load (internal/modules/cjs/loader.js:724:14) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/wd/node_modules/tough-cookie/lib/pubsuffix-psl.js',
'/wd/node_modules/tough-cookie/lib/cookie.js',
'/wd/node_modules/request/lib/cookies.js',
'/wd/node_modules/request/index.js',
'/wd/node_modules/purescript-installer/dl-tar/index.js',
'/wd/node_modules/purescript-installer/download-purescript-source/index.js',
'/wd/node_modules/purescript-installer/build-purescript/index.js',
'/wd/node_modules/purescript-installer/download-or-build-purescript/index.js',
'/wd/node_modules/purescript-installer/install-purescript/index.js',
'/wd/node_modules/purescript-installer/index.js'
]
}
npm WARN purescript-metajelo@ No repository field.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] postinstall: `install-purescript --purs-ver=0.13.6`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] post
[2020-03-02T16_53_17_120Z-debug.log](https://github.com/purescript/npm-installer/files/4276715/2020-03-02T16_53_17_120Z-debug.log)
[2020-03-02T16_53_17_120Z-debug.log](https://github.com/purescript/npm-installer/files/4276719/2020-03-02T16_53_17_120Z-debug.log)
install 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! /home/brandon/.npm/_logs/2020-03-02T16_53_17_120Z-debug.log
$ node --version
v12.13.0
Full container specification at https://github.com/bbarker/purescript-hodgepodge
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.
Steps to reproduce the behavior.
sudo npm install -g purescript
purs
I am expecting it to do something other than above.
Spago installs just fine with sudo, and I am able to do spago init
but spago build
does not work as it uses purs
I read https://harry.garrood.me/blog/malicious-code-in-purescript-npm-installer/
Your installer is still vulnerable. The simplest solution is to use a shrinkwrap file
npm shrinkwrap
It will freeze dependencies including deep dependencies.
5 July, around 2100 UTC: [email protected] is published, with an exploit breaking the purescript npm installer
Locking dependencies will make sure that your software will not change whenever someone updates another package without opt in.
The compiler maintainers investigate, and for a while, we are stumped. It’s difficult to reliably reproduce, as the failure doesn’t occur in a local checkout of the purescript npm installer.
My hypothesis is that you used package-lock instead of shrink-wrap. So you had frozen dependencies when installing locally, but when purescript npm installer was installed it was not the case.
Readme links to https://github.com/purescript-contrib/node-purescript. The link results 404
. There probably exists a new name for node-purescript
When I run purs --version I get an error
PS C:\dev\lang\purescript\project\purescript-book\exercises\chapter2> purs --version
ResourceUnavailable: C:\Users\ammsel\AppData\Roaming\npm\purs.ps1:10
Line |
10 | & "$basedir/node_modules/purescript/purs.bin" $args
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Program 'purs.bin' failed to run: No application is associated with the specified file for this operation.At C:\Users\ammsel\AppData\Roaming\npm\purs.ps1:10 char:1 + &
| "$basedir/node_modules/purescript/purs.bin" $args + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~.
This is how I installed purescript
PS C:\dev\lang\purescript\project\purescript-book\exercises\chapter2> npm install -g purescript
npm WARN deprecated [email protected]: this library is no longer supported
npm WARN deprecated [email protected]: request has been deprecated, see https://github.com/request/request/issues/3142
added 152 packages, and audited 153 packages in 14s
6 packages are looking for funding
run `npm fund` for details
Note that commands such as spago test
and spago repl
seem to run fine
PS C:\dev\lang\purescript\project\purescript-book\exercises\chapter2> spago repl
PSCi, version 0.13.8
Type :? for help
>
Also note I am running windows 10
I was trying to force the installer to build PureScript from source by modifying supportedPlatforms
(removing all platforms) and architecture check (so it would always be false
). When doing so, the installer fails with the following output:
/.../npm-installer (master*=) % node index.js --purs-ver=0.15.7
✖ Check if a prebuilt 0.15.7 binary is provided for linux
No prebuilt PureScript binary is provided for x64 architecture.
See troubleshooting suggestions in https://github.com/purescript/purescript/blob/master/INSTALL.md
▬ Download the prebuilt PureScript binary
▬ Verify the prebuilt binary works correctly
▬ Save the downloaded binary to the npm cache directory
↓ Fallback: building from source
/.../npm-installer/node_modules/zen-observable/lib/Observable.js:65
throw e;
^
TypeError: Cannot read properties of undefined (reading 'has')
at getCurrentTask (/.../npm-installer/index.js:308:24)
at Object.next (/.../npm-installer/index.js:376:16)
at notifySubscription (/.../npm-installer/node_modules/zen-observable/lib/Observable.js:135:18)
at onNotify (/.../npm-installer/node_modules/zen-observable/lib/Observable.js:179:3)
at SubscriptionObserver.next (/.../npm-installer/node_modules/zen-observable/lib/Observable.js:235:7)
at Object.next (/.../npm-installer/install-purescript/index.js:89:15)
at notifySubscription (/.../npm-installer/node_modules/zen-observable/lib/Observable.js:135:18)
at onNotify (/.../npm-installer/node_modules/zen-observable/lib/Observable.js:179:3)
at SubscriptionObserver.next (/.../npm-installer/node_modules/zen-observable/lib/Observable.js:235:7)
at /.../npm-installer/download-or-build-purescript/index.js:246:13
Node.js v19.6.1
The problem is somewhat fixed with the following patch (the output would be slightly messed up. I guess there's a better fix):
diff --git a/index.js b/index.js
index 3164858..f6398f8 100755
--- a/index.js
+++ b/index.js
@@ -160,6 +160,13 @@ const taskGroups = [
]
]),
new TaskGroup([
+ [
+ 'head',
+ {
+ head: 'Build from source',
+ status: 'processing'
+ }
+ ],
[
'check-stack',
{
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.