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

Invalid switch #393

Closed
kilokon opened this issue Jun 25, 2019 · 18 comments
Closed

Invalid switch #393

kilokon opened this issue Jun 25, 2019 · 18 comments

Comments

@kilokon
Copy link

kilokon commented Jun 25, 2019

"git" "clone" "--origin" "origin" "--no-checkout" "<url to package.git" "~/.emacs.d/straight/repos/package/"

Packages are not downloading automatically
i have to manually git clone each one.

@raxod502
Copy link
Member

Please provide more information. Otherwise, I have no way of knowing what is wrong. In particular, please provide an init.el file that I can put in an empty user-emacs-directory and reproduce the error, as well as versions of all relevant software.

That being said, perhaps your version of Git is too old.

@kilokon
Copy link
Author

kilokon commented Jun 25, 2019

init file link

The exact error is error: Failed to run "git"
I'm on windows

straight-process buffer shows

$ cd "c:/emacs/emacs-26.2-x86_64/bin/"
$ "find" "/dev/null" "-newermt" "2018-01-01 12:00:00"

FIND: Invalid switch

[Return code: 2]

$ cd "c:/Users/Avik/.emacs.d/straight/repos/"
$ "git" "clone" "--origin" "origin" "--no-checkout" "https://github.com/emacs-straight/seq.git" "c:/Users/Avik/.emacs.d/straight/repos/seq/"

[File error while searching for program]

@raxod502
Copy link
Member

It sounds like you need to install a find program which has support for -newermt. It also sounds like you need to install Git, or perhaps add it to your PATH. How one does these things on Windows, I have no idea. Perhaps somebody who does use Emacs on Windows can help you with that.

@garyo
Copy link

garyo commented Nov 14, 2019

I can help with this -- just got it working on Win10, Emacs27 nightly (2019-10-10).

  1. Install msys2 (this can work with older cygwin too, just adjust exec-path below)
  2. Make sure msys2's usr/bin is in exec-path (usually c:/msys2/usr/bin but may be different depending on how you install msys2)
    1. Check (executable-find "find") returns the proper find, not /Windows/system32/find.exe
    2. Make sure you do this before bootstrapping straight.el
  3. Because find is still run via cmd.exe which has weird quoting rules, you may need this patch:
diff --git a/straight.el b/straight.el
index 1dd3632..4e9c7bd 100644
--- a/straight.el
+++ b/straight.el
@@ -3510,7 +3510,7 @@ modified since their last builds.")
                           (append (list "-o"
                                         "-path"
                                         (format
-                                         "%s/*" (straight--repos-dir
+                                         "\"%s/*\"" (straight--repos-dir
                                                  local-repo))
                                         newer-or-newermt
                                         mtime-or-file

to avoid the /* from getting expanded by the shell and turned into multiple args which would cause the "find" to fail. With this patch it gets passed to find as a single arg.

This works for me; M-x straight-check-all now works with no errors/warnings.

(By the way it would be nice if that invocation of "find" could go into the *straight-process* buffer so we can see the result and any additional output.)

@raxod502
Copy link
Member

(By the way it would be nice if that invocation of "find" could go into the straight-process buffer so we can see the result and any additional output.)

Done! Do you want to submit a pull request for your change to improve functionality on Windows?

@garyo
Copy link

garyo commented Nov 15, 2019

Sure, no problem. One question: is it OK to always quote that arg, or is there another level of arg-quoting that happens before the command gets executed on Linux/Mac? I don't want to break anything for other OSes.

@raxod502
Copy link
Member

In general, it is wrong to put quotes in arguments. The fact that this is needed on Windows is a bizarre quirk, and doing it anywhere else will completely break the command. To work around the Windows problem, I would suggest adding the quoting behavior at the level of straight--call (i.e. where the arguments are passed to call-process). That way, it will be centralized.

@garyo
Copy link

garyo commented Nov 18, 2019

In general, it is wrong to put quotes in arguments

True, of course -- as long as the cmd is started via fork/exec or CreateProcess and not via a shell. I don't know much about how call-process works on Windows, but this issue makes me think it's starting a cmd.exe shell and passing the args to it. I'll look into it further. I expect using shell-quote-argument will be fine on Windows but I'll confirm the details.

@r-darwish
Copy link
Contributor

Thank you all for investigating this. Is there any news about the quoting patch?

@raxod502
Copy link
Member

raxod502 commented Jan 8, 2020

I am not currently aware of any work in this direction. But I think it should be a straightforward change to make by someone who has access to a Windows machine for testing :)

@r-darwish
Copy link
Contributor

I think that I might be able to open a PR that uses Powershell instead of find in Windows. I'll look into that.

@garyo
Copy link

garyo commented Jan 8, 2020

This has been on my list for a long time, sorry -- rather than the simple patch above, I wanted to investigate the best place to put the quotes which means figuring out exactly how the subprocess is started and how the args are passed and whether there's some arg-quoting already happening further down the create-process pipeline and if so why it isn't working. So I haven't really started on it. If you folks have time please do dig into it.

@xeijin
Copy link

xeijin commented Feb 8, 2020

@garyo can we at least have the patch in until someone can take a look? Just spent ages debugging this...

raxod502 added a commit that referenced this issue Feb 9, 2020
Co-authored-by: Radon Rosborough <radon.neon@gmail.com>
@raxod502
Copy link
Member

raxod502 commented Feb 9, 2020

The pull request #473 has been merged, which should address your concern.

raxod502 added a commit that referenced this issue Feb 14, 2020
Co-authored-by: Radon Rosborough <radon.neon@gmail.com>
@raxod502 raxod502 closed this as completed May 9, 2020
@raxod502
Copy link
Member

raxod502 commented May 9, 2020

This thread is being closed automatically by Tidier because it is labeled with "waiting on response" and has not seen any activity for 90 days. But don't worry—if you have any information that might advance the discussion, leave a comment and I will be happy to reopen the thread :)

@MikeGitIt
Copy link

I am still seeing this error on Windows. I have even updated straight to the latest version, to no avail. Am I missing something? Emacs version is 27.1.

@progfolio
Copy link
Contributor

progfolio commented Dec 6, 2020

Could you please provide the following?:

  • windows version
  • find command version
  • output of straight-version
  • contents of *straight-process-buffer*

Have you tried the solution here?: #393 (comment)

@raxod502 raxod502 reopened this Dec 20, 2020
@raxod502
Copy link
Member

This thread is being closed automatically by Tidier because it is labeled with "waiting on response" and has not seen any activity for 90 days. But don't worry—if you have any information that might advance the discussion, leave a comment and I will be happy to reopen the thread :)

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

No branches or pull requests

7 participants