Skip to content
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

I was unable to test code for url.peg #46

Closed
machinshin opened this issue Aug 29, 2020 · 8 comments
Closed

I was unable to test code for url.peg #46

machinshin opened this issue Aug 29, 2020 · 8 comments

Comments

@machinshin
Copy link

machinshin commented Aug 29, 2020

I tried going through the examples of javascript usage here:
http://canopy.jcoglan.com/langs/javascript.html

but i get the following error:

?> canopy url.peg --lang js
invalid options argument
TypeError: invalid options argument
    at optsArg (/usr/local/lib/node_modules/canopy/node_modules/mkdirp/lib/opts-arg.js:13:11)
    at mkdirp (/usr/local/lib/node_modules/canopy/node_modules/mkdirp/index.js:11:10)
    at write (/usr/local/lib/node_modules/canopy/bin/canopy:32:5)
    at Object.<anonymous> (/usr/local/lib/node_modules/canopy/bin/canopy:37:3)
    at Module._compile (internal/modules/cjs/loader.js:1139:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1159:10)
    at Module.load (internal/modules/cjs/loader.js:988: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

can anyone tell me what the issue here is?

@sumginazu
Copy link

@machinshin I just ran into the same issue. I suspect something in the npm package is out of date. I was able to work around this by building canopy from source, following the instructions in CONTRIBUTING.md. The executable created there works just fine.

@patb2
Copy link

patb2 commented Nov 22, 2020

Encountered same problem, demo examples do not work, throws invalid options argument error, and @sumginazu's workaround did not work either. It's really a pity for such a reputable and widely used library.

@teichopsia
Copy link

fwiw - the problem is mkdirp was converted in 1.x to promises so the syntax invoked in canopy needs updating to

--- node_modules/canopy/bin/canopy      2020-11-23 01:17:52.459859400 -0800
+++ canopy-0.3.0-mkdirp-1.x-patch/canopy        2020-11-23 01:19:03.316873075 -0800
@@ -29,7 +29,7 @@
     var name = names[index];
     if (!name) return;
 
-    mkdirp(path.dirname(name), function(error) {
+    mkdirp(path.dirname(name)).then(function(){
       fs.writeFileSync(name, parser[name]);
       write(index + 1);
     });

so that's a quick patch if you feel like hacking the post npm installed result.

not sure if the author intends on releasing an interim patch to deal with it since 0.3.0 was 5 years back but that solved my use case to just get it running. ymmv. efforts to pin mkdirp to 0.5.1 fell down a npm hole where package{,-lock}.json and npm-shrinkwrap.json all stomp on one another and none of them allow regressing a specific dependency. if somebody figures out a solution to that so be it.

@nippur72
Copy link

nippur72 commented Mar 8, 2021

stumbled on the same issue, since 0.4.0 is lagging can we just have a 0.3.1 with this fixed ?

@Bartvds
Copy link

Bartvds commented Apr 16, 2021

I also had this error and got it working with the above patch.

@jcoglan a fix release to keep current release installable without patching would be nice.

@js850
Copy link

js850 commented Apr 23, 2021

+1, I experienced this also when trying to run the tutorial. The patch by teichopsia fixed it for me.

@jcoglan
Copy link
Owner

jcoglan commented Apr 23, 2021

This issue is fixed in master so I'm going to close this. I haven't had time to work on this project for several months but I will publish new releases as soon as I have time.

@jcoglan
Copy link
Owner

jcoglan commented Apr 1, 2022

This should now be fixed as part of the v0.4 release; see https://blog.jcoglan.com/2022/04/01/announcing-canopy-0-4/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants