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

Cannot open file #74

Open
chrt opened this issue Jan 8, 2022 · 4 comments
Open

Cannot open file #74

chrt opened this issue Jan 8, 2022 · 4 comments

Comments

@chrt
Copy link

chrt commented Jan 8, 2022

I am using Emacs 27.2 and gawk 5.0.0 in Windows.

I failed to review the demo, and the error messages were as follows:

helm-M-x-execute-command: Org-fc shell error: Cannot find file - -L
Cannot find file - -NAME
Cannot find file - -NOT
Cannot find file - -NAME
Access denied - .GIT
Cannot find file - -PRINT0
(
  (:path "
---------- CHANGELOG.ORG

---------- DEMO.ORG

---------- .BUILD.YML

---------- .GITIGNORE
" :cards (
gawk: c:/Users/username/AppData/Roaming/.emacs.d/src/org-fc/awk/index.awk:65: fatal: cannot open file `
---------- CHANGELOG.ORG

---------- DEMO.ORG

---------- .BUILD.YML

---------- .GITIGNORE
' for reading (No such file or directory)

My .emacs.d/init.el is as follows:

(add-to-list 'load-path "c:/Users/username/AppData/Roaming/.emacs.d/src/org-fc/")

;; org-fc
(require 'org-fc)
(require 'org-fc-hydra)
(setq org-fc-directories "d:/Notes")

I tried to review my own cards, but the result is similar.

Any help is appreciated. Thanks!

@l3kn
Copy link
Owner

l3kn commented Jan 14, 2022

How did you set up the find command on windows? Maybe it doesn't support the -L flag and gets confused.

@nv2p
Copy link

nv2p commented Apr 12, 2022

I use emacs 28 native-comp in MSYS2 and ran into the same issue. I can confirm that for me the problem was with find in windows. Adding a setq find-program [msys2 or git path] in my init file, as usually suggested, didn't work for me. "C:\Windows\System32\find.exe" is first in the path if I type where find in eshell and I didn't find how to remove it, only how to add others, which doesn't solve the problem.

So I went for the more radical, but working solution (also in Powershell) of replacing the find.exe in "C:\Windows\System32" with the one from "C:\msys64\usr\bin". I kept the old file in case, but so far so good. You need to change the permissions for this operation (see here how to gain full control, but I suggest only applying this to the file, not the whole folder, and putting things back after ;)).

@l3kn
Copy link
Owner

l3kn commented Jul 1, 2022

I don't have a windows installation to test this on but it seems like the problem could also be solved by explicitly telling org-fc which version of find to use.

Invoking find is handled through the org-fc-awk--find function. A fix might be to overwrite it like this:

(defun org-fc-awk--find (paths)
  (format
   "C:\mysys64\usr\bin\find -L %s -name \"*.org\" -not -name \".*\" -print0"
   (mapconcat
    (lambda (path) (shell-quote-argument (expand-file-name path)))
    paths " ")))

The exact path depends on how and where a compatible find was installed.
If this works, I can add configuration variables for the paths of the find and gawk programs.

Maybe we can also put together a list of paths to use for different installation methods.
Is there also a 32bit version of MYSYS2 with a path of mysys32\usr\bin?
And are there other common methods for installing unix tools on windows?

@nv2p
Copy link

nv2p commented Jul 1, 2022

To be clear, from my point of view, this issue is solved (but can't close myself). It's nice from you to give an ad-hoc fix, but I think it's a more general problem, which has actually nothing to do with org-fc itself. So I think you shouldn't waste time with a list of path or any else. There are many answers on that on SO (like my link above) or other places. That's also why I prefer a global fix to it, as I proposed, cause it's anyway a problem for me if find is unusable in eshell, for instance.

To answer your last question, there are 3 main ways of getting unix tools on Windows to my knowledge (I don't count virtualization, like WSL) :

  1. msys2, which has the advantage to be extensible, cause it's like a (limited) mini-linux in windows
  2. git for windows, which is kind of a customized mini-msys2, for this specific purpose, and contain several classic unix tools
  3. find the executables and add them manually.

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

3 participants