Subject: [bug#72925] [PATCH v3] adding jpm package

From: Omar Bassam <[email-masked]>
Date: Wed, 2 Oct 2024 23:27:00 +0300

On Wed, 2 Oct 2024 at 23:14, Suhail Singh <[email-masked]> wrote:

> Omar Bassam <[email-masked]> writes:
>
> >> > This is expected as the jpm install command is meant to install janet
> >> > packages globally which would be impure.
> >>
> >> It would help for this to be noted in some manner.  Be it in the
> >> description or as comments in the package description.
> >
> > I don't think this needs to be said because all package managers
> installed
> > via guix have this issue.
>
> For me, someone familiar with Guix, but unfamiliar with Janet and JPM
> defaults, it wasn't obvious that I needed to add "-l" to the invocation.
>
> I don't believe such a message is necessary, but it would be helpful to
> some (those individuals who aren't familiar with both JPM and Guix).
>

This is where jgart suggestion would be really helpful. I am personally
working on a project
https://lisp-spectrum.org/ where I try to document all the struggles that I
had with the Lisp ecosystem
and try to make it more accessible to new users. (Any contributions are
welcomed of course).

>
> > Also, there is no one way to solve this because jpm gives you the freedom
> > to install packages on a user level
> > or on a project only level.
>
> The fact that JPM doesn't install packages at a user level by default
> was not something I knew previously.
>
> >> > To install janet packages to your local project directory, you need to
> >> add
> >> > the "-l" flag as follows:
> >> > jpm install -l sh
> >>
> >> Does this work for you (for jpm installed via guix)?  If so, could you
> >> please confirm the set of dependencies you have installed in the guix
> >> profile for the above to work?  If not, could you provide an example
> >> invocation that I could test out which would allow me to install a janet
> >> dependency in a local directory?
> >
> > Do you still get the same error?
>
> No, a different one.
>
> > Yes, this does work for me without any other dependencies. I am using
> guix
> > on ubuntu with guix shell.
>
> I am running guix-shell (--pure) with the following dependencies
> installed:
> - janet
> - gcc-toolchain gcc-toolchain:static
> - openssl
> - git
> - jpm
> - bash coreutils
> - curl nss-certs
>
> With the above, when running "jpm --local install sh" I observe the
> following error:
>
> #+begin_example
>   error: ( "cc"
>     "-std=c99"
>
> "-I/gnu/store/rdlvs1p09brkk961lj3vncifb4xlsmm5-janet-1.36.0/include/janet"
>     "-I/tmp/review-72925/jpm_tree/lib"
>     "-O2"
>     "-o"
>     "build/_jmod_posix_spawn.so"
>     "build/posix-spawn.o"
>     "-shared"
>     "-pthread"): No such file or directory
>   error: build fail
>     in pdag
> [/gnu/store/ffmis4y6rld42biqx5lq4nvsjp0bqiq6-jpm-1.1.0/lib/janet/jpm/dagbuild.janet]
> (tail call) on line 79, column 23
>     in with-dyns
> [/gnu/store/ffmis4y6rld42biqx5lq4nvsjp0bqiq6-jpm-1.1.0/lib/janet/jpm/pm.janet]
> on line 236, column 9
>     in defer
> [/gnu/store/ffmis4y6rld42biqx5lq4nvsjp0bqiq6-jpm-1.1.0/lib/janet/jpm/pm.janet]
> on line 221, column 5
>     in bundle-install
> [/gnu/store/ffmis4y6rld42biqx5lq4nvsjp0bqiq6-jpm-1.1.0/lib/janet/jpm/pm.janet]
> on line 219, column 3
>     in with-dyns
> [/gnu/store/ffmis4y6rld42biqx5lq4nvsjp0bqiq6-jpm-1.1.0/lib/janet/jpm/pm.janet]
> on line 234, column 13
>     in defer
> [/gnu/store/ffmis4y6rld42biqx5lq4nvsjp0bqiq6-jpm-1.1.0/lib/janet/jpm/pm.janet]
> on line 221, column 5
>     in bundle-install
> [/gnu/store/ffmis4y6rld42biqx5lq4nvsjp0bqiq6-jpm-1.1.0/lib/janet/jpm/pm.janet]
> on line 219, column 3
>     in install
> [/gnu/store/ffmis4y6rld42biqx5lq4nvsjp0bqiq6-jpm-1.1.0/lib/janet/jpm/commands.janet]
> (tail call) on line 190, column 20
>     in run-main [boot.janet] on line 4432, column 16
>     in cli-main [boot.janet] on line 4613, column 17
> #+end_example
>
> When running "jpm --cc=gcc --local install sh" I get the same error.
>
> I was finally able to get it to succeed by having cc symlink to gcc and
> adding the directory containing the symlink to PATH.  So I believe that
> the package definition you've submitted is correct.  However, I'm
> wondering what (if anything) needs to be done about the issue I
> encountered.
>
> Specifically, it's unclear why passing "-cc=gcc" didn't work (nor did
> setting "CC=gcc", but perhaps JPM ignores the latter?).  Is this an
> upstream bug?  Were my expectations misplaced?  Should the JPM package
> in Guix provide "cc" as well?
>

No, this is not really a Janet or JPM issue but rather the fact that you
are overriding the gcc compiler with a symlinked binary
instead of the absolute path. I faced this issue as well with
LD_LIBRARY_PATH where you have to use "readlink" to point it
to the absolute path of the "lib" folder in your guix profile.

> --
> Suhail