all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* using guix for ruby development
@ 2018-02-15 12:46 Divan Santana
  2018-02-15 12:54 ` Divan Santana
  0 siblings, 1 reply; 6+ messages in thread
From: Divan Santana @ 2018-02-15 12:46 UTC (permalink / raw)
  To: help-guix

Hi all,

So I'm *trying* to use guix on Parabola Linux to provide the rubies and
replace some other functionality of like chruby for instance.

I'm a bit of a noob with guix and even ruby, so it's a bit of a
challenge.

I've read through these nice notes[1] by Pjotr. The answers I'm looking
for, may well be in there but I might have missed it.

  [1]:
    - https://gitlab.com/pjotrp/guix-notes/blob/master/RUBY.org
    - https://gitlab.com/pjotrp/guix-notes/blob/master/RUBYGEMS-Nokogiri.org

I've also used the linked in script[2] which helps.

[2]: https://gitlab.com/pjotrp/guix-notes/blob/master/scripts/ruby-guix-env

Anyway the issue:

  $ gem env
  RubyGems Environment:
    - RUBYGEMS VERSION: 2.6.14
    - RUBY VERSION: 2.4.3 (2017-12-14 patchlevel 205) [x86_64-linux]
    - INSTALLATION DIRECTORY: /home/admin/.gem/sx7ih0vgp7q8zj7k58xjvnp3yghig0ll-ruby-2.4.3/2.4.0
    - USER INSTALLATION DIRECTORY: /home/admin/.gem/ruby/2.4.0
    - RUBY EXECUTABLE: /gnu/store/sx7ih0vgp7q8zj7k58xjvnp3yghig0ll-ruby-2.4.3/bin/ruby
    - EXECUTABLE DIRECTORY: /home/admin/.gem/sx7ih0vgp7q8zj7k58xjvnp3yghig0ll-ruby-2.4.3/2.4.0/bin
    - SPEC CACHE DIRECTORY: /home/admin/.gem/sx7ih0vgp7q8zj7k58xjvnp3yghig0ll-ruby-2.4.3/specs
    - SYSTEM CONFIGURATION DIRECTORY: /gnu/store/sx7ih0vgp7q8zj7k58xjvnp3yghig0ll-ruby-2.4.3/etc
    - RUBYGEMS PLATFORMS:
      - ruby
      - x86_64-linux
    - GEM PATHS:
       - /home/admin/.gem/sx7ih0vgp7q8zj7k58xjvnp3yghig0ll-ruby-2.4.3/2.4.0
       - /home/admin/.guix-profile/lib/ruby/vendor_ruby
       - /home/admin/.guix-profile/lib/ruby/gems/2.4.0/
    - GEM CONFIGURATION:
       - :update_sources => true
       - :verbose => true
       - :backtrace => false
       - :bulk_threshold => 1000
       - "gem" => "--no-rdoc"
    - REMOTE SOURCES:
       - https://rubygems.org/
    - SHELL PATH:
       - /home/admin/.gem/sx7ih0vgp7q8zj7k58xjvnp3yghig0ll-ruby-2.4.3/2.4.0/bin
       - /home/admin/src/ds-config/guile/scripts
       - /home/admin/src/ds-config/bin
       - /home/admin/.node_modules/node_modules/.bin
       - /home/admin/.guix-profile/bin
       - /home/admin/src/ds-config/guile/scripts
       - /home/admin/src/ds-config/bin
       - /home/admin/.node_modules/node_modules/.bin
       - /home/admin/.guix-profile/bin
       - /usr/local/sbin
       - /usr/local/bin
       - /usr/bin
       - /usr/lib/jvm/default/bin
       - /usr/bin/site_perl
       - /usr/bin/vendor_perl
       - /usr/bin/core_perl

So I'm in a ruby project. I type `bundle install` to install the gems.

It goes and fetches the missing gems and installs them in /home/admin/.gem/sx7ih0vgp7q8zj7k58xjvnp3yghig0ll-ruby-2.4.3/2.4.0/gems/

That's great. I fire up the project[3] with:

  [3]: https://gitlab.com/gitlab-com/gitlab-docs (using an older commit
  because ruby25 is not yet in guix repos.

  $ bundle exec nanoc live

  Captain! We’ve been hit!

  LoadError: liblzma.so.5: cannot open shared object file: No such file or directory - /home/admin/.gem/sx7ih0vgp7q8zj7k58xjvnp3yghig0ll-ruby-2.4.3/2.4.0/gems/nokogiri-1.7.2/lib/nokogiri/nokogiri.so

  $ ldd /home/admin/.gem/sx7ih0vgp7q8zj7k58xjvnp3yghig0ll-ruby-2.4.3/2.4.0/gems/nokogiri-1.7.2/lib/nokogiri/nokogiri.so
          linux-vdso.so.1 (0x00007ffff6b10000)
          libm.so.6 => /usr/lib/libm.so.6 (0x00007f469080f000)
          libdl.so.2 => /usr/lib/libdl.so.2 (0x00007f469060b000)
          liblzma.so.5 => /usr/lib/liblzma.so.5 (0x00007f46903e5000)
          libz.so.1 => /usr/lib/libz.so.1 (0x00007f46901ce000)
          libpthread.so.0 => /usr/lib/libpthread.so.0 (0x00007f468ffb0000)
          libcrypt.so.1 => /usr/lib/libcrypt.so.1 (0x00007f468fd78000)
          libc.so.6 => /usr/lib/libc.so.6 (0x00007f468f9c1000)
          /usr/lib64/ld-linux-x86-64.so.2 (0x00007f4690f97000)

Guessing the reason is because it seems to compile against the OS system
and not the "guix system". And that could cause problems?

Other gems also are like this.

  $ ldd /home/admin/.gem/sx7ih0vgp7q8zj7k58xjvnp3yghig0ll-ruby-2.4.3/2.4.0/gems/ffi-1.9.18/lib/ffi_c.so
          linux-vdso.so.1 (0x00007ffd1bdf1000)
          libffi.so.6 => /usr/lib/libffi.so.6 (0x00007f6af531e000)
          libpthread.so.0 => /usr/lib/libpthread.so.0 (0x00007f6af5100000)
          libdl.so.2 => /usr/lib/libdl.so.2 (0x00007f6af4efc000)
          libcrypt.so.1 => /usr/lib/libcrypt.so.1 (0x00007f6af4cc4000)
          libm.so.6 => /usr/lib/libm.so.6 (0x00007f6af4978000)
          libc.so.6 => /usr/lib/libc.so.6 (0x00007f6af45c1000)
          /usr/lib64/ld-linux-x86-64.so.2 (0x00007f6af574c000)

I could install ruby-nokogiri via guix but that provides 1.8 and I need
1.7. :(

Is there a simple way of getting these gems installed to use guix system
libs so things don't break?
--
Divan

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: using guix for ruby development
  2018-02-15 12:46 using guix for ruby development Divan Santana
@ 2018-02-15 12:54 ` Divan Santana
  2018-02-16 18:44   ` Marius Bakke
  2018-02-18 15:15   ` Christopher Baines
  0 siblings, 2 replies; 6+ messages in thread
From: Divan Santana @ 2018-02-15 12:54 UTC (permalink / raw)
  To: help-guix

Divan Santana <divan@santanas.co.za> writes:

> Hi all,
>
> So I'm *trying* to use guix on Parabola Linux to provide the rubies and
> replace some other functionality of like chruby for instance.
>
> I'm a bit of a noob with guix and even ruby, so it's a bit of a
> challenge.
>
> I've read through these nice notes[1] by Pjotr. The answers I'm looking
> for, may well be in there but I might have missed it.
>
>   [1]:
>     - https://gitlab.com/pjotrp/guix-notes/blob/master/RUBY.org
>     - https://gitlab.com/pjotrp/guix-notes/blob/master/RUBYGEMS-Nokogiri.org
>
> I've also used the linked in script[2] which helps.
>
> [2]: https://gitlab.com/pjotrp/guix-notes/blob/master/scripts/ruby-guix-env
>
> Anyway the issue:
>
>   $ gem env
>   RubyGems Environment:
>     - RUBYGEMS VERSION: 2.6.14
>     - RUBY VERSION: 2.4.3 (2017-12-14 patchlevel 205) [x86_64-linux]
>     - INSTALLATION DIRECTORY: /home/admin/.gem/sx7ih0vgp7q8zj7k58xjvnp3yghig0ll-ruby-2.4.3/2.4.0
>     - USER INSTALLATION DIRECTORY: /home/admin/.gem/ruby/2.4.0
>     - RUBY EXECUTABLE: /gnu/store/sx7ih0vgp7q8zj7k58xjvnp3yghig0ll-ruby-2.4.3/bin/ruby
>     - EXECUTABLE DIRECTORY: /home/admin/.gem/sx7ih0vgp7q8zj7k58xjvnp3yghig0ll-ruby-2.4.3/2.4.0/bin
>     - SPEC CACHE DIRECTORY: /home/admin/.gem/sx7ih0vgp7q8zj7k58xjvnp3yghig0ll-ruby-2.4.3/specs
>     - SYSTEM CONFIGURATION DIRECTORY: /gnu/store/sx7ih0vgp7q8zj7k58xjvnp3yghig0ll-ruby-2.4.3/etc
>     - RUBYGEMS PLATFORMS:
>       - ruby
>       - x86_64-linux
>     - GEM PATHS:
>        - /home/admin/.gem/sx7ih0vgp7q8zj7k58xjvnp3yghig0ll-ruby-2.4.3/2.4.0
>        - /home/admin/.guix-profile/lib/ruby/vendor_ruby
>        - /home/admin/.guix-profile/lib/ruby/gems/2.4.0/
>     - GEM CONFIGURATION:
>        - :update_sources => true
>        - :verbose => true
>        - :backtrace => false
>        - :bulk_threshold => 1000
>        - "gem" => "--no-rdoc"
>     - REMOTE SOURCES:
>        - https://rubygems.org/
>     - SHELL PATH:
>        - /home/admin/.gem/sx7ih0vgp7q8zj7k58xjvnp3yghig0ll-ruby-2.4.3/2.4.0/bin
>        - /home/admin/src/ds-config/guile/scripts
>        - /home/admin/src/ds-config/bin
>        - /home/admin/.node_modules/node_modules/.bin
>        - /home/admin/.guix-profile/bin
>        - /home/admin/src/ds-config/guile/scripts
>        - /home/admin/src/ds-config/bin
>        - /home/admin/.node_modules/node_modules/.bin
>        - /home/admin/.guix-profile/bin
>        - /usr/local/sbin
>        - /usr/local/bin
>        - /usr/bin
>        - /usr/lib/jvm/default/bin
>        - /usr/bin/site_perl
>        - /usr/bin/vendor_perl
>        - /usr/bin/core_perl
>
> So I'm in a ruby project. I type `bundle install` to install the gems.
>
> It goes and fetches the missing gems and installs them in /home/admin/.gem/sx7ih0vgp7q8zj7k58xjvnp3yghig0ll-ruby-2.4.3/2.4.0/gems/
>
> That's great. I fire up the project[3] with:
>
>   [3]: https://gitlab.com/gitlab-com/gitlab-docs (using an older commit
>   because ruby25 is not yet in guix repos.
>
>   $ bundle exec nanoc live
>
>   Captain! We’ve been hit!
>
>   LoadError: liblzma.so.5: cannot open shared object file: No such file or directory - /home/admin/.gem/sx7ih0vgp7q8zj7k58xjvnp3yghig0ll-ruby-2.4.3/2.4.0/gems/nokogiri-1.7.2/lib/nokogiri/nokogiri.so
>
>   $ ldd /home/admin/.gem/sx7ih0vgp7q8zj7k58xjvnp3yghig0ll-ruby-2.4.3/2.4.0/gems/nokogiri-1.7.2/lib/nokogiri/nokogiri.so
>           linux-vdso.so.1 (0x00007ffff6b10000)
>           libm.so.6 => /usr/lib/libm.so.6 (0x00007f469080f000)
>           libdl.so.2 => /usr/lib/libdl.so.2 (0x00007f469060b000)
>           liblzma.so.5 => /usr/lib/liblzma.so.5 (0x00007f46903e5000)
>           libz.so.1 => /usr/lib/libz.so.1 (0x00007f46901ce000)
>           libpthread.so.0 => /usr/lib/libpthread.so.0 (0x00007f468ffb0000)
>           libcrypt.so.1 => /usr/lib/libcrypt.so.1 (0x00007f468fd78000)
>           libc.so.6 => /usr/lib/libc.so.6 (0x00007f468f9c1000)
>           /usr/lib64/ld-linux-x86-64.so.2 (0x00007f4690f97000)
>
> Guessing the reason is because it seems to compile against the OS system
> and not the "guix system". And that could cause problems?
>
> Other gems also are like this.
>
>   $ ldd /home/admin/.gem/sx7ih0vgp7q8zj7k58xjvnp3yghig0ll-ruby-2.4.3/2.4.0/gems/ffi-1.9.18/lib/ffi_c.so
>           linux-vdso.so.1 (0x00007ffd1bdf1000)
>           libffi.so.6 => /usr/lib/libffi.so.6 (0x00007f6af531e000)
>           libpthread.so.0 => /usr/lib/libpthread.so.0 (0x00007f6af5100000)
>           libdl.so.2 => /usr/lib/libdl.so.2 (0x00007f6af4efc000)
>           libcrypt.so.1 => /usr/lib/libcrypt.so.1 (0x00007f6af4cc4000)
>           libm.so.6 => /usr/lib/libm.so.6 (0x00007f6af4978000)
>           libc.so.6 => /usr/lib/libc.so.6 (0x00007f6af45c1000)
>           /usr/lib64/ld-linux-x86-64.so.2 (0x00007f6af574c000)
>
> I could install ruby-nokogiri via guix but that provides 1.8 and I need
> 1.7. :(
>
> Is there a simple way of getting these gems installed to use guix system
> libs so things don't break?

So for this particular project I managed to get it working via changing
the Gemfile to up the version on nokogiri to 1.8 so I can use the
nokogiri from guix. Did the same with ffi which had similar issue.

That's not ideal as one may need a diff version or the gem may not be
packaged yet.

Any thoughts?
--
Divan

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: using guix for ruby development
  2018-02-15 12:54 ` Divan Santana
@ 2018-02-16 18:44   ` Marius Bakke
  2018-02-23 13:33     ` Divan Santana
  2018-02-18 15:15   ` Christopher Baines
  1 sibling, 1 reply; 6+ messages in thread
From: Marius Bakke @ 2018-02-16 18:44 UTC (permalink / raw)
  To: Divan Santana, help-guix


[-- Attachment #1.1: Type: text/plain, Size: 5749 bytes --]

Divan Santana <divan@santanas.co.za> writes:

> Divan Santana <divan@santanas.co.za> writes:
>
>> Hi all,
>>
>> So I'm *trying* to use guix on Parabola Linux to provide the rubies and
>> replace some other functionality of like chruby for instance.
>>
>> I'm a bit of a noob with guix and even ruby, so it's a bit of a
>> challenge.
>>
>> I've read through these nice notes[1] by Pjotr. The answers I'm looking
>> for, may well be in there but I might have missed it.
>>
>>   [1]:
>>     - https://gitlab.com/pjotrp/guix-notes/blob/master/RUBY.org
>>     - https://gitlab.com/pjotrp/guix-notes/blob/master/RUBYGEMS-Nokogiri.org
>>
>> I've also used the linked in script[2] which helps.
>>
>> [2]: https://gitlab.com/pjotrp/guix-notes/blob/master/scripts/ruby-guix-env
>>
>> Anyway the issue:
>>
>>   $ gem env
>>   RubyGems Environment:
>>     - RUBYGEMS VERSION: 2.6.14
>>     - RUBY VERSION: 2.4.3 (2017-12-14 patchlevel 205) [x86_64-linux]
>>     - INSTALLATION DIRECTORY: /home/admin/.gem/sx7ih0vgp7q8zj7k58xjvnp3yghig0ll-ruby-2.4.3/2.4.0
>>     - USER INSTALLATION DIRECTORY: /home/admin/.gem/ruby/2.4.0
>>     - RUBY EXECUTABLE: /gnu/store/sx7ih0vgp7q8zj7k58xjvnp3yghig0ll-ruby-2.4.3/bin/ruby
>>     - EXECUTABLE DIRECTORY: /home/admin/.gem/sx7ih0vgp7q8zj7k58xjvnp3yghig0ll-ruby-2.4.3/2.4.0/bin
>>     - SPEC CACHE DIRECTORY: /home/admin/.gem/sx7ih0vgp7q8zj7k58xjvnp3yghig0ll-ruby-2.4.3/specs
>>     - SYSTEM CONFIGURATION DIRECTORY: /gnu/store/sx7ih0vgp7q8zj7k58xjvnp3yghig0ll-ruby-2.4.3/etc
>>     - RUBYGEMS PLATFORMS:
>>       - ruby
>>       - x86_64-linux
>>     - GEM PATHS:
>>        - /home/admin/.gem/sx7ih0vgp7q8zj7k58xjvnp3yghig0ll-ruby-2.4.3/2.4.0
>>        - /home/admin/.guix-profile/lib/ruby/vendor_ruby
>>        - /home/admin/.guix-profile/lib/ruby/gems/2.4.0/
>>     - GEM CONFIGURATION:
>>        - :update_sources => true
>>        - :verbose => true
>>        - :backtrace => false
>>        - :bulk_threshold => 1000
>>        - "gem" => "--no-rdoc"
>>     - REMOTE SOURCES:
>>        - https://rubygems.org/
>>     - SHELL PATH:
>>        - /home/admin/.gem/sx7ih0vgp7q8zj7k58xjvnp3yghig0ll-ruby-2.4.3/2.4.0/bin
>>        - /home/admin/src/ds-config/guile/scripts
>>        - /home/admin/src/ds-config/bin
>>        - /home/admin/.node_modules/node_modules/.bin
>>        - /home/admin/.guix-profile/bin
>>        - /home/admin/src/ds-config/guile/scripts
>>        - /home/admin/src/ds-config/bin
>>        - /home/admin/.node_modules/node_modules/.bin
>>        - /home/admin/.guix-profile/bin
>>        - /usr/local/sbin
>>        - /usr/local/bin
>>        - /usr/bin
>>        - /usr/lib/jvm/default/bin
>>        - /usr/bin/site_perl
>>        - /usr/bin/vendor_perl
>>        - /usr/bin/core_perl
>>
>> So I'm in a ruby project. I type `bundle install` to install the gems.
>>
>> It goes and fetches the missing gems and installs them in /home/admin/.gem/sx7ih0vgp7q8zj7k58xjvnp3yghig0ll-ruby-2.4.3/2.4.0/gems/
>>
>> That's great. I fire up the project[3] with:
>>
>>   [3]: https://gitlab.com/gitlab-com/gitlab-docs (using an older commit
>>   because ruby25 is not yet in guix repos.
>>
>>   $ bundle exec nanoc live
>>
>>   Captain! We’ve been hit!
>>
>>   LoadError: liblzma.so.5: cannot open shared object file: No such file or directory - /home/admin/.gem/sx7ih0vgp7q8zj7k58xjvnp3yghig0ll-ruby-2.4.3/2.4.0/gems/nokogiri-1.7.2/lib/nokogiri/nokogiri.so
>>
>>   $ ldd /home/admin/.gem/sx7ih0vgp7q8zj7k58xjvnp3yghig0ll-ruby-2.4.3/2.4.0/gems/nokogiri-1.7.2/lib/nokogiri/nokogiri.so
>>           linux-vdso.so.1 (0x00007ffff6b10000)
>>           libm.so.6 => /usr/lib/libm.so.6 (0x00007f469080f000)
>>           libdl.so.2 => /usr/lib/libdl.so.2 (0x00007f469060b000)
>>           liblzma.so.5 => /usr/lib/liblzma.so.5 (0x00007f46903e5000)
>>           libz.so.1 => /usr/lib/libz.so.1 (0x00007f46901ce000)
>>           libpthread.so.0 => /usr/lib/libpthread.so.0 (0x00007f468ffb0000)
>>           libcrypt.so.1 => /usr/lib/libcrypt.so.1 (0x00007f468fd78000)
>>           libc.so.6 => /usr/lib/libc.so.6 (0x00007f468f9c1000)
>>           /usr/lib64/ld-linux-x86-64.so.2 (0x00007f4690f97000)
>>
>> Guessing the reason is because it seems to compile against the OS system
>> and not the "guix system". And that could cause problems?
>>
>> Other gems also are like this.
>>
>>   $ ldd /home/admin/.gem/sx7ih0vgp7q8zj7k58xjvnp3yghig0ll-ruby-2.4.3/2.4.0/gems/ffi-1.9.18/lib/ffi_c.so
>>           linux-vdso.so.1 (0x00007ffd1bdf1000)
>>           libffi.so.6 => /usr/lib/libffi.so.6 (0x00007f6af531e000)
>>           libpthread.so.0 => /usr/lib/libpthread.so.0 (0x00007f6af5100000)
>>           libdl.so.2 => /usr/lib/libdl.so.2 (0x00007f6af4efc000)
>>           libcrypt.so.1 => /usr/lib/libcrypt.so.1 (0x00007f6af4cc4000)
>>           libm.so.6 => /usr/lib/libm.so.6 (0x00007f6af4978000)
>>           libc.so.6 => /usr/lib/libc.so.6 (0x00007f6af45c1000)
>>           /usr/lib64/ld-linux-x86-64.so.2 (0x00007f6af574c000)
>>
>> I could install ruby-nokogiri via guix but that provides 1.8 and I need
>> 1.7. :(
>>
>> Is there a simple way of getting these gems installed to use guix system
>> libs so things don't break?
>
> So for this particular project I managed to get it working via changing
> the Gemfile to up the version on nokogiri to 1.8 so I can use the
> nokogiri from guix. Did the same with ffi which had similar issue.
>
> That's not ideal as one may need a diff version or the gem may not be
> packaged yet.
>
> Any thoughts?

Mixing Guix packages with other package managers can be difficult.  In
this situation I would write a "Guixfile" and use that instead of
Bundler.


[-- Attachment #1.2: Guixfile.scm --]
[-- Type: text/plain, Size: 911 bytes --]

(use-modules (guix build-system ruby)
	     ((guix licenses) #:prefix license:)
	     (guix download)
	     (guix packages)
	     (gnu packages ruby))

(define-public ruby-nokogiri-1.7
  (package
    (inherit ruby-nokogiri)
    (version "1.7.0")
    (source (origin
	      (method url-fetch)
	      (uri (rubygems-uri "nokogiri" version))
	      (sha256
	       (base32
		"1qx2adp6gdnaipvv0nshiq2hgnra44c8j5vkjjfm73sr9wbdmbk3"))))))

(define-public gitlab-docs
  (package
    (name "gitlab-docs")
    (version "master")
    (source (dirname (current-filename)))
    (build-system ruby-build-system)
    (propagated-inputs
     `(("ruby-nokogiri" ,ruby-nokogiri-1.7)
       ("ruby-redcarpet" ,ruby-redcarpet)))
    (home-page "https://gitlab.com/gitlab-com/gitlab-docs")
    (synopsis "GitLab documentation")
    (description "Documentation for the GitLab git server")
    (license license:expat)))

gitlab-docs

[-- Attachment #1.3: Type: text/plain, Size: 232 bytes --]


And then start the environment with `guix environment -l Guixfile.scm`.

I see the Gemfile requires some gems that are not available in Guix yet,
so I would attempt to write package definitions for those as well.

Hope this helps!

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: using guix for ruby development
  2018-02-15 12:54 ` Divan Santana
  2018-02-16 18:44   ` Marius Bakke
@ 2018-02-18 15:15   ` Christopher Baines
  2018-02-23 13:42     ` Divan Santana
  1 sibling, 1 reply; 6+ messages in thread
From: Christopher Baines @ 2018-02-18 15:15 UTC (permalink / raw)
  To: Divan Santana; +Cc: help-guix

[-- Attachment #1: Type: text/plain, Size: 1554 bytes --]


Divan Santana <divan@santanas.co.za> writes:

> Divan Santana <divan@santanas.co.za> writes:
>> Is there a simple way of getting these gems installed to use guix system
>> libs so things don't break?
>
> So for this particular project I managed to get it working via changing
> the Gemfile to up the version on nokogiri to 1.8 so I can use the
> nokogiri from guix. Did the same with ffi which had similar issue.
>
> That's not ideal as one may need a diff version or the gem may not be
> packaged yet.
>
> Any thoughts?

I've been putting up with using bundler and rubygems for a little while
now, although I'd still like to switch to only using Guix packages one
day.

My current workflow when I use Bundler/Rubygems is to using Guix to
provide the right version of Ruby, and then Direnv to setup the
environment.

This would be a .envrc file that would work for nokogiri.

  use guix --ad-hoc ruby@2.3 gcc-toolchain pkg-config libxml2 libxslt

  layout ruby


To use this, you'd need to create a file called .envrc with the above 2
lines, and then run direnv allow to allow it to be loaded. After it
loads, assuming you're using bundler, you should run gem install
bundler. This works better than using the Guix package for bundler, as
that uses a specific Ruby version, which might not be the one you've
specified in the environment. After bundler is installed, run bundle
install. When things break, which they will, I just rm -rf .direnv, and
start again.

So, in summary.

  # create the .envrc file
  direnv allow
  gem install bundler
  bundle

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 962 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: using guix for ruby development
  2018-02-16 18:44   ` Marius Bakke
@ 2018-02-23 13:33     ` Divan Santana
  0 siblings, 0 replies; 6+ messages in thread
From: Divan Santana @ 2018-02-23 13:33 UTC (permalink / raw)
  To: Marius Bakke, help-guix


Marius Bakke <mbakke@fastmail.com> writes:

> Divan Santana <divan@santanas.co.za> writes:
>
>> Divan Santana <divan@santanas.co.za> writes:
>>
>>> Hi all,
>>>
>>> So I'm *trying* to use guix on Parabola Linux to provide the rubies and
>>> replace some other functionality of like chruby for instance.
>>>
>>> I'm a bit of a noob with guix and even ruby, so it's a bit of a
>>> challenge.
>>>
>>> I've read through these nice notes[1] by Pjotr. The answers I'm looking
>>> for, may well be in there but I might have missed it.
>>>
>>>   [1]:
>>>     - https://gitlab.com/pjotrp/guix-notes/blob/master/RUBY.org
>>>     - https://gitlab.com/pjotrp/guix-notes/blob/master/RUBYGEMS-Nokogiri.org
>>>
>>> I've also used the linked in script[2] which helps.
>>>
>>> [2]: https://gitlab.com/pjotrp/guix-notes/blob/master/scripts/ruby-guix-env
>>>
>>> Anyway the issue:
>>>
>>>   $ gem env
>>>   RubyGems Environment:
>>>     - RUBYGEMS VERSION: 2.6.14
>>>     - RUBY VERSION: 2.4.3 (2017-12-14 patchlevel 205) [x86_64-linux]
>>>     - INSTALLATION DIRECTORY: /home/admin/.gem/sx7ih0vgp7q8zj7k58xjvnp3yghig0ll-ruby-2.4.3/2.4.0
>>>     - USER INSTALLATION DIRECTORY: /home/admin/.gem/ruby/2.4.0
>>>     - RUBY EXECUTABLE: /gnu/store/sx7ih0vgp7q8zj7k58xjvnp3yghig0ll-ruby-2.4.3/bin/ruby
>>>     - EXECUTABLE DIRECTORY: /home/admin/.gem/sx7ih0vgp7q8zj7k58xjvnp3yghig0ll-ruby-2.4.3/2.4.0/bin
>>>     - SPEC CACHE DIRECTORY: /home/admin/.gem/sx7ih0vgp7q8zj7k58xjvnp3yghig0ll-ruby-2.4.3/specs
>>>     - SYSTEM CONFIGURATION DIRECTORY: /gnu/store/sx7ih0vgp7q8zj7k58xjvnp3yghig0ll-ruby-2.4.3/etc
>>>     - RUBYGEMS PLATFORMS:
>>>       - ruby
>>>       - x86_64-linux
>>>     - GEM PATHS:
>>>        - /home/admin/.gem/sx7ih0vgp7q8zj7k58xjvnp3yghig0ll-ruby-2.4.3/2.4.0
>>>        - /home/admin/.guix-profile/lib/ruby/vendor_ruby
>>>        - /home/admin/.guix-profile/lib/ruby/gems/2.4.0/
>>>     - GEM CONFIGURATION:
>>>        - :update_sources => true
>>>        - :verbose => true
>>>        - :backtrace => false
>>>        - :bulk_threshold => 1000
>>>        - "gem" => "--no-rdoc"
>>>     - REMOTE SOURCES:
>>>        - https://rubygems.org/
>>>     - SHELL PATH:
>>>        - /home/admin/.gem/sx7ih0vgp7q8zj7k58xjvnp3yghig0ll-ruby-2.4.3/2.4.0/bin
>>>        - /home/admin/src/ds-config/guile/scripts
>>>        - /home/admin/src/ds-config/bin
>>>        - /home/admin/.node_modules/node_modules/.bin
>>>        - /home/admin/.guix-profile/bin
>>>        - /home/admin/src/ds-config/guile/scripts
>>>        - /home/admin/src/ds-config/bin
>>>        - /home/admin/.node_modules/node_modules/.bin
>>>        - /home/admin/.guix-profile/bin
>>>        - /usr/local/sbin
>>>        - /usr/local/bin
>>>        - /usr/bin
>>>        - /usr/lib/jvm/default/bin
>>>        - /usr/bin/site_perl
>>>        - /usr/bin/vendor_perl
>>>        - /usr/bin/core_perl
>>>
>>> So I'm in a ruby project. I type `bundle install` to install the gems.
>>>
>>> It goes and fetches the missing gems and installs them in /home/admin/.gem/sx7ih0vgp7q8zj7k58xjvnp3yghig0ll-ruby-2.4.3/2.4.0/gems/
>>>
>>> That's great. I fire up the project[3] with:
>>>
>>>   [3]: https://gitlab.com/gitlab-com/gitlab-docs (using an older commit
>>>   because ruby25 is not yet in guix repos.
>>>
>>>   $ bundle exec nanoc live
>>>
>>>   Captain! We’ve been hit!
>>>
>>>   LoadError: liblzma.so.5: cannot open shared object file: No such file or directory - /home/admin/.gem/sx7ih0vgp7q8zj7k58xjvnp3yghig0ll-ruby-2.4.3/2.4.0/gems/nokogiri-1.7.2/lib/nokogiri/nokogiri.so
>>>
>>>   $ ldd /home/admin/.gem/sx7ih0vgp7q8zj7k58xjvnp3yghig0ll-ruby-2.4.3/2.4.0/gems/nokogiri-1.7.2/lib/nokogiri/nokogiri.so
>>>           linux-vdso.so.1 (0x00007ffff6b10000)
>>>           libm.so.6 => /usr/lib/libm.so.6 (0x00007f469080f000)
>>>           libdl.so.2 => /usr/lib/libdl.so.2 (0x00007f469060b000)
>>>           liblzma.so.5 => /usr/lib/liblzma.so.5 (0x00007f46903e5000)
>>>           libz.so.1 => /usr/lib/libz.so.1 (0x00007f46901ce000)
>>>           libpthread.so.0 => /usr/lib/libpthread.so.0 (0x00007f468ffb0000)
>>>           libcrypt.so.1 => /usr/lib/libcrypt.so.1 (0x00007f468fd78000)
>>>           libc.so.6 => /usr/lib/libc.so.6 (0x00007f468f9c1000)
>>>           /usr/lib64/ld-linux-x86-64.so.2 (0x00007f4690f97000)
>>>
>>> Guessing the reason is because it seems to compile against the OS system
>>> and not the "guix system". And that could cause problems?
>>>
>>> Other gems also are like this.
>>>
>>>   $ ldd /home/admin/.gem/sx7ih0vgp7q8zj7k58xjvnp3yghig0ll-ruby-2.4.3/2.4.0/gems/ffi-1.9.18/lib/ffi_c.so
>>>           linux-vdso.so.1 (0x00007ffd1bdf1000)
>>>           libffi.so.6 => /usr/lib/libffi.so.6 (0x00007f6af531e000)
>>>           libpthread.so.0 => /usr/lib/libpthread.so.0 (0x00007f6af5100000)
>>>           libdl.so.2 => /usr/lib/libdl.so.2 (0x00007f6af4efc000)
>>>           libcrypt.so.1 => /usr/lib/libcrypt.so.1 (0x00007f6af4cc4000)
>>>           libm.so.6 => /usr/lib/libm.so.6 (0x00007f6af4978000)
>>>           libc.so.6 => /usr/lib/libc.so.6 (0x00007f6af45c1000)
>>>           /usr/lib64/ld-linux-x86-64.so.2 (0x00007f6af574c000)
>>>
>>> I could install ruby-nokogiri via guix but that provides 1.8 and I need
>>> 1.7. :(
>>>
>>> Is there a simple way of getting these gems installed to use guix system
>>> libs so things don't break?
>>
>> So for this particular project I managed to get it working via changing
>> the Gemfile to up the version on nokogiri to 1.8 so I can use the
>> nokogiri from guix. Did the same with ffi which had similar issue.
>>
>> That's not ideal as one may need a diff version or the gem may not be
>> packaged yet.
>>
>> Any thoughts?
>
> Mixing Guix packages with other package managers can be difficult.  In
> this situation I would write a "Guixfile" and use that instead of
> Bundler.
>
> (use-modules (guix build-system ruby)
> 	     ((guix licenses) #:prefix license:)
> 	     (guix download)
> 	     (guix packages)
> 	     (gnu packages ruby))
>
> (define-public ruby-nokogiri-1.7
>   (package
>     (inherit ruby-nokogiri)
>     (version "1.7.0")
>     (source (origin
> 	      (method url-fetch)
> 	      (uri (rubygems-uri "nokogiri" version))
> 	      (sha256
> 	       (base32
> 		"1qx2adp6gdnaipvv0nshiq2hgnra44c8j5vkjjfm73sr9wbdmbk3"))))))
>
> (define-public gitlab-docs
>   (package
>     (name "gitlab-docs")
>     (version "master")
>     (source (dirname (current-filename)))
>     (build-system ruby-build-system)
>     (propagated-inputs
>      `(("ruby-nokogiri" ,ruby-nokogiri-1.7)
>        ("ruby-redcarpet" ,ruby-redcarpet)))
>     (home-page "https://gitlab.com/gitlab-com/gitlab-docs")
>     (synopsis "GitLab documentation")
>     (description "Documentation for the GitLab git server")
>     (license license:expat)))
>
> gitlab-docs
>
> And then start the environment with `guix environment -l Guixfile.scm`.
>
> I see the Gemfile requires some gems that are not available in Guix yet,
> so I would attempt to write package definitions for those as well.
>
> Hope this helps!

Thanks for this reply Marius.

Ideally one would do it this way and submit the packages applicable
back. When I get more familiar with things will do this.

For now I'm going to go with Christopher's method using direnv as that
is a quick win for now.
--
Divan

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: using guix for ruby development
  2018-02-18 15:15   ` Christopher Baines
@ 2018-02-23 13:42     ` Divan Santana
  0 siblings, 0 replies; 6+ messages in thread
From: Divan Santana @ 2018-02-23 13:42 UTC (permalink / raw)
  To: Christopher Baines, help-guix

Christopher Baines <mail@cbaines.net> writes:

> Divan Santana <divan@santanas.co.za> writes:
>
>> Divan Santana <divan@santanas.co.za> writes:
>>> Is there a simple way of getting these gems installed to use guix system
>>> libs so things don't break?
>>
>> So for this particular project I managed to get it working via changing
>> the Gemfile to up the version on nokogiri to 1.8 so I can use the
>> nokogiri from guix. Did the same with ffi which had similar issue.
>>
>> That's not ideal as one may need a diff version or the gem may not be
>> packaged yet.
>>
>> Any thoughts?
>
> I've been putting up with using bundler and rubygems for a little while
> now, although I'd still like to switch to only using Guix packages one
> day.

Yes that would be ideal. One day.


> My current workflow when I use Bundler/Rubygems is to using Guix to
> provide the right version of Ruby, and then Direnv to setup the
> environment.
>
> This would be a .envrc file that would work for nokogiri.
>
>   use guix --ad-hoc ruby@2.3 gcc-toolchain pkg-config libxml2 libxslt
>
>   layout ruby
>
>
> To use this, you'd need to create a file called .envrc with the above 2
> lines, and then run direnv allow to allow it to be loaded. After it
> loads, assuming you're using bundler, you should run gem install
> bundler. This works better than using the Guix package for bundler, as
> that uses a specific Ruby version, which might not be the one you've
> specified in the environment. After bundler is installed, run bundle
> install. When things break, which they will, I just rm -rf .direnv, and
> start again.
>
> So, in summary.
>
>   # create the .envrc file
>   direnv allow
>   gem install bundler
>   bundle

This is really awesome and saved the day for me. It works well! I read
up a bit on the above because wasn't that familiar with some of the
direnv magic above.

  use guix --ad-hoc ruby@2.4.3 gcc-toolchain pkg-config libxml2 libxslt
  layout ruby

Thanks a lot! This setup also works nicely with emacs-direnv.

However with an old puppet 3 project using ruby 2.1.10 setup using the below I get these weird
errors. Any idea?

  $ cd ~/src/fnb/puppet-main
  direnv: loading .envrc
  direnv: using guix --ad-hoc ruby@2.1.10 gcc-toolchain pkg-config libxml2 libxslt
  direnv: export +BUNDLE_BIN +CPLUS_INCLUDE_PATH +C_INCLUDE_PATH +GEM_HOME +LIBRARY_PATH +PKG_CONFIG_PATH ~GEM_PATH ~PATH
  ~/src/fnb/puppet-main
  $ cat .envrc
  use guix --ad-hoc ruby@2.1.10 gcc-toolchain pkg-config libxml2 libxslt
  layout ruby

$ which ruby
/gnu/store/izam4vc9zp4q4wzrfm77pix5nscc4d48-profile/bin/ruby
15:36 admin@laptop 0 29602 ~/src/fnb/puppet-main
$ which gem
/gnu/store/izam4vc9zp4q4wzrfm77pix5nscc4d48-profile/bin/gem
15:36 admin@laptop 0 34372 ~/src/fnb/puppet-main
$ which bundle
/home/admin/src/fnb/puppet-main/.direnv/bin/bundle
15:37 admin@laptop 0 39143 ~/src/fnb/puppet-main
$ ruby -v
ruby 2.1.10p492 (2016-04-01 revision 54464) [x86_64-linux]
15:37 admin@laptop 0 48688 ~/src/fnb/puppet-main
$ which irb
/gnu/store/izam4vc9zp4q4wzrfm77pix5nscc4d48-profile/bin/irb
15:37 admin@laptop 0 53463 ~/src/fnb/puppet-main
$ irb
/gnu/store/k7ipxfl30xazwp940kmvp1wx44gx854c-ruby-2.1.10/lib/ruby/2.1.0/fileutils.rb:250:in `mkdir': Permission denied @ dir_s_mkdir - /home/admin/.guix-profile/lib/ruby/vendor_ruby/extensions/x86_64-linux/2.1.0-static (Errno::EACCES)
	from /gnu/store/k7ipxfl30xazwp940kmvp1wx44gx854c-ruby-2.1.10/lib/ruby/2.1.0/fileutils.rb:250:in `fu_mkdir'
	from /gnu/store/k7ipxfl30xazwp940kmvp1wx44gx854c-ruby-2.1.10/lib/ruby/2.1.0/fileutils.rb:224:in `block (2 levels) in mkdir_p'

Was getting similar issues when running bundle there.
--
Divan

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-02-23 14:13 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-15 12:46 using guix for ruby development Divan Santana
2018-02-15 12:54 ` Divan Santana
2018-02-16 18:44   ` Marius Bakke
2018-02-23 13:33     ` Divan Santana
2018-02-18 15:15   ` Christopher Baines
2018-02-23 13:42     ` Divan Santana

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.