gcv / julia-snail

An Emacs development environment for Julia
GNU General Public License v3.0
235 stars 23 forks source link

Support installation in read-only locations (e.g. through nixpkgs) #117

Open fedeinthemix opened 1 year ago

fedeinthemix commented 1 year ago

The installation instructions should mention that the Julia package CSTParser should be installed for julia-snail to work. Otherwise it fails silently.

gcv commented 1 year ago

CSTParser should install automatically when julia-snail first starts. It installs in a dedicated environment to avoid polluting the user's Julia packages. If it didn't install, that's a bug and I'll need more details (like the relevant contents of the *Messages* buffer).

fedeinthemix commented 1 year ago

I'm on NixOS 22.11 and when I start the REPL in julia-snail I briefly see julia downloading something (probably the general registry) and then the buffer disappears. Nothing relevant is shown in the *Messages* buffer. I suspect that julia-snail is trying to put (write) the dedicated environment in a read-only place. (julia-snail is in a system read-only directory.).

gcv commented 1 year ago

Trying to write something to /nix explains the failure, but it’s not immediately obvious why Snail would do that. It should install packages to ~/.julia just like a manual Pkg.add call.

  1. Did you install Julia using the derivation in nixpkgs? And Snail is emacsPackages.julia-snail? Or do you use something custom?
  2. Does the Snail derivation contain a Manifest.toml file?
  3. When you get Snail started, what is the value of LOAD_PATH in the Julia REPL?
fedeinthemix commented 1 year ago
  1. I'm using julia-snail as follows
    ((pkgs.emacsPackagesFor emacs-gtk).emacsWithPackages
       (epkgs: with epkgs; [
       fbe-defaults
       julia-mode
       julia-snail
       ...
       ]))

    fbe_defaults is a system wide configuration that includes

        (use-package julia
          :hook
          (julia-mode . julia-snail-mode))
  2. There is no Manifest.toml file in the derivation, just Project.toml.
  3. I can't check the value of LOAD_PATH as the REPL terminates almost immediately.
gcv commented 1 year ago

Snail's own dependency installation process tries to write a Manifest.toml file into its own install location, which is in the Nix store. Snail stopped shipping a Manifest.toml file about 6 months ago to follow Julia best practices (https://github.com/gcv/julia-snail/issues/95#issuecomment-1126786733). Of course, that messes up Nix-style reproducibility.

I can think of two workarounds:

  1. julia-snail could have a custom derivation in nixpkgs (rather than a generic melpaDerivation), which ships a Manifest.toml with proper version pins. I'm not excited to have to maintain a downstream package.
  2. The Snail bootstrap process could detect that it lives in a read-only directory, and then try to hack around that (install itself in an environment in $TMPDIR). Also not appetizing.

This is why, even though I use Nix and like it a lot, I do not buy into using the Nix way to install Emacs packages.

fedeinthemix commented 1 year ago

Regarding option 2, a standard location for this kind of purposes is $XDG_CACHE_HOME, see https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html. This is used, among others, by the jedi emacs package.