Giter Club home page Giter Club logo

Comments (3)

nojb avatar nojb commented on June 8, 2024

Could it be related to #1585?

I confirm this is the culprit. The root cause is that Filename.quote_command is given a string that it cannot handle and it fails.

Filename.quote_command prog args

The backtrace in my case is:

failed with Failure("Filename.quote_command: bad file name C:\\cygwin64\\home\\nojebar\\mlfi\\_build/default/.ppx/878efc8ece20bcbf2dd8c437a0746ae0/ppx.exe --as-ppx --cookie \"library-name=\\\"js_core\\\"\"")
# 0.03 Typing_aux.raise_error - Failure
Raised at Stdlib.failwith in file "stdlib.ml", line 29, characters 17-33
Called from Stdlib__Filename.Win32.quote_command in file "filename.ml", line 234, characters 6-28
Called from Merlin_kernel__Pparse.commandline in file "merlin/src/ocaml/driver/pparse.ml" (inlined), line 42, characters 2-34
Called from Merlin_kernel__Pparse.apply_rewriter in file "merlin/src/ocaml/driver/pparse.ml", line 48, characters 13-41
Called from Merlin_kernel__Pparse.rewrite in file "merlin/src/ocaml/driver/pparse.ml", line 118, characters 4-87
Called from Merlin_kernel__Pparse.apply_rewriters_str in file "merlin/src/ocaml/driver/pparse.ml", line 129, characters 16-61
Called from Merlin_kernel__Pparse.apply_rewriters in file "merlin/src/ocaml/driver/pparse.ml", line 144, characters 20-70
Called from Merlin_kernel__Mppx.rewrite.(fun) in file "merlin/src/kernel/mppx.ml", line 27, characters 4-76

However, the call to Filename.quote_command is only used for logging, so it can be easily avoided. The following patch fixes it:

diff --git a/src/ocaml/driver/pparse.ml b/src/ocaml/driver/pparse.ml
index 077e93ff..0bc75ac0 100644
--- a/src/ocaml/driver/pparse.ml
+++ b/src/ocaml/driver/pparse.ml
@@ -39,7 +39,7 @@ let report_error = function
       "External preprocessor does not produce a valid file. Command line: %s" cmd
 
 let commandline prog args =
-  Filename.quote_command prog args
+  Printf.sprintf "%s %s" prog (String.concat ~sep:" " (List.map ~f:Filename.quote args))
 
 let apply_rewriter magic ppx (fn_in, failures) =
   let title = "apply_rewriter" in

This also has the virtue that it matches what the function System.run_in_directory actually uses.

cc @3Rafal @voodoos

from merlin.

voodoos avatar voodoos commented on June 8, 2024

Thanks for taking the time to investigate! I remember we took great care to keep existing windows behavior untouched, it a shame we overlooked that debug call.

I will apply your fix and probably do a patch-release soon.

from merlin.

nojb avatar nojb commented on June 8, 2024

I will apply your fix and probably do a patch-release soon.

Thanks!

from merlin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.