[Nix-dev] How to package Heroku Toolbelt?

Alex Berg chexxor at gmail.com
Tue Nov 19 03:44:49 CET 2013


Yes "--user-install" option[1] will install Gems into my home directory.
(Related: Bundler can also do this, with the "--path" option. [2]) But,
should storing gems in Home directory be the default behavior for Ruby on
NixOS? If so, we should configure this when installing Ruby or Rubygems. We
I see two options for this configuration: 1) Set GEM_HOME in load script
for shell, such as `.bashrc`, and 2) Create `.gemrc` file [3] and put
"gem-install: --user-install"in it.

I'll try to reinstall Ruby with the "cursesSupport" option and then update
you.

Here's my `gem env` info for you. Note that, after I set the GEM_HOME
environment variable, the priority of the Nix Store path was lowered, to
become:
       - $GEM_HOME
       - /home/chexxor/.gem/ruby/1.9.1
       -
/nix/store/m1mgqmkx23hyqr8sp1533x4mhcv6fpqf-ruby-1.9.3-p429/lib/ruby/gems/1.9.1


    $ GEM_HOME
    $ gem env
    RubyGems Environment:
      - RUBYGEMS VERSION: 1.8.17
      - RUBY VERSION: 1.9.3 (2013-05-15 patchlevel 429) [x86_64-linux]
      - INSTALLATION DIRECTORY:
/nix/store/m1mgqmkx23hyqr8sp1533x4mhcv6fpqf-ruby-1.9.3-p429/lib/ruby/gems/1.9.1
      - RUBYGEMS PREFIX:
/nix/store/b2f6h37xaqx8nvnl9sib3hgwp3r7f91h-rubygems-1.8.17
      - RUBY EXECUTABLE:
/nix/store/m1mgqmkx23hyqr8sp1533x4mhcv6fpqf-ruby-1.9.3-p429/bin/ruby
      - EXECUTABLE DIRECTORY:
/nix/store/m1mgqmkx23hyqr8sp1533x4mhcv6fpqf-ruby-1.9.3-p429/bin
      - RUBYGEMS PLATFORMS:
        - ruby
        - x86_64-linux
      - GEM PATHS:
         -
/nix/store/m1mgqmkx23hyqr8sp1533x4mhcv6fpqf-ruby-1.9.3-p429/lib/ruby/gems/1.9.1
         - /home/chexxor/.gem/ruby/1.9.1
      - GEM CONFIGURATION:
         - :update_sources => true
         - :verbose => true
         - :benchmark => false
         - :backtrace => false
         - :bulk_threshold => 1000
      - REMOTE SOURCES:
         - http://rubygems.org/


[1] http://guides.rubygems.org/command-reference/#gem_install
[2] http://bundler.io/v1.5/man/bundle-install.1.html
[3] http://guides.rubygems.org/command-reference/#gem_environment



On Mon, Nov 18, 2013 at 7:17 PM, Jonas Pfenniger (zimbatm) <
zimbatm at zimbatm.com> wrote:

> 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/20131119/1856a524/attachment.html 


More information about the nix-dev mailing list