idris-lang / Idris2

A purely functional programming language with first class types
https://idris-lang.org/
Other
2.52k stars 375 forks source link

Can't make directory. #1524

Closed Kesanov closed 2 years ago

Kesanov commented 3 years ago

test.ipkg:

package test

sourcedir = "src"
modules   = Main

src/Main.idr:

module Main

command:

>>> idris2  --install test.ipkg
Uncaught error: INTERNAL ERROR: Can't make directory test

OS: WSL

gallais commented 3 years ago

Does idris2 have the right to create the directory ~/.idris2/idris2-0.3.0/test?

Kesanov commented 3 years ago

How can I check that? Btw, I installed it with nix-env.

Kesanov commented 3 years ago

If I do sudo idris2 --instal test.ipkg I get sudo: idris2: command not found

fabianhjr commented 3 years ago

Hi @Josef-Vonasek, for clarification, did you install it from the packaged v0.3.0 version (nix-env -iA nixpkgs.idris2) or did you build from source and install the result? (nix-build -E "with import <nixpkgs> {}; (callPackage ./. {})" && nix-env -i result/)

I don't have Windows but could you do tree ~/.idris2/ -L 2 to check that directory?

Kesanov commented 3 years ago

I did nix-env -i idris2 and got it installed under /home/unix/.nix-profile/bin/idris2.

~/.idris2 doesn't exist. Adding ~/.idris2/idris2-0.3.0/test manually with mkdir has no effect.

fabianhjr commented 3 years ago

Hey, could you try using this nix packages? https://github.com/claymager/idris2-pkgs

Kesanov commented 3 years ago

All I want to do is run a simple hello world package with no external dependencies. I don't see how packager manager helps that.

fabianhjr commented 3 years ago

@Josef-Vonasek, the issue is that nix copied everything to a non-mutable store (this is as designed) so you cannot copy more stuff over the nix install of Idris2.

You could try to move around it in a hacky way (Copying the Nix Idris2 install to ~/.idris2 and setting the env IDRIS2_PREFIX to that location) however that would probably cause a bit more issues (since on an nix-env -u and a garbage collection the dependencies of the copied idris2 might get removed, nix-env -u would update the nix install but not your user install, etc)

The other option would be to make it from source, this is what I do on NixOS and should work better for you too. Clone this repo, nix-shell and follow the bootstraping instructions here, use the normal make install which will install idris2 in your home dir and remember to add the idris2 bin to your PATH. (I use a symbolic link from ~/.local/bin to ~/.idris2/bin/idris2 and have ~/.local/bin in my PATH)

claymager commented 3 years ago

@Josef-Vonasek Does running $ mkdir -p $(idris2 --libdir) fix your issue?

There is a disagreement between nix and idris2:

When installing with make, there's no issue, because the makefile handles that for us. Nix won't let us make a mutable folder at build time.

1300 would help, but the idris2 in nixpkgs is pinned to the last release, and there were a few packaging changes this spring that are not included yet.

Kesanov commented 3 years ago

Does running $ mkdir -p $(idris2 --libdir) fix your issue?

Nope. It creates a folder /nix/store/bqqj72s3i18w4synw9wz2sf9radz2zzq-idris2-0.3.0/idris2-0.3.0, but it doesn't affect the error.

claymager commented 3 years ago

Oops. Forgot I had IDRIS2_PREFIX set, sorry. Add that to your shell env, make the libdir, and it should work.


Order of precedence for libdir is

Build location is immutable, so obviously out. The nix package chooses not to set IDRIS2_PREFIX, but setting a default is trivial and the approach I'm taking in idris2-pkgs.

We still need to make sure idris properly handles the libdir not existing.