nixpkgs/pkgs/development
Farid Zakaria 4af8bc084a
buildRubyGem: fix to support bundler cmds (#104977)
The way in which Nixpks builds Ruby gems means that certain operations
by bundler *will not work*, namely `bundle install --redownload`.

According to the source the _cache/_ directory should have been kept,
however it seems through revisions to the file it has been purged.

Here was the comment from the original commit that introduced
buildRubyGem:
```
  # Note:
  #   We really do need to keep the $out/${ruby.gemPath}/cache.
  #   This is very important in order for many parts of RubyGems/Bundler to not blow up.
  #   See https://github.com/bundler/bundler/issues/3327
```

Why is the _cache_ directory needed?

Bundler and RubyGems uses the cache as a source of truth.
When bundler executes `bundler install --redownload`, any gems it
discovers in the _GEM_PATH_ it assums must have their _.gem_ file
present in the cache (unaware it was installed from Nix).

Rather than downloading the gem from RubyGems the bundler code forcibly
re-installs the gem from the cache directory instead and **fails** if it
does not exist.

I've opened https://github.com/rubygems/rubygems/issues/4088 to see if
this failure should be soft and not so explicit; or fallback to fetching
the gem from scratch.

Without this change the following is the error:
```bash
> [nix-shell:~/code/nix/playground/jruby-bundler-rake]$ bundle install --force
[DEPRECATED] The `--force` option has been renamed to `--redownload`
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.jruby.ext.openssl.SecurityHelper (file:/nix/store/fis6nzrpw9pmcivr84qh5byfgm07qn10-jruby-9.2.13.0/lib/ruby/stdlib/jopenssl.jar) to field java.security.MessageDigest.provider
WARNING: Please consider reporting this to the maintainers of org.jruby.ext.openssl.SecurityHelper
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
Fetching gem metadata from https://rubygems.org/.
Using bundler 2.1.4
Installing hello-world 1.2.0
Bundler::GemNotFound: Could not find hello-world-1.2.0.gem for installation
An error occurred while installing hello-world (1.2.0), and Bundler
cannot continue.
Make sure that `gem install hello-world -v '1.2.0' --source
'https://rubygems.org/'` succeeds before bundling.
```

Wth the fix the following no woccurs:
```bash
[nix-shell:~/code/nix/playground/jruby-bundler-rake]$ bundle install --redownload
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.jruby.ext.openssl.SecurityHelper (file:/nix/store/69wjlj4yirp48rv1q03zxgd4xvf0150d-jruby-9.2.13.0/lib/ruby/stdlib/jopenssl.jar) to field java.security.MessageDigest.provider
WARNING: Please consider reporting this to the maintainers of org.jruby.ext.openssl.SecurityHelper
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
Fetching gem metadata from https://rubygems.org/.
Using bundler 2.1.4
Installing hello-world 1.2.0
Bundle complete! 1 Gemfile dependency, 2 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
```

```
[nix-shell:~/code/nix/playground/jruby-bundler-rake]$ ls -l /nix/store/cwl9n5073hqgpfhnw4wic13nrrgg9dn8-gem-env/lib/jruby/gems/2.5.0/cache/
total 8
lrwxrwxrwx 1 fmzakari primarygroup 102 Dec 31  1969 bundler-2.1.4.gem -> /nix/store/ifc8a0gsfkrhkv953rd4rz8bcspahi8y-bundler-2.1.4/lib/jruby/gems/2.5.0/cache/bundler-2.1.4.gem
lrwxrwxrwx 1 fmzakari primarygroup 110 Dec 31  1969 hello-world-1.2.0.gem -> /nix/store/xi9ln6n1mz2is5ppykjxqhhkpjq9zm6i-hello-world-1.2.0/lib/jruby/gems/2.5.0/cache/hello-world-1.2.0.gem
```

I have a minimal project that demonstrates this issue at https://github.com/fzakaria/jruby-bundler-nix-failure
2020-11-30 12:15:12 +01:00
..
androidndk-pkgs
arduino platformio: 5.0.2 -> 5.0.3 2020-11-24 14:36:19 +01:00
beam-modules Merge pull request #97984 from berbiche/erlang-mk-flags 2020-11-24 23:42:09 +01:00
bower-modules/generic
chez-modules
compilers Merge pull request #105314 from lopsided98/rustc-musl-target 2020-11-29 00:39:36 -05:00
coq-modules
dhall-modules dhallPackages.Prelude: 13.0.0 -> 19.0.0 2020-11-24 16:48:11 +01:00
dotnet-modules
em-modules/generic
go-modules buildGo{Package,Module}: set trimpath in GOFLAGS 2020-11-18 08:13:34 +10:00
go-packages buildGo{Package,Module}: set trimpath in GOFLAGS 2020-11-18 08:13:34 +10:00
guile-modules
haskell-modules git-annex: update sha256 hash for the new 8.20201127 version 2020-11-27 21:16:12 +01:00
idris-modules
interpreters python: Propagate packageOverrides to pythonForBuild 2020-11-30 11:12:59 +01:00
java-modules
libraries Merge pull request #105400 from arcz/libff 2020-11-30 09:08:26 +09:00
lisp-modules
lua-modules
misc utillinux: rename to util-linux 2020-11-24 12:42:06 -05:00
mobile utillinux: rename to util-linux 2020-11-24 12:42:06 -05:00
node-packages nodePackages: Regenerate 2020-11-28 01:54:26 +01:00
ocaml-modules ocamlPackages.batteries: 3.1.0 → 3.2.0 2020-11-30 08:13:28 +01:00
perl-modules
pharo
php-packages Merge pull request #105332 from r-ryantm/auto-update/php-xdebug 2020-11-29 13:28:54 +01:00
pure-modules
python-modules python37Packages.pytest-metadata: 1.10.0 -> 1.11.0 2020-11-29 20:07:21 -08:00
r-modules Merge pull request #101451 from moritzschaefer/fix-r-mirror-path 2020-11-27 01:58:30 +01:00
ruby-modules buildRubyGem: fix to support bundler cmds (#104977) 2020-11-30 12:15:12 +01:00
tools Merge pull request #104603 from siraben/errcheck-update 2020-11-30 11:36:33 +01:00
web postman: 7.34.0 -> 7.36.0 2020-11-29 08:58:53 +00:00