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

org-web-tools-archive-view has a problem with "--auto-compress" #70

Open
maikol-solis opened this issue Feb 5, 2024 · 6 comments
Open

Comments

@maikol-solis
Copy link

In macOS I had the very same issue as #65, with org-web-tools-archive-view. Every time I use the function, this message appears,

Extraction of file failed: tar: Option -a is not permitted in mode -x

I could solve the problem by removing the --auto-compress flag and advising the new function instead of the original one.

Maybe this could be applied upstream if you find useful.

 (defun org-web-tools-archive-view-mod ()
    "Open Zip file archive of web page.
Extracts to a temp directory and opens with
`browse-url-default-browser'.  Note: the extracted files are left
on-disk in the temp directory."
    (interactive)
    (unless (executable-find "unzip")
      (error "Can't find unzip command"))
    (let* ((attach-dir (org-attach-dir t))
	   (files (org-attach-file-list attach-dir))
	   (file (if (= (length files) 1)
		     (car files)
		   (completing-read "Open attachment: "
				    (mapcar #'list files) nil t)))
           (extension (file-name-extension file))
           (archive-path (expand-file-name file attach-dir))
           (temp-dir (make-temp-file "org-web-tools-view-archive-" 'dir)))
      (with-temp-buffer
        (unless (zerop (pcase extension
                         ;; TODO: If/when we want to support only Emacs 26+, we
                         ;; can use the `rx' matcher instead of `file-name-extension',
                         ;; and easily test for e.g. ".tar.xz".
                         ("zip" (call-process (executable-find "unzip") nil t nil
                                              archive-path "-d" temp-dir))
                         ;; Assume that if it's not a zip file, it's a tar archive
                         ;; (`extension' will be just, e.g. "xz").
                         (_ (call-process (executable-find "tar") nil t nil
                                          ;; "--auto-compress"
                                          "--extract"
                                          "--directory" temp-dir
                                          "--file" archive-path))))
          (error "Extraction of file failed: %s" (buffer-string))))
      (->> (directory-files temp-dir 'full-path (rx ".html" eos))
           (-map #'org-web-tools-archive-view--escape-filename)
           (--map (concat "file://" it))
           (-map #'browse-url-default-browser))
      (message "Files extracted to: %s" temp-dir)))

  (advice-add #'org-web-tools-archive-view :override #'org-web-tools-archive-view-mod)

Best.

@alphapapa
Copy link
Owner

Hi,

Sorry, I don't understand: IIUC the solution in the linked issue is to install and use the GNU version of tar, which should make this Elisp advice unnecessary.

@maikol-solis
Copy link
Author

Hi!
Yes, I have installed the gnu-tar via homebrew, as other issue said. And even in this case, the org-web-tools-archive-view doesn't work for me.

@alphapapa
Copy link
Owner

Did you follow the suggestions in #65 (comment) and compare with the following comment? It sounds like you still have Emacs using the non-GNU version of tar, as he did until he did some further configuration.

@maikol-solis
Copy link
Author

Yes I did all the steps in the issue. I put this into my .zshrc

typeset -U path
# PREpend the gnu utils paths
for bindir in "$(brew --prefix)/opt/"*"/libexec/gnubin"; do path=($bindir ${path[@]}); done
# APPend the other homebrew bins
for bindir in "$(brew --prefix)/opt/"*"/bin"; do path+=($bindir); done
# prepend the gnu man pages (optional)
for mandir in "$(brew --prefix)/opt/"*"/libexec/gnuman"; do manpath=($mandir ${manpath[@]}); done
# append the other homebrew man pages (optional)
for mandir in "$(brew --prefix)/opt/"*"/share/man/man1"; do manpath+=($mandir); done
export PATH path

and even I tried the linuxify solution and nothing worked for me.

@alphapapa
Copy link
Owner

One final check: after doing that, did you log out and back in again?

@askdkc
Copy link
Contributor

askdkc commented Feb 6, 2024

@maikol-solis

You should probably use the exec-path-from-shell package for Emacs when running on macOS, in order to properly set the shell path.

I suggest running this in your init.el file.

(use-package exec-path-from-shell
  :ensure t
  :config
  (when (memq window-system '(mac ns x))
    (exec-path-from-shell-initialize)))

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