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

Install tikz magic: need to set environment variable #885

Closed
memeplex opened this issue Jun 29, 2019 · 5 comments
Closed

Install tikz magic: need to set environment variable #885

memeplex opened this issue Jun 29, 2019 · 5 comments

Comments

@memeplex
Copy link

I'm trying to make the jupyter tikz magic work in my binder.

First I'm installing some deb packages:

cat apt.txt 
texlive-latex-extra
pdf2svg
imagemagick

Next I add this requirement:

git+git://github.com/mkrphys/ipython-tikzmagic.git

That's fine. The problem is the absurdly restrictive policy imagemagick sets by default since a few months. Because I'm unable to run sudo in postBuild, I have to change it for my user:

mkdir -p ~/.magick
sed 's@rights="none" pattern="PDF" />@rights="all" pattern="PDF" />@' /etc/ImageMagick-6/policy.xml > ~/.magick/policy.xml
export MAGICK_CONFIGURE_PATH="/app/.magick/:/etc/ImageMagick-6/"

But the variable MAGICK_CONFIGURE_PATH is not set in my jupyter session. I've seen some example repo in your site that sets the PATH environment variable like this. If that's not possible, should I write a ~/.profile or ~/.bashrc file?

@memeplex
Copy link
Author

Ok, I was able to set the environment using .profile, but it doesn't solve my problem because of ImageMagick/ImageMagick#1342. In brief, I need to change the policies under /etc. Is that possible? I can't run sudo at all in the postBuild script.

@betatim
Copy link
Member

betatim commented Jun 29, 2019

You can't run things as root and there are no plans to change this.

Setting environment variables when your session starts on binder is handled by a start file: https://repo2docker.readthedocs.io/en/latest/config_files.html#start-run-code-before-the-user-sessions-starts but from skimming the issue you linked it doesn't sound like it'll help you :-(

If you really absolutely need to sudo the way forward is (unfortunately) to create your own Dockerfile. https://mybinder.readthedocs.io/en/latest/tutorials/dockerfile.html#preparing-your-dockerfile has some hints on what needs to be in your Dockerfile for it to work. We also have https://github.com/binder-examples/minimal-dockerfile but this is really the minnimal working example (it doesn't even copy the contents of the repository into the image).

edit: can run -> can't run

@memeplex
Copy link
Author

You can run things as root and there are no plans to change this.

You meant "don't", didn't you?

I'm trying to get this working with graphicsmagick. This is not the first headache this paranoid imagemagick default policy has caused me.

@memeplex
Copy link
Author

For future reference: it works just fine using the imagemagick interface of graphicsmagick. This is all that's needed to get tikz working in pybinder:

  • apt.txt
texlive-latex-extra
pdf2svg
ghostscript
graphicsmagick-imagemagick-compat
  • requirements.txt
git+git://github.com/mkrphys/ipython-tikzmagic.git

@betatim
Copy link
Member

betatim commented Jun 30, 2019

You meant "don't", didn't you?

Ah yes, updated my original comment.

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

2 participants