gfngfn / SATySFi

A statically-typed, functional typesetting system
GNU Lesser General Public License v3.0
1.16k stars 83 forks source link

lib-satysfi is copied to unexpected directory when `opam install satysfi` #38

Closed nekketsuuu closed 4 years ago

nekketsuuu commented 6 years ago

Problem

It seems that opam install satysfi doesn't copy lib-satysfi to an appropriate place.

# After `opam install satysfi`...
SATySFi/tests$ make
satysfi list.satyh math.satyh head.satyh first.saty -o output.pdf
 ---- ---- ---- ----
  target file: 'output.pdf'
! [Error] package file not found: dist/hash/default-font.satysfi-hash
Makefile:4: recipe for target 'all' failed
make: *** [all] Error 1

Reason

This problem is related to a breaking change requested by #34. This PR changes the default location of the library to /usr/local/share/satysfi, but OPAM copies it under $HOME/.opam/4.06.0/share/satysfi because PREFIX=%prefix% while running opam install satysfi.

And, we shouldn't copy libraries under /usr/local/share while opam install, because the OPAM manual says:

(the installation commands) should only write to subdirectories of prefix, without altering the source directory itself.

In fact, copying to /usr/local/share requires sudo on Ubuntu.

Proposal

This problem will occur if non-default $PREFIX is set. How about making a config file which has all library path? I'll make a PR of this.

No, this proposal is the same as using ~/.satysfi. This causes a problem for Homebrew. Some other solution is needed (for example, using an environment variable like $LD_LIBRARY_PATH?).

Workaround

To newcomers: you can fix this issue temporarily by cp -R "$(opam config var prefix)/share/satysfi" "${HOME}/.satysfi".

Environment

omasanori commented 6 years ago

How about just making SATySFi $PREFIX-friendly? (At least setup_root_dirs will need some changes.) Maybe I am missing the point, though... PATH-like environment variable would be helpful anyway.

nekketsuuu commented 6 years ago

Survey: TeX uses multiple TEXMF.

References (in Japanese):

nekketsuuu commented 6 years ago

@omasanori What do you think about the method to remember $PREFIX?

omasanori commented 6 years ago

I am unsure but embedding $PREFIX into the source code in compile-time or using relative path would work, I guess.

objmagic commented 6 years ago

we shouldn't copy libraries under /usr/local/share

agree. We cannot assume every user has access to /usr/local

nyuichi commented 6 years ago

Yes, root_dirs is now hard-coded and is not configurable. I was aware, when I wrote that patch, that that may cause some problems, but could not find a neat way to tell opam to modify the source code and embed installation directory strings (e.g. /usr/local or ~/.opam/4.06.0/). (Is there?)

One possible workaround is to get opam installation directory at run time and append it to satysfi_root_dirs with less priority than ~/.satysfi. Thoughts?

nekketsuuu commented 6 years ago

@nyuichi Thanks for your comment! I almost agree with you. I also thought of getting the OPAM prefix at run time by running opam config var prefix, however I noticed that the same problem will occur if other $PREFIX is set at compile time. So I'm seeking more general solution.

objmagic commented 6 years ago

I can make a large clean up in https://github.com/gfngfn/SATySFi/issues/21 to address many issues including this one later when I have time. But before this I'd like to have font dependency issue resolved

nyuichi commented 6 years ago

@nekketsuuu

Right. That's not a fix but just a workaround, though I think it should work fine for most users. Meanwhile, I await @objmagic's fix, leaving this issue as it is.

omasanori commented 6 years ago

@objmagic, please consider free alternatives I listed too if you work on the font issue. IMHO, using Latin Modern and/or TeX Gyre for Latin scripts and IPAex for Japanese scripts is a lightweight solution.

(Note that Latin Modern and some of TeX Gyre fonts already have corresponding OpenType Math fonts, so they will get harmonized results without much investigation after we get configurable math font feature.)

nekketsuuu commented 6 years ago

@objmagic additional note for the font issue https://twitter.com/bd_gfngfn/status/964779203869556737

objmagic commented 6 years ago

Thanks. We can wait @gfngfn to fix font issue #13 #17 (since I don't know much about font) and I can fix build issue later (#21, #40)

nyuichi commented 6 years ago

@objmagic

Are you still working on this? If you don't have time, I can write a patch instead.

equal-l2 commented 5 years ago

Has the problem solved?

omasanori commented 5 years ago

Not yet. We still need to execute cp -R "$(opam config var prefix)/share/satysfi" "${HOME}/.satysfi" as a workaround after installation. https://github.com/gfngfn/SATySFi/pull/109 addresses this, but it has not been reviewed yet.

nekketsuuu commented 5 years ago

@gfngfn How's #109 going? I think it's great to resolve this issue for easy installation of SATySFi.

na4zagin3 commented 5 years ago

FYI, for workaround, I made a tool https://github.com/na4zagin3/satyrographos which copies the directories under $(opam config var prefix)/share/satysfi/* to $HOME/.satysfi/dist with merging.

na4zagin3 commented 4 years ago

@nekketsuuu do you mind to close this PR as the lib-satysfi is not installed under the OPAM registory now?

nekketsuuu commented 4 years ago

@na4zagin3 Which commits or pull requests do you think of as that change?

na4zagin3 commented 4 years ago

@nekketsuuu https://github.com/gfngfn/SATySFi/commit/3c1bd3c652c60dcde6eb8f1ed619c4fd981ca81f must be it.

na4zagin3 commented 4 years ago

If https://github.com/gfngfn/SATySFi/pull/149 is merged, the dist library will be installed into OPAM registry again, fyi.

nekketsuuu commented 4 years ago

Ah, I remember that. Personally I feel that does not resolve the core of this problem best, but this issue is fixed as you said.

I'm closing this issue, but feel free to reopen this or report an related issue if needed.

na4zagin3 commented 4 years ago

Ah, I missed this PR actually includes a proposal to use environment variables.. I'd update the title and the description..