Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change the fake mechanism to be compatible with bundler. #121

Merged
merged 1 commit into from
Jan 31, 2016

Conversation

larskanis
Copy link
Member

The previous fake mechanism worked by hooking onto the "require 'rbconfig'" call. This is problematic because bundler internally requires rbconfig, but doesn't work corretly in a faked environment. It then fails to load gems that are also part of the standard library, like json and rdoc. This results in issues like rake-compiler/rake-compiler-dock#8

The fake mechanism is now changed to hook onto the "require 'mkrb'" call, which is typically part of the extconf file, and it is where the faked platform values are actually needed. That way it is loaded after bundler/setup, so that the library paths are set according to the Gemfile.lock, to the native Linux libraries, before the fake environment is active.

Please note, that the build directory of a given gem needs to be cleared, in order to get updated fake files. So do a "rm tmp pkg -rf".

This patch is already in rake-compiler-dock-0.5.1. See commit rake-compiler/rake-compiler-dock@1e2fb4e

The previous fake mechanism worked by hooking onto the
"require 'rbconfig'" call.
This is problematic because bundler internally requires rbconfig, but doesn't
work corretly in a faked environment.
It then fails to load gems that are also part of the standard library, like
json and rdoc.
This results in issues like rake-compiler/rake-compiler-dock#8

The fake mechanism is now changed to hook onto the "require 'mkrb'" call,
which is typically part of the extconf file, and it is where the faked platform
values are actually needed.
That way it is loaded after bundler/setup, so that the library paths are
set according to the Gemfile.lock, to the native Linux libraries, before
the fake environment is active.

Please note, that the build directory of a given gem needs to be cleared,
in order to get updated fake files. So do a "rm tmp pkg -rf".
kou added a commit that referenced this pull request Jan 31, 2016
Change the fake mechanism to be compatible with bundler.

Patch by Lars Kanis. Thanks!!!
@kou kou merged commit dc569b2 into rake-compiler:master Jan 31, 2016
@kou
Copy link
Member

kou commented Jan 31, 2016

Thanks!

Should we release a new version?

@kou
Copy link
Member

kou commented Jan 31, 2016

This change breaks some existing tests. Could you confirm them?:

% rake
/usr/bin/ruby2.3 -S rspec ./spec/lib/rake/extensiontask_spec.rb ./spec/lib/rake/javaextensiontask_spec.rb
    ..................................................FF.....................*.***.......

Pending:
  Rake::JavaExtensionTask (defaults) (tasks) (one extension) compile should depend on 'compile:{platform}'
    # needs fixing
    # ./spec/lib/rake/javaextensiontask_spec.rb:103
  Rake::JavaExtensionTask (defaults) (tasks) (one extension) compile:extension_one should depend on 'compile:extension_one:{platform}'
    # needs fixing
    # ./spec/lib/rake/javaextensiontask_spec.rb:114
  Rake::JavaExtensionTask (defaults) (tasks) (one extension) lib/extension_one.jar should define as task
    # needs fixing
    # ./spec/lib/rake/javaextensiontask_spec.rb:121
  Rake::JavaExtensionTask (defaults) (tasks) (one extension) lib/extension_one.jar should depend on 'copy:extension_one:{platform}'
    # needs fixing
    # ./spec/lib/rake/javaextensiontask_spec.rb:126

Failures:

  1) Rake::ExtensionTask (tasks) (cross platform tasks) (cross for 'universal-unknown' platform) rbconfig should chain rbconfig tasks to Makefile generation
     Failure/Error: Rake::Task["tmp/universal-unknown/extension_one/#{@ruby_ver}/Makefile"].prerequisites.should include("tmp/universal-unknown/extension_one/#{@ruby_ver}/rbconfig.rb")
       expected ["tmp/universal-unknown/extension_one/2.3.0", "ext/extension_one/extconf.rb", "tmp/universal-unknown/extension_one/2.3.0/fake.rb", "tmp/universal-unknown/extension_one/2.3.0/mkmf.rb"] to include "tmp/universal-unknown/extension_one/2.3.0/rbconfig.rb"
       Diff:
       @@ -1,2 +1,5 @@
       -["tmp/universal-unknown/extension_one/2.3.0/rbconfig.rb"]
       +["tmp/universal-unknown/extension_one/2.3.0",
       + "ext/extension_one/extconf.rb",
       + "tmp/universal-unknown/extension_one/2.3.0/fake.rb",
       + "tmp/universal-unknown/extension_one/2.3.0/mkmf.rb"]
     # ./spec/lib/rake/extensiontask_spec.rb:433:in `block (6 levels) in <top (required)>'

  2) Rake::ExtensionTask (tasks) (cross platform tasks) (cross for 'universal-unknown' platform) rbconfig should take rbconfig from rake-compiler configuration
     Failure/Error: Rake::Task["tmp/universal-unknown/extension_one/#{@ruby_ver}/rbconfig.rb"].prerequisites.should include(@config_path)
       expected [] to include "/rubies/2.3.0/rbconfig.rb"
       Diff:
       @@ -1,2 +1,2 @@
       -["/rubies/2.3.0/rbconfig.rb"]
       +[]
     # ./spec/lib/rake/extensiontask_spec.rb:437:in `block (6 levels) in <top (required)>'

Finished in 0.06182 seconds
85 examples, 2 failures, 4 pending

Failed examples:

rspec ./spec/lib/rake/extensiontask_spec.rb:432 # Rake::ExtensionTask (tasks) (cross platform tasks) (cross for 'universal-unknown' platform) rbconfig should chain rbconfig tasks to Makefile generation
rspec ./spec/lib/rake/extensiontask_spec.rb:436 # Rake::ExtensionTask (tasks) (cross platform tasks) (cross for 'universal-unknown' platform) rbconfig should take rbconfig from rake-compiler configuration
rake aborted!
/usr/bin/ruby2.3 -S rspec ./spec/lib/rake/extensiontask_spec.rb ./spec/lib/rake/javaextensiontask_spec.rb failed
/var/lib/gems/2.3.0/gems/rspec-core-2.8.0/lib/rspec/core/rake_task.rb:137:in `block (2 levels) in initialize'
/var/lib/gems/2.3.0/gems/rspec-core-2.8.0/lib/rspec/core/rake_task.rb:127:in `block in initialize'
Tasks: TOP => default => spec
(See full trace by running task with --trace)

@larskanis
Copy link
Member Author

larskanis commented Jan 31, 2016 via email

@larskanis
Copy link
Member Author

I've adjusted the specs per commit af31388 and pushed it directly on master.

A new release version would be fine!

@kou
Copy link
Member

kou commented Mar 4, 2016

Sorry... I forgot to release a new version...
I've released 0.9.6 now.

@larskanis
Copy link
Member Author

larskanis commented Mar 4, 2016 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants