Emacs & Anaconda. Linking problems

白昼怎懂夜的黑 提交于 2019-12-06 08:15:41

问题


I have a problem where:

  • In order to run Anaconda, I need to unset LD_LIBRARY_PATH
  • In order to run Emacs (as well as other programs), I need to set LD_LIBRARY_PATH

If I try to run Emacs while unsetting LD_LIBRARY_PATH I run into linking problems, e.g.

symbol lookup error: /usr/lib64/libpangocairo-1.0.so.0: undefined symbol:
cairo_ft_font_options_substitute

And I run into the same problem if I try to load gedit or other programs. Given this, I am currently unable to use Anaconda and Emacs in the same environment.

This prevents me from using Emacs packages such as emacs-jedi (a great package for editing and debugging Python code) which require a functioning Python environment (specifically emacs-jedi requires epc).

Any ideas on how to circumvent this problem? (Note: I don't have root access)

Update:

  • I have tried prepending $ANACONDA/lib to my current LD_LIBRARY_PATH, but this also results in the symbol look up errors that I described above.
  • I have also tried updating $PATH and $LD_LIBRARY_PATH on my .emacs file, by putting this at the top with no luck:

    (setenv "PATH" (concat "/home/josh/installs/conda/1.7.0/bin/:" (getenv "PATH")))
    (setenv "LD_LIBRARY_PATH" (concat "/home/josh/installs/conda/1.7.0/lib/:" (getenv "LD_LIBRARY_PATH")))
    
  • Here is the thread that explains in more detail the errors that I get : Linking problems with Anaconda when using LD_LIBRARY_PATH


回答1:


There are several ways to fix it, but probably this is the most easiest (untested).

(defadvice jedi:start-server (around my-jedi:start-server-ld-library-path-hack
                                     activate)
  "Unset LD_LIBRARY_PATH when starting Jedi server."
  (let ((process-environment (mapcar #'identity process-environment)))
    (setenv "LD_LIBRARY_PATH")          ; unset $LD_LIBRARY_PATH
    ad-do-it))

If this works, maybe it is better idea to have it in Jedi.el. I can imagine that sometimes it is useful to change LD_LIBRARY_PATH for project to project.

One of the other ways to fix it to run Jedi EPC server outside of Emacs (e.g., in terminal). This way, you can easily control any environment variables. For starter, see: http://tkf.github.io/emacs-jedi/latest/#jedi:toggle-debug-server




回答2:


Probably you don't need to unset LD_LIBRARY_PATH for running Anaconda, but changing it in such a way Anaconda libraries come first.

Have you tried to do LD_LIBRARY_PATH=.:$LD_LIBRARY_PATH? (not safe in genera, but it might help in this case)

What shell do you use? What error do you have if you run Anaconda without unsetting LD_LIBRARY_PATH? What is your value for LD_LIBRARY_PATH?

You can alias emacs to "LD_LIBRARY_PATH= emacs", so emacs with have the correct path, but most of your other binaries will be useless in that session.

Alternatively, you may alias anaconda binary to "LD_LIBRARY_PATH=. "




回答3:


Why don't you do something like this:

alias emacs="LD_LIBRARY_PATH='whatever' sh -c 'echo \$HOME'"
alias emacs="LD_LIBRARY_PATH='whatever' bash -c '/usr/bin/emacs \${@:0}'"

Maybe you have to change the /usr/bin/emacs path.

I derived it from what I've tried with this:

alias asdf="HOME=asf bash -c 'echo \$HOME \${@:0}'"


来源:https://stackoverflow.com/questions/19227478/emacs-anaconda-linking-problems

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!