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-refile does not work. org-copy-subtree: Invalid function: org-preserve-local-variables #11801

Closed
Lchyang opened this issue Jan 6, 2019 · 40 comments

Comments

@Lchyang
Copy link

Lchyang commented Jan 6, 2019

Description
org-refile does not work.

Reproduction guide 🐞
Start Emacs
Open an .org file
Go to a headline and try to refile by , R
select a target
Observed behaviour: 👀 💔
I get the following message:
Getting targets...done
Copied: Subtree(s) with 22 characters
org-copy-subtree: Invalid function: org-preserve-local-variables

Expected behaviour: ❤️ 😄
refile could be used

System Info 💻

  • OS: darwin
  • Emacs: 25.3.1
  • Spacemacs: 0.200.13
  • Spacemacs branch: master (rev. c7a103a)
  • Graphic display: t
  • Distribution: spacemacs
  • Editing style: vim
  • Completion: helm
  • Layers:
    ‘‘‘elisp
    (markdown
    (ibuffer :variables ibuffer-group-buffers-by ’projects)
    (chinese :variables chinese-enable-youdao-dict t)
    auto-completion emacs-lisp
    (python :variables python-sort-imports-on-save t python-enable-yapf-format-on-save t)
    django org syntax-checking)
    ‘‘‘

my org config:

(with-eval-after-load 'org

  (setq org-agenda-files '("~/org/gtd/inbox.org"
                          "~/org/gtd/gtd.org"
                          "~/org/gtd/tickler.org"))

  (setq org-capture-templates '(("t" "Todo [inbox]" entry
                                (file+headline "~/org/gtd/inbox.org" "Tasks")
                                "* TODO %i%?")
                                ("T" "Tickler" entry
                                (file+headline "~/org/gtd/tickler.org" "Tickler")
                                "* %i%? \n %U")))


  (setq org-refile-targets
          '((nil :maxlevel . 3)
          (org-agenda-files :maxlevel . 3)))

  (setq org-refile-use-outline-path 'file)

  (setq org-outline-path-complete-in-steps nil)

  (setq org-todo-keywords '((sequence "TODO(t)" "WAITING(w)" "|" "DONE(d)" "CANCELLED(c)")))
@samspills
Copy link
Contributor

This is probably the same as here: #11788

Could you try removing all org*/*.elc files from your elpa directory and recompile? I did the following:

cd ~/.emacs.d/elpa/develop
find org*/*.elc -print0 | xargs -0 rm

and then inside spacemacs I ran spacemacs/recompile-elpa.

@Lchyang
Copy link
Author

Lchyang commented Jan 7, 2019

Thank you very much, I used the master branch.
I did this:

cd ~/.emacs.d/elpa
find org*/*.elc -print0 | xargs -0 rm

and the problem is solved.

@snuffop
Copy link
Contributor

snuffop commented Jan 9, 2019

Just a Note: even after installing ~/.emacs.d fresh, one needs to still follow the above after installed.

@breadncup
Copy link

I believe this is a bug in org or org-refile somewhere. Why does removing the byte compiled files resolve the issue? It's ridiculous. Shouldn't everything work fine with byte compiled one as well?

@snuffop
Copy link
Contributor

snuffop commented Jan 14, 2019

Your right. I believe that it May have something to do with load order or the recompile after update reads in previously uncompiled code. Not sure.

@skrobul
Copy link

skrobul commented Jan 20, 2019

Had the same error, but with org-gcal instead. Running the commands above did not help, so I decided to nuke all *.elc files in ~/.emacs.d, then ran spacemacs/recompile-elpa and the problem is gone.

@lsyoyo
Copy link

lsyoyo commented Feb 13, 2019

@samspills I did what you mentioned in your comment, and I even did what @skrobul suggested, I still have issue, any suggestions?

@lsyoyo
Copy link

lsyoyo commented Feb 13, 2019

I moved up one directory level (~/.emacs.d/elpa) and then did the steps again, after that it worked.

@sydneyweidman
Copy link

Had the same error, but with org-gcal instead. Running the commands above did not help, so I decided to nuke all *.elc files in ~/.emacs.d, then ran spacemacs/recompile-elpa and the problem is gone.

I'm running develop on Ubuntu 18.06 and this was the only thing that worked for me.
Even removing the elc files from .emacs.d/elpa didn't work. Had to do the whole tree from .emacs.d on down.

@jscott22
Copy link

jscott22 commented Mar 1, 2019

Had the same error, but with org-gcal instead. Running the commands above did not help, so I decided to nuke all *.elc files in ~/.emacs.d, then ran spacemacs/recompile-elpa and the problem is gone.

I'm running develop on Ubuntu 18.06 and this was the only thing that worked for me.
Even removing the elc files from .emacs.d/elpa didn't work. Had to do the whole tree from .emacs.d on down.

This worked for me, thanks!!

@bleggett
Copy link

bleggett commented Apr 16, 2019

This needs to be reopened, there is a workaround, but the core issue has not been resolved in Spacemacs yet, and even when fixed it recurs when packages are updated.

Looks like it was fixed in doom-emacs thusly:
doomemacs/doomemacs@574dae1

@fabrik42
Copy link
Contributor

Hi! Another hint for the people that still face problems:

I am using the emacs-plus homebrew formula with the new version 26.2.

I didn't find .elc files to delete and spacemacs/recompile-elpa didn't recompile anything (just warnings and skippings).

The reason was that I needed to delete the .elc files in another directory:

cd ~/.emacs.d/elpa/26.2/develop
find org*/*.elc -print0 | xargs -0 rm

Then run spacemacs/recompile-elpa - refile away!

@jkonecny12
Copy link

As already told in #11801 (comment) cloud you please re-open this issue?

@Lchyang Lchyang reopened this May 8, 2019
@kutsurak
Copy link

Hi all,

I removed all the .elc files under ~/.emacs.d/, but spacemacs/recompile-elpa did not recompile anything. I had to evaluate the following s-exp: (byte-recompile-directory "~/.emacs.d/elpa" 0 t). The version shown in the *spacemacs* buffer is 0.200.13@26.2

@kepi
Copy link
Contributor

kepi commented May 17, 2019

It would be great to have this resolved. Currently I'm simply updating spacemacs after every package update like this:

  1. update packages
  2. exit spacemacs
  3. run spacemacs git update with this "oneliner":
cd ~/.emacs.d && git pull --rebase; find ~/.emacs.d/elpa/2*/develop/org-plus-contrib* -name '*.elc' -delete # update spacemacs

Edit: There is no need to recompile anything for me as it gets compiled automatically.

@Technologicat
Copy link
Contributor

Happens with org-sort-entries too.

Nuking all .elc files under ~/.emacs.d and then running M-x spacemacs/recompile-elpa helped, as suggested by @skrobul . Incantation used: cd ~/.emacs.d && find . -name *.elc -print0 | xargs -0 rm

@LorenRiccie
Copy link

Worked
(Emacs 26.1, master branch on Debian Buster)

@Zlopez
Copy link

Zlopez commented Oct 7, 2019

I'm using the latest develop and wasn't able to do org-archive-subtree and instead got this error.

I recompiled the files and this fixed it.

@plajjan
Copy link

plajjan commented Nov 18, 2019

+1, @Technologicat incantation worked to fix the org-refile issue.

@andrewjesaitis
Copy link

Just to echo @breadncup's comment. I'm not using spacemacs, but use emacs26 and org-mode and this happens to me every once in a while. After googling, I always end up hitting this thread and just deleting all *.elc files in my elpa directory fixes it. So my guess is this isn't a spacemacs issue, something in org-mode itself.

@emacs18
Copy link
Contributor

emacs18 commented Dec 1, 2019

It appears that there is a potential problem when updating any elisp package.
This was recently discussed in emacs-devel list. I quote one of the emails below.

What emacs developers seem to need is specific examples of the problems.
If folks can provide step by step detail on how to reproduce the problems and
share that with emacs developers, then this problem might get resolved once and for all.
Otherwise we all have to work around this problem.

From: Stefan Kangas <stefan@marxist.se>
Subject: Re: org 9.2.6 and org 9.1.9
Newsgroups: gmane.emacs.orgmode, gmane.emacs.devel
To: Tim Cross <theophilusx@gmail.com>
Cc: Jean-Christophe Helary <jean.christophe.helary@traduction-libre.org>, Org-mode <emacs-orgmode@gnu.org>, Emacs developers <emacs-devel@gnu.org>
Date: Wed, 27 Nov 2019 11:11:40 +0100 (4 days, 4 hours, 50 minutes ago)

Tim Cross <theophilusx@gmail.com> writes:

> What is really needed to fix this problem is some mechanism which
> will ensure all org related definitions are somehow purged from the
> running instance before attempting to install and compile a new
> version.

That could be one way of going about it.  Other solutions have been
discussed in Bug#10125, for example here:

https://debbugs.gnu.org/cgi/bugreport.cgi?bug=10125#59

> But I don't think the issue is with package.el per se. You get the
> same problem if you try to install org-mode manually without
> package.el.
[...]
> Provided there is no org-mode functionality loaded when you install
> a later version with package.el, it works fine.

As far as I understand, the bug in package.el is that you can't always
successfully install a later version of a package after it has been
loaded.  In this case, Org-mode fails to install properly.

Best regards,
Stefan Kangas

@thanhvg
Copy link
Contributor

thanhvg commented Dec 11, 2019

For those who are on dev branch and encounter this bug can you try this work around:

Open any org file in Spacemacs (to make sure org-mode is fully loaded), do spc h p and search for org-plus-contrib (owner: spacemacs-org layer). Once you have found it:

  • F3 or
  • C-z choose Recompile

Restart Spacemace. Hope the problem is gone then. This is a convenient way to recompile a package instead of doing it manually on both command line and emacs.

@Zlopez
Copy link

Zlopez commented Dec 16, 2019

@thanhvg I tried it and here is the output:

  • F3 - macro not defined
  • C-z - does something, but not what expected

I was able to find recompile under SPC-c-r, but this just throws error:

-*- mode: compilation; default-directory: "~/.emacs.d/layers/+spacemacs/spacemacs-org/" -*-
Compilation started at Mon Dec 16 14:14:09

make -k 
/bin/bash: make: command not found

Compilation exited abnormally with code 127 at Mon Dec 16 14:14:09

@ambantis
Copy link

Using the current version (20191230), I get this problem both in osx and linux (arch linux). When I checkout the org-mode and use the 9.3.1 tag and compile, this error goes away (both in osx and linux).

@Jeel-Shah
Copy link

Hi all,

I encountered the same problem (Spacemacs Release 0.200.13.x).

  1. I ran find . -name *.elc -print0 | xargs -0 rm

It said that it didn't find any .elc files. But, I called spacemacs/recompile-elpa anyway. It successfully recompiled and the issue was resolved. I would suggest trying the second step independent of the result in the first.

@breadncup
Copy link

Unbelievable! This ticket has been a year, but it is still opened. :)

@emacs18
Copy link
Contributor

emacs18 commented Jan 22, 2020

@duianto mentioned #12829 which has more details on the problem which is that updating packages in emacs is not a reliable process especially for older emacs versions and especially for org mode.

I think this is a hard problem to solve. That I think is why emacs developers have not yet solved it.
However improvements have been made in emacs and in org mode so that the problem is less frequent in more modern versions of emacs and org-mode.

I would not expect spacemacs folks to solve this difficult problem which even emacs developers are having difficulty solving. The best bet is to use one of the many work arounds suggested by others. My own work around is to delete org-plus-contrib package (and others), then make sure that it is installed on startup before there is any possibility of loading any org mode related files.

@LambdaP
Copy link

LambdaP commented Feb 17, 2020

@thanhvg I tried it and here is the output:

* `F3` - macro not defined

* `C-z` - does something, but not what expected

I was able to find recompile under SPC-c-r, but this just throws error:

-*- mode: compilation; default-directory: "~/.emacs.d/layers/+spacemacs/spacemacs-org/" -*-
Compilation started at Mon Dec 16 14:14:09

make -k 
/bin/bash: make: command not found

Compilation exited abnormally with code 127 at Mon Dec 16 14:14:09

I am having the exact same problem. Did you find a way out of this error?

@thanhvg
Copy link
Contributor

thanhvg commented Feb 18, 2020

@LambdaP do you use helm or ivy? My solution is only available for helm :(

@LorenRiccie
Copy link

LorenRiccie commented Apr 21, 2020

Got the problem again with emacs 26.3 creating a footnote in an orgmode file.

cd ~/.emacs.d/elpa/
find org*/*.elc -print0 | xargs -0 rm

Then recompilation of the directory via Emacs fixed the error :)

@rafonseca
Copy link

on 0.200.13@26.3 (spacemacs),
M-x spacemacs/recompile-elpa
also works, at least for now.

@Zlopez
Copy link

Zlopez commented Jun 10, 2020

I hit the issue again today and solution from @LorenRiccie helped.

@clyton
Copy link

clyton commented Jun 23, 2020

I too faced the same issue. Deleting the .elc files in only the org directory find org*/*.elc -print0 | xargs -0 rm and recompiling does not solve the error. I also tried recompiling just the org-plus-contrib package and it still does not work. I had to delete all .elc files under elpa and then recompile. Finally it worked

@jkonecny12
Copy link

jkonecny12 commented Jul 7, 2020

Issue is still present. I hit it by updating packages from the main screen.

I had to remove all .elc files from elpa directory. It seems that there were no .elc files in the org* directories for some reason and recompilation did not compile them.

@Caffa
Copy link

Caffa commented Jul 24, 2020

I'm on mac, so what I did was
find . | grep "org*.elc"$ | while read -r line ; do rm -rf $line ;done
then recompile in spacemacs

@undefiened
Copy link

@thanhvg I tried it and here is the output:

* `F3` - macro not defined

* `C-z` - does something, but not what expected

I was able to find recompile under SPC-c-r, but this just throws error:

-*- mode: compilation; default-directory: "~/.emacs.d/layers/+spacemacs/spacemacs-org/" -*-
Compilation started at Mon Dec 16 14:14:09

make -k 
/bin/bash: make: command not found

Compilation exited abnormally with code 127 at Mon Dec 16 14:14:09

I am having the exact same problem. Did you find a way out of this error?

A bit too late response, but still leave it in case anyone needs it: I did not press Enter after searching for org-plus-contrib (so I stayed in helm or whatever it is), just pressed F3 and recompilation started.

@nickanderson
Copy link
Contributor

Deleting all the elc files in ~/.emacs.d/elpa/VERSION/develop restarting and running spacemacs/recompile-elpa was unsuccessful for me today.

@Prometheus77
Copy link

I was able to solve in Windows with the org-plus-contrib + F3 to recompile solution; however, a workaround is only a workaround. If we have definitely traced the issue to an org-mode bug, is there an open issue on org-mode's github?

@github-actions
Copy link

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Please let us know if this issue is still valid!

@github-actions github-actions bot added the stale marked as a stale issue/pr (usually by a bot) label Oct 17, 2021
@lebensterben lebensterben added Found work-around and removed stale marked as a stale issue/pr (usually by a bot) labels Jan 29, 2022
@lebensterben
Copy link
Collaborator

For future reference, please use the solution here.

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

No branches or pull requests