From mboxrd@z Thu Jan 1 00:00:00 1970 From: Divan Santana Subject: Re: using guix for ruby development Date: Fri, 23 Feb 2018 15:42:08 +0200 Message-ID: <87tvu74yd7.fsf@santanas.co.za> References: <87a7wato8i.fsf@santanas.co.za> <877eretnuw.fsf@santanas.co.za> <87tvuel46m.fsf@cbaines.net> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:50573) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1epE6X-0001V4-Lb for help-guix@gnu.org; Fri, 23 Feb 2018 09:13:42 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1epE6S-0001fU-Io for help-guix@gnu.org; Fri, 23 Feb 2018 09:13:41 -0500 Received: from outmail149043.authsmtp.co.uk ([62.13.149.43]:62806) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1epE6S-0001eZ-65 for help-guix@gnu.org; Fri, 23 Feb 2018 09:13:36 -0500 In-reply-to: <87tvuel46m.fsf@cbaines.net> List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-guix-bounces+gcggh-help-guix=m.gmane.org@gnu.org Sender: "Help-Guix" To: Christopher Baines , help-guix@gnu.org Christopher Baines writes: > Divan Santana writes: > >> Divan Santana 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