-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Initialize .purs-repl file. #260
Conversation
What's the error? |
The psvm isn't working properly. I tried to resolve by
|
Might be a psvm bug, then. Hm. Seems to be failing during |
Yeah, that works fine.
I can't figure out why that scripts.js file is executed when I do
I added psvm to PATH, but it's still failing... |
Running scripts.js is supposed to happen, it's part of the prepublish script in package.json. It should use a locally installed psvm too, and also npm scripts set up your PATH for you so you shouldn't need to modify it. |
I managed to fix the issues I had with scripts.js. I'm not sure the exact problem, but I changed the call to "spawnSync" to pass the command's args to the second parameter, "args List of string arguments". Note that I also removed the extra quoting around "bower_components/purescript-/src/**/.purs". I'm guessing that the globbing is a little goofy when passing into a subshell. I'm not sure where this is expanded now. With this fixed, I was able to test the |
I'd rather not make changes like this to scripts.js unless we know exactly what's causing it, especially since this error only seems to occur on your machine - it's always worked on mine and on Travis, but with this change Travis has started failing. |
Oh also, |
Right, I agree. I'm on Fedora 25, btw. I'll reboot and retry the standard build later. |
What version of Node.js are you using, by the way? |
The package.json specifies node > 4 and mine is node 4.6, IIRC. I'll update later when I'm on that OS again. |
Yeah, issue persists after reboot and trying again, on both Node v4.4.6 and v4.7.0. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No thank you; this version range applies to people trying to run pulp, so it shouldn't be influenced by requirements for development (if it is true that they are tighter). 4.x.x is very old now too.
What happens if you update to node 6? |
Yeah, I wanted to commit this to see if that would fix the CI run - I saw the CI was using v6 before, while I was using v4. I'm using v4 in my own projects because I had troubles with latest node versions because of its flat dependency structuring. I'll try building in a Docker image using Node 6. |
I think you'll have to modify .travis.yml and/or appveyor.yml if you want the CI to use a different version of Node. |
Ah, yeah, you're right - my change to the "engine" property didn't control the version of Node used by Travis. That property does control the node version used by buildpack apps, it's worth noting, which is used in Heroku and its clones. I was able to successfully build using Node v6 by using this command: [chexxor@fedora] $ docker run -it --rm -v `pwd`:/usr/src/app -w /usr/src/app node:6.10.0 bash
root@7dfde777ca59 $ cd usr/src/app
root@7dfde777ca59 $ npm run build
# ... all runs ok ... Do you want me to create a CONTRIBUTING file? Or a section in README? |
It would be better to check the node version at the beginning of scripts.js and fail with an error if it's too old, I think. |
I think at this point we can fairly safely say that this was due to an API change; sometime between 4.x and 6.x spawnSync must have gained the ability to use a shell command. Now that we know what's causing it, I think I prefer your original approach, come to think of it. |
The only issue I can see with your original fix is that it doesn't quite preserve all the information faithfully when printing a command. I think it would be preferable to use util.inspect on the args array than to join them with spaces. Then there's less risk of it being misinterpreted, I think. |
@hdgarrood I don't quite follow - you would like to support Node v4 users? If so, we would split the command's executable from it's args, as I first tried. However, I agree with your original suggestion - it's ok to expect people to use the latest Node version for building pulp. |
I would like to use the variant that doesn't involve shells, because quoting things is a pain and because shells are a great way of accidentally breaking things on OSes you aren't developing on. One byproduct of this is that it enables people to develop on node v4 which I guess is nice but I'm not really fussed about that. |
Looks like Node v4 doesn't expand the globs while Node v6 does. See how the arg is expanded when using "echo" instead of "psa": "compile": {
cmd: "echo",
args: ["bower_components/purescript-*/src/**/*.purs"]
},
// in node v4
>> echo [ 'bower_components/purescript-*/src/**/*.purs' ]
bower_components/purescript-*/src/**/*.purs
// Seems to pass it to subshell *quoted*, like `echo "bower_components/purescript-*/src/**/*.purs"`
// in Node v6
>> echo [ 'bower_components/purescript-*/src/**/*.purs' ]
bower_components/purescript-ansi/src/Ansi/Codes.purs bower_components/purescript-ansi/src/Ansi/Output.purs
// Seems to pass it to subshell *unquoted* like `echo bower_components/purescript-*/src/**/*.purs` This means that configuring args in one way produces two different behaviors in Node v4 and v6. "compile": {
cmd: "psc",
args: [
"-c",
"\"bower_components/purescript-*/src/**/*.purs",
"src/**/*.purs",
]
},
// is equivalent to this (note the quoted quotes) in Node v4 (which fails)
// $ psc -c ' "bower_components/purescript-*/src/**/*.purs" ' ' "src/**/*.purs" '
// and this in Node v6 (which works)
// $ psc -c "bower_components/purescript-*/src/**/*.purs" "src/**/*.purs" I think the Node v4 doesn't support the "shell" option to "spawnSync". Looks like it was added in Jan 2016 by nodejs/node#4598. Looks like it was also backported to Node v4 at some point, but only >v4.8 (moxystudio/node-cross-spawn#69). I was using v4.6. :( I tried in v4.8 and confirm it works. |
c41dbd8
to
65396ab
Compare
My impression was that using the calling style with a single string for the command and then an array of strings for the arguments would mean that it doesn't use a shell. Is that not correct? |
Here's what that "shell" flag does: https://github.com/nodejs/node/blob/98e54b0bd4854bdb3e2949d1b6b20d6777fb7cde/lib/child_process.js#L410 If true, it turns the command and args into a single string and puts it into a shell: If false, it just executes it as-is, I believe: |
I wasn't able to get the commands to work with |
Are you sure that's what it happens if you provide an args array and don't specify |
The docs for node 6 say |
Anyway this is not really related to the original issue - can you please add a note to the commit message that this fixes whichever issue it is, and then I'll merge? |
If you'd like I'm very happy to keep discussing this in a new PR. |
Keep discussing the shell issue, I mean. |
65396ab
to
b81cc05
Compare
b81cc05
to
94d4819
Compare
Updated commit to include #259. Very kind of you, but I am so burned out on that shell issue. Better to just use latest versions of Node. |
Understandable. Thank you! |
Would be nice to initialize a .purs-repl file having "import Prelude". This would allow newcomers to PS to do
pulp init
followed by1+1
and not get a "Unknown operator (+)" error.This file would only be read by psci/purs repl when purescript/purescript#2735 is merged, and likely included in the PS v0.11 release.
I haven't build/tested this change, yet, as my
npm run build
is failing, and I can't find further instructions in this repo for building.