* How do I use wrap-ruby-program to make curl findable in a Ruby package?
@ 2024-02-05 9:39 Marek Paśnikowski
2024-02-05 20:35 ` Marek Paśnikowski
0 siblings, 1 reply; 5+ messages in thread
From: Marek Paśnikowski @ 2024-02-05 9:39 UTC (permalink / raw)
To: help-guix
[-- Attachment #1: Type: text/plain, Size: 1428 bytes --]
Dear All
I am having one problem with correctly packaging ruby-nano-bots[^1]. The Ruby
gem wants to load libcurl at runtime and is not able to find it without
setting the LD_LIBRARY_PATH to ~/.guix-profile/lib . This is the final
problem to solve, because after I performed ~guix install curl~ and exported
the above path adjustment, I am now able to use the application.
Armed with this tool, I started interviewing the Mistral AI on ways to perform
the path adjustment inside a package definition. Unfortunately, it started
hallucating, but not without making me discover a ~wrap-ruby-program~ function
in guix/build/ruby-build-system.scm (line 188).
I understand that I actually want to include a path other than $GUIX_PROFILE ,
but have absolutely no idea if there exists a standard path with package
inputs, or how it would interact with =wrap-ruby-program= . This is why I
will focus my question on usage of the $GUIX_PROFILE and then proceed to think
about the ultimately correct path.
Can I use the function in the body of the package definition, or does the
package definition go inside the wrapper? Could you provide an example how to
set the following? ~LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$GUIX_PROFILE/lib~ . The
function code is honestly completely unreadable to me at the moment.
Sincerely,
Marek Paśnikowski
[^1]: [[https://github.com/icebaker/ruby-nano-bots]]
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: How do I use wrap-ruby-program to make curl findable in a Ruby package?
2024-02-05 9:39 How do I use wrap-ruby-program to make curl findable in a Ruby package? Marek Paśnikowski
@ 2024-02-05 20:35 ` Marek Paśnikowski
2024-02-06 12:20 ` Carlo Zancanaro
0 siblings, 1 reply; 5+ messages in thread
From: Marek Paśnikowski @ 2024-02-05 20:35 UTC (permalink / raw)
To: help-guix
[-- Attachment #1: Type: text/plain, Size: 1111 bytes --]
05.02.2024 10:39:08 CET Marek Paśnikowski:
> Can I use the function in the body of the package definition, or does the
> package definition go inside the wrapper? Could you provide an example how
> to set the following? ~LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$GUIX_PROFILE/lib~
> . The function code is honestly completely unreadable to me at the moment.
After many hours of searching and thinking I found the following code works:
#+BEGIN_SRC scheme
(arguments
'(#:phases
(modify-phases
%standard-phases
(delete 'check)
(add-after
'wrap
'include-curl
(lambda* (#:key inputs outputs #:allow-other-keys)
(wrap-program
(search-input-file outputs "bin/nb")
`("LD_LIBRARY_PATH"
suffix
,(list
(dirname
(search-input-file inputs "lib/libcurl.so"))))))))
#+END_SRC
When I will have rested from this code adventure, I will make effort to
publish the entire package set I created to make this program work.
Sincerely,
Marek Paśnikowski
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: How do I use wrap-ruby-program to make curl findable in a Ruby package?
2024-02-05 20:35 ` Marek Paśnikowski
@ 2024-02-06 12:20 ` Carlo Zancanaro
2024-02-06 12:42 ` Marek Paśnikowski
0 siblings, 1 reply; 5+ messages in thread
From: Carlo Zancanaro @ 2024-02-06 12:20 UTC (permalink / raw)
To: Marek Paśnikowski; +Cc: help-guix
Hi Marek,
On Mon, Feb 05 2024, Marek Paśnikowski wrote:
> After many hours of searching and thinking I found the following code
> works:
I'm glad you got something working. Using wrap-program like this will
likely work, but with the downside that LD_LIBRARY_PATH will also be
inherited by any child processes. This might be fine for ruby-nano-bots,
but this has caused me serious compatibility problems in the past.
Usually, I prefer to store a reference to the precise library in the
store, rather than setting LD_LIBRARY_PATH. I'm not really sure how to
do that in your case, because I'm not familiar with ruby-nano-bots or
any of its dependencies.
Carlo
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: How do I use wrap-ruby-program to make curl findable in a Ruby package?
2024-02-06 12:20 ` Carlo Zancanaro
@ 2024-02-06 12:42 ` Marek Paśnikowski
2024-02-06 13:28 ` Carlo Zancanaro
0 siblings, 1 reply; 5+ messages in thread
From: Marek Paśnikowski @ 2024-02-06 12:42 UTC (permalink / raw)
To: help-guix
[-- Attachment #1: Type: text/plain, Size: 1241 bytes --]
06.02.2024 13:20:52 CET Carlo Zancanaro:
> On Mon, Feb 05 2024, Marek Paśnikowski wrote:
> > After many hours of searching and thinking I found the following code
>
> > works:
> I'm glad you got something working. Using wrap-program like this will
> likely work, but with the downside that LD_LIBRARY_PATH will also be
> inherited by any child processes. This might be fine for ruby-nano-bots,
> but this has caused me serious compatibility problems in the past.
If my logic is correct, this should be mitigated somewhat by placing the
needed library path at the end of the $LD_LIBRARY_PATH ? Which is why I opted
for the ~suffix~ argument in the ~wrap-program~ .
>
> Usually, I prefer to store a reference to the precise library in the
> store, rather than setting LD_LIBRARY_PATH. I'm not really sure how to
> do that in your case, because I'm not familiar with ruby-nano-bots or
> any of its dependencies.
I believe this exact behaviour is achieved by ~(search-input-file inputs "lib/
libcurl.so")~ . When I first attempted to build the ~wrap-program~ call I had
a nesting error which explicitly showed that "/gnu/store/hash-curl/lib" is of
unexpected type. Am I wrong?
Sincerely,
Marek Paśnikowski
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: How do I use wrap-ruby-program to make curl findable in a Ruby package?
2024-02-06 12:42 ` Marek Paśnikowski
@ 2024-02-06 13:28 ` Carlo Zancanaro
0 siblings, 0 replies; 5+ messages in thread
From: Carlo Zancanaro @ 2024-02-06 13:28 UTC (permalink / raw)
To: Marek Paśnikowski; +Cc: help-guix
Hi Marek,
On Tue, Feb 06 2024, Marek Paśnikowski wrote:
> 06.02.2024 13:20:52 CET Carlo Zancanaro:
>> I'm glad you got something working. Using wrap-program like this will
>> likely work, but with the downside that LD_LIBRARY_PATH will also be
>> inherited by any child processes. This might be fine for ruby-nano-bots,
>> but this has caused me serious compatibility problems in the past.
>
> If my logic is correct, this should be mitigated somewhat by placing the
> needed library path at the end of the $LD_LIBRARY_PATH ? Which is why I opted
> for the ~suffix~ argument in the ~wrap-program~ .
The problems I have had in the past was when spawning another program,
which doesn't want LD_LIBRARY_PATH set at all. Doing so caused
completely incorrect library versions to be loaded for child processes,
because the environment variable was inherited by all child processes.
I ended up having to modify the places where those child processes were
spawned to clear LD_LIBRARY_PATH before spawning.
>> Usually, I prefer to store a reference to the precise library in the
>> store, rather than setting LD_LIBRARY_PATH. I'm not really sure how to
>> do that in your case, because I'm not familiar with ruby-nano-bots or
>> any of its dependencies.
>
> I believe this exact behaviour is achieved by ~(search-input-file inputs "lib/
> libcurl.so")~ . When I first attempted to build the ~wrap-program~ call I had
> a nesting error which explicitly showed that "/gnu/store/hash-curl/lib" is of
> unexpected type. Am I wrong?
No, sorry. You are using a precise store reference in LD_LIBRARY_PATH,
that's fine. I was more saying as an alternative to LD_LIBRARY_PATH,
it's nicer to patch the program itself to load a specific library. That
is, patch ruby-nano-bots (or its relevant dependency) during the Guix
build so it's dlopening the specific library in the store.
Carlo
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-02-06 13:29 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-05 9:39 How do I use wrap-ruby-program to make curl findable in a Ruby package? Marek Paśnikowski
2024-02-05 20:35 ` Marek Paśnikowski
2024-02-06 12:20 ` Carlo Zancanaro
2024-02-06 12:42 ` Marek Paśnikowski
2024-02-06 13:28 ` Carlo Zancanaro
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.