[Nix-dev] How to package Heroku Toolbelt?

Jonas Pfenniger (zimbatm) zimbatm at zimbatm.com
Mon Nov 18 12:17:32 CET 2013


What's the output of `gem env` if you unset the GEM_HOME that you have
exported ?
Normally you should have $HOME/.gem/ruby/1.9.1 in your gem paths and `gem
install --user-install your-gem` should place it there. You still have to
add $HOME/.gem/ruby/1.9.1/bin in your PATH.
Later versions of rubygems automatically place gems in the first writable
gem path. 1.9.1 is not the version of ruby but the version of the stdlib.

I'm super new to Nix so please correct me if I'm wrong. My understanding is
that you could as well manage your ruby dependencies using nix and the nix
gem. See:
https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/interpreters/ruby/generated.nix.
I don't have an exact howto but I believe you could generate another
.nix
expression with the dependencies that you want using that gem ?

Regarding readline, it seems that it's only compiled if a cursesSupport
flag is enabled :
https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/interpreters/ruby/ruby-19.nix#L5but
I don't know how to compile ruby with it or not. You could check by
running `find /nix/store/
m1mgqmkx23hyqr8sp1533x4mhcv6fpqf-ruby-1.9.3-p429/ -name readline.so`.
Usually it live be under lib/ruby/1.9.1/x86_64-linux.



On 18 November 2013 08:08, Alex Berg <chexxor at gmail.com> wrote:

> Thanks for the idea Jonas. I gave it a try, and I finally got it working.
> But, I encountered some problems on the way, so I want to ask here.
>
> I am using Ruby 1.9, which includes "Rubygems" out-of-the-box, I believe.
>
>     $ gem install heroku
>     ERROR:  While executing gem ... (Gem::FilePermissionError)
>             You don't have write permissions into the
> /nix/store/m1mgqmkx23hyqr8sp1533x4mhcv6fpqf-ruby-1.9.3-p429/lib/ruby/gems/1.9.1
> directory.
>
> We can't install stuff into a Nix Store, so I must install Gems into a
> directory which I own. I discovered I can override the default Gem location
> by setting the "GEM_HOME" environment variable, so I chose my "home"
> directory, which I own.
>
>     $ export GEM_HOME=/home/chexxor/.gemrepo
>     $ gem install heroku
>     # <No problem>
>     $ heroku
>     # <Nothing. The PATH doesn't point there. How should I manage the
> PATH?>
>     $  ~/.gemrepo/gems/heroku-3.0.1/bin/heroku
>     # <Same "readline" error as from my Nix-packaged Heroku>
>
> So, installing the "heroku" Gem produced the same result as installing the
> "heroku" Nix package. But, I found a way to fix the issue.
>
>     $ gem install rb-readline
>     $ heroku
>     # <Heroku command list - Success!>
>
> How is "rb-readline" Gem different from the "readline" package which is
> installed when Nix-packaged Ruby is installed? I read the docs, which say
> that "rb-readline" is a Ruby implementation of the "readline" package,
> which is written in C. The "rb-readline" package works easier across more
> platforms. (Is this a bug in the "Ruby" Nix package?)
>
> Some questions:
>
> 1) Where should NixOS users store Gems? I believe Gems are dependent on a
> specific Ruby version, so we should ensure each Ruby version gets its own
> set of Gems. No?
> 2) Does anybody else have this readline issue? Can we define this
> "rb-readline" Gem as a dependency of the Ruby Nix package?
>
>
>
>
>
>
> On Mon, Nov 18, 2013 at 6:59 AM, Jonas Pfenniger (zimbatm) <
> zimbatm at zimbatm.com> wrote:
>
>> Alternatively you could also just install the "heroku" and the "foreman"
>> gem for the same effect.
>> The toolbelt is really just a distribution of these gems with a bundled
>> ruby interpreter, it's principally meant for OSes with a broken package
>> management like OSX and Windows (they want to avoid support for
>> mis-configured ruby installs).
>>
>>
>> On 15 November 2013 07:24, Vladimír Čunát <vcunat at gmail.com> wrote:
>>
>>> On 11/15/2013 06:34 AM, Alex Berg wrote:
>>>
>>>> Now, another question. After I install the Heroku Toolbelt, the `heroku`
>>>> command is available on the command-line. But, I can't run it because I
>>>> haven't installed Ruby.
>>>>
>>>
>>> That's because of not patching the shebangs. You are right that it's run
>>> automatically, but you just need to add ruby to buildInputs, so it's found
>>> by the patcher. (I confused this, direct running of patchShebangs is only
>>> needed if the builders need to run scripts.)
>>>
>>> However, it still complains about some dependencies. I would just have
>>> to guess how this is best done, as I don't know ruby. You can try looking
>>> at other packages using it (git grep ruby), or hopefully someone with
>>> nix+ruby experience will help (e.g. I saw ToDo on wiki from Marc Weber <
>>> marco-oweber at gmx.de>).
>>>
>>>
>>> Good luck!
>>> Vlada
>>>
>>>
>>>
>>> _______________________________________________
>>> nix-dev mailing list
>>> nix-dev at lists.science.uu.nl
>>> http://lists.science.uu.nl/mailman/listinfo/nix-dev
>>>
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.science.uu.nl/pipermail/nix-dev/attachments/20131118/90466f5d/attachment.html 


More information about the nix-dev mailing list