Open shuhaowu opened 4 years ago
I'm having a very similar problem. My use case is that I want to set up a development environment using nix-shell
to work on development of a Ruby gem. Most Ruby gems make use of a Gemfile
containing a call to gemspec
which (by default) looks for a *.gemspec
file in the project root directory.
I can successfully create a Gemfile.lock
& gemset.nix
containing the dependencies specified in the gemspec using nix-shell -p bundix --run 'bundix -l'
. However, when I then run nix-shell --pure
and try to make use of the bundled gems, I see an error:
$ irb
irb(main):001:0> require 'bundler/setup'
[!] There was an error parsing `Gemfile`: There are no gemspecs at /nix/store/bl4d9v4gfm80l15kfzivgvjzs9y0s2gh-gemfile-and-lockfile. Bundler cannot continue.
# from /nix/store/bl4d9v4gfm80l15kfzivgvjzs9y0s2gh-gemfile-and-lockfile/Gemfile:3
# -------------------------------------------
#
> gemspec
#
# -------------------------------------------
Relevant documentation references:
I'd be happy to work on a fix for this, but I don't really know where to start. Any pointers would be welcome!
This other issue (https://github.com/nix-community/bundix/issues/76) looks closely related.
For posterity, I encountered this error when trying to contribute to a third-party library. Doing some additional Google searches led me to these chat logs:
[15:41] <manveru> joko: https://github.com/asciidoctor/asciidoctor-reveal.js/blob/master/asciidoctor-revealjs.gemspec#L32-L45 those should be in the Gemfile
[15:41] <manveru> and replace the `gemspec` call with them
[15:42] <manveru> i got a bundix v3 in the works that will fix that... but it's pretty low prio atm :|
This confirms that the workaround of moving the gemspec
dependencies into the Gemfile
is the official solution.
I don't want to propose a change to the upstream library just because bundix
doesn't work with gemspecs, and while I can just make the edit locally and not include it in my PR, it'd be nice to see support for gemspecs in bundix
.
If a gem is created with
gemspec
within theGemfile
and with rake, then rake doesn't work as it is trying to find the gemspec in /nix/store as opposed to the current directory in nix-shell. This problem has been discussed in IRC in the past, but I don't see an issue for it?To reproduce
Gemfile
:bundix -l
andbundix -i
to generate theGemfile.lock
,gemset.nix
, andshell.nix
nix-shell --run "rake"
and see the following error:To work around
Do not use
gemspec
and hard code the dependencies inGemfile