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

Error executing elm-install from elm_install gem #4732

Closed
RobertFischer opened this issue Aug 2, 2017 · 5 comments
Closed

Error executing elm-install from elm_install gem #4732

RobertFischer opened this issue Aug 2, 2017 · 5 comments

Comments

@RobertFischer
Copy link

Referenced here: https://github.com/gdotdesign/elm-github-install/issues/32

Environment

  • jruby-9.1.12.0 installed via rbenv
  • Linux megapadd 4.4.0-87-generic #110-Ubuntu SMP Tue Jul 18 12:55:35 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
  • Installed elm-install 1.1.1.
  • Minimal elm-package.json:
$ cat elm-package.json 
{
    "version": "1.0.0",
    "summary": "helpful summary of your project, less than 80 characters",
    "repository": "https://github.com/user/project.git",
    "license": "BSD3",
    "source-directories": [
        "."
    ],
    "exposed-modules": [],
    "dependencies": {
        "elm-lang/core": "5.1.1 <= v < 6.0.0"
    },
    "elm-version": "0.18.0 <= v < 0.19.0"
}

Expected Behavior

  • In the directory with elm-package.json, you should be able to run elm-install and it should install cleanly.

Actual Behavior

  • Getting an warning about a deprecated constants.
  • Getting an error about constraint types being wrong.
$ elm-install 
/home/robert/.rbenv/versions/jruby-9.1.12.0/lib/ruby/gems/shared/gems/commander-4.4.3/lib/commander/user_interaction.rb:334: warning: constant ::JavaPackageModuleTemplate is deprecated
error: Contract violation for return value:
        Expected: [Solve::Constraint],
        Actual: [#<Solve::Constraint < 6.0.0>, #<Solve::Constraint >= 5.1.1>]
        Value guarded in: ElmInstall::Utils::transform_constraint
        With Contract: String => Array
        At: /home/robert/.rbenv/versions/jruby-9.1.12.0/lib/ruby/gems/shared/gems/elm_install-1.1.1/lib/elm_install/utils.rb:23 . Use --trace to view backtrace
  • Here is the same error but with the trace:
/home/robert/.rbenv/versions/jruby-9.1.12.0/lib/ruby/gems/shared/gems/commander-4.4.3/lib/commander/user_interaction.rb:334: warning: constant ::JavaPackageModuleTemplate is deprecated
ReturnContractError: Contract violation for return value:
        Expected: [Solve::Constraint],
        Actual: [#<Solve::Constraint < 6.0.0>, #<Solve::Constraint >= 5.1.1>]
        Value guarded in: ElmInstall::Utils::transform_constraint
        With Contract: String => Array
        At: /home/robert/.rbenv/versions/jruby-9.1.12.0/lib/ruby/gems/shared/gems/elm_install-1.1.1/lib/elm_install/utils.rb:23 
              block in Contract at /home/robert/.rbenv/versions/jruby-9.1.12.0/lib/ruby/gems/shared/gems/contracts-0.16.0/lib/contracts.rb:46
               failure_callback at /home/robert/.rbenv/versions/jruby-9.1.12.0/lib/ruby/gems/shared/gems/contracts-0.16.0/lib/contracts.rb:155
                      call_with at /home/robert/.rbenv/versions/jruby-9.1.12.0/lib/ruby/gems/shared/gems/contracts-0.16.0/lib/contracts/call_with.rb:86
  block in transform_constraint at /home/robert/.rbenv/versions/jruby-9.1.12.0/lib/ruby/gems/shared/gems/contracts-0.16.0/lib/contracts/method_handler.rb:138
              block in identify at /home/robert/.rbenv/versions/jruby-9.1.12.0/lib/ruby/gems/shared/gems/elm_install-1.1.1/lib/elm_install/identifier.rb:61
                           each at org/jruby/RubyHash.java:1343
                            map at org/jruby/RubyEnumerable.java:830
                       identify at /home/robert/.rbenv/versions/jruby-9.1.12.0/lib/ruby/gems/shared/gems/elm_install-1.1.1/lib/elm_install/identifier.rb:60
                        send_to at /home/robert/.rbenv/versions/jruby-9.1.12.0/lib/ruby/gems/shared/gems/contracts-0.16.0/lib/contracts/method_reference.rb:43
                      call_with at /home/robert/.rbenv/versions/jruby-9.1.12.0/lib/ruby/gems/shared/gems/contracts-0.16.0/lib/contracts/call_with.rb:79
              block in identify at /home/robert/.rbenv/versions/jruby-9.1.12.0/lib/ruby/gems/shared/gems/contracts-0.16.0/lib/contracts/method_handler.rb:138
                     initialize at /home/robert/.rbenv/versions/jruby-9.1.12.0/lib/ruby/gems/shared/gems/elm_install-1.1.1/lib/elm_install/identifier.rb:20
                        send_to at /home/robert/.rbenv/versions/jruby-9.1.12.0/lib/ruby/gems/shared/gems/contracts-0.16.0/lib/contracts/method_reference.rb:43
                      call_with at /home/robert/.rbenv/versions/jruby-9.1.12.0/lib/ruby/gems/shared/gems/contracts-0.16.0/lib/contracts/call_with.rb:79
            block in initialize at /home/robert/.rbenv/versions/jruby-9.1.12.0/lib/ruby/gems/shared/gems/contracts-0.16.0/lib/contracts/method_handler.rb:138
                     initialize at /home/robert/.rbenv/versions/jruby-9.1.12.0/lib/ruby/gems/shared/gems/elm_install-1.1.1/lib/elm_install/installer.rb:12
                        send_to at /home/robert/.rbenv/versions/jruby-9.1.12.0/lib/ruby/gems/shared/gems/contracts-0.16.0/lib/contracts/method_reference.rb:43
                      call_with at /home/robert/.rbenv/versions/jruby-9.1.12.0/lib/ruby/gems/shared/gems/contracts-0.16.0/lib/contracts/call_with.rb:79
            block in initialize at /home/robert/.rbenv/versions/jruby-9.1.12.0/lib/ruby/gems/shared/gems/contracts-0.16.0/lib/contracts/method_handler.rb:138
                        install at /home/robert/.rbenv/versions/jruby-9.1.12.0/lib/ruby/gems/shared/gems/elm_install-1.1.1/lib/elm_install.rb:40
                block in (root) at /home/robert/.rbenv/versions/jruby-9.1.12.0/lib/ruby/gems/shared/gems/elm_install-1.1.1/bin/elm-install:21
                           call at /home/robert/.rbenv/versions/jruby-9.1.12.0/lib/ruby/gems/shared/gems/commander-4.4.3/lib/commander/command.rb:178
                            run at /home/robert/.rbenv/versions/jruby-9.1.12.0/lib/ruby/gems/shared/gems/commander-4.4.3/lib/commander/command.rb:153
             run_active_command at /home/robert/.rbenv/versions/jruby-9.1.12.0/lib/ruby/gems/shared/gems/commander-4.4.3/lib/commander/runner.rb:446
                           run! at /home/robert/.rbenv/versions/jruby-9.1.12.0/lib/ruby/gems/shared/gems/commander-4.4.3/lib/commander/runner.rb:68
                           run! at /home/robert/.rbenv/versions/jruby-9.1.12.0/lib/ruby/gems/shared/gems/commander-4.4.3/lib/commander/delegates.rb:15
                block in (root) at /home/robert/.rbenv/versions/jruby-9.1.12.0/lib/ruby/gems/shared/gems/commander-4.4.3/lib/commander/import.rb:5
@headius
Copy link
Member

headius commented Aug 7, 2017

Confirmed on JRuby 9.2.

@headius headius added this to the JRuby 9.2.0.0 milestone Aug 7, 2017
@headius
Copy link
Member

headius commented Aug 7, 2017

I have not sorted out exactly where this is failing, but there are multiple levels of Enumerable calls in e.g. ElmInstall::Utils::transform_constraint, which appears to be the location where the Solve::Constraint instances come from. This logic appears to process an array of constraints, producing an array of Constraint instances that is presumably broken apart somewhere else. That breaking apart is what I suspect of having a bug, but I'm not sure where it is yet.

@enebo enebo modified the milestones: JRuby 9.1.13.0, JRuby 9.2.0.0 Aug 16, 2017
@enebo
Copy link
Member

enebo commented Aug 17, 2017

I have found a clue in this. mri will call Utils::transform_constraint but JRuby will call that method redefined via methodhandler.redefine_method which will blow up. So either a) MRI is not redefining this but we are or b) it should be redefining this method but not on Utils.

@enebo
Copy link
Member

enebo commented Aug 17, 2017

So I believe our problem is that contracts replaces the module_function of Utils::transform_constraint and not the instance version. If I remove Utils. and then include into Utils ElmInstall::Identifier everything works. Also if I alias the transform_constraint and make it a module_function and change Identifier to call it then it also works. So definitely, somewhere the wrong version of transform_constraint is being removed.

enebo added a commit that referenced this issue Aug 17, 2017
Wow!  So order of when method_added and singleton_method_added matter for some
gems (in this case contracts).
@enebo enebo closed this as completed in bd96c06 Aug 17, 2017
@enebo
Copy link
Member

enebo commented Aug 17, 2017

It was the best of times and it was the hinkiest of times...So this is one of the most brittle behavioral incompatibilities I have run into in a while. The basic gist is that contracts gem replaces the wrong verion of a module_method in a Module if the hook methods method_added or method_singleton_added are executed in a different order than MRI does it.

I swapped the order and added a regression. It to me is not harmful to fix this but I really don't think this order is Ruby semantics. Is it? If so then someone can add this to ruby/spec.

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

No branches or pull requests

3 participants