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

Package ruby-debug-ide #83779

Closed
wants to merge 1 commit into from
Closed

Package ruby-debug-ide #83779

wants to merge 1 commit into from

Conversation

mbarak
Copy link

@mbarak mbarak commented Mar 30, 2020

Motivation for this change

Allow ruby devs using Nix to use their preferred IDE to debug their projects. ruby-debug-ide is used by VS Code and RubyMine for debugging.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

@mbarak
Copy link
Author

mbarak commented Mar 30, 2020

This is the error I am getting when I try to build

mbarak@ruby-debug-ide-dev:~/nixpkgs$ nix-build -I . -A ruby-debug-ide --show-trace 
these derivations will be built:
  /nix/store/qz5d4ag3gxxcdyrk4n5488a2lx8i5zf3-ruby2.6.5-ruby-debug-ide-0.7.0.drv
  /nix/store/4jvldsnnknxshz3fwxwh49rhgw8pj3ij-ruby-debug-ide-0.7.0.drv
  /nix/store/ck76j91x4n0s0s7wv3xcw1414kji1nmn-ruby-debug-ide-0.7.0.drv
building '/nix/store/qz5d4ag3gxxcdyrk4n5488a2lx8i5zf3-ruby2.6.5-ruby-debug-ide-0.7.0.drv'...
unpacking sources
patching sources
configuring
no configure script, doing nothing
installing
buildFlags: 
WARNING:  You build with buildroot.
  Build root: /
  Bin dir: /nix/store/lbm5aw087kk9g05bv1fixj5020frc7rc-ruby2.6.5-ruby-debug-ide-0.7.0/lib/ruby/gems/2.6.0/bin
  Gem home: /nix/store/lbm5aw087kk9g05bv1fixj5020frc7rc-ruby2.6.5-ruby-debug-ide-0.7.0/lib/ruby/gems/2.6.0
Building native extensions. This could take a while...
ERROR:  Error installing /nix/store/xsayw8pjzjiycsfn7wiagrlj7pz62n8s-ruby-debug-ide-0.7.0.gem:
        ERROR: Failed to build gem native extension.

    current directory: /nix/store/lbm5aw087kk9g05bv1fixj5020frc7rc-ruby2.6.5-ruby-debug-ide-0.7.0/lib/ruby/gems/2.6.0/gems/ruby-debug-ide-0.7.0/ext
/nix/store/a3wafb77xrn5wcz21sxg8l40kdlm2wny-ruby-2.6.5/bin/ruby mkrf_conf.rb
NOTE: Gem::DependencyInstaller#find_gems_with_sources is deprecated with no replacement. It will be removed on or after 2019-12-01.
Gem::DependencyInstaller#find_gems_with_sources called from mkrf_conf.rb:6.
NOTE: Gem::DependencyInstaller#find_gems_with_sources is deprecated with no replacement. It will be removed on or after 2019-12-01.
Gem::DependencyInstaller#find_gems_with_sources called from mkrf_conf.rb:7.
Installing base gem
Unable to resolve dependency: user requested 'debase (> 0)'
/nix/store/a3wafb77xrn5wcz21sxg8l40kdlm2wny-ruby-2.6.5/lib/ruby/2.6.0/rubygems/resolver/installer_set.rb:72:in `add_always_install'
  /nix/store/a3wafb77xrn5wcz21sxg8l40kdlm2wny-ruby-2.6.5/lib/ruby/2.6.0/rubygems/dependency_installer.rb:394:in `resolve_dependencies'
  /nix/store/a3wafb77xrn5wcz21sxg8l40kdlm2wny-ruby-2.6.5/lib/ruby/2.6.0/rubygems/dependency_installer.rb:301:in `install'
  mkrf_conf.rb:36:in `rescue in <main>'
  mkrf_conf.rb:29:in `<main>'

rake failed, exit code 1

Gem files will remain installed in /nix/store/lbm5aw087kk9g05bv1fixj5020frc7rc-ruby2.6.5-ruby-debug-ide-0.7.0/lib/ruby/gems/2.6.0/gems/ruby-debug-ide-0.7.0 for inspection.
Results logged to /nix/store/lbm5aw087kk9g05bv1fixj5020frc7rc-ruby2.6.5-ruby-debug-ide-0.7.0/lib/ruby/gems/2.6.0/extensions/x86_64-linux/2.6.0/ruby-debug-ide-0.7.0/gem_make.out
builder for '/nix/store/qz5d4ag3gxxcdyrk4n5488a2lx8i5zf3-ruby2.6.5-ruby-debug-ide-0.7.0.drv' failed with exit code 1
cannot build derivation '/nix/store/4jvldsnnknxshz3fwxwh49rhgw8pj3ij-ruby-debug-ide-0.7.0.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/ck76j91x4n0s0s7wv3xcw1414kji1nmn-ruby-debug-ide-0.7.0.drv': 1 dependencies couldn't be built
error: build of '/nix/store/ck76j91x4n0s0s7wv3xcw1414kji1nmn-ruby-debug-ide-0.7.0.drv' failed

@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/package-ruby-debug-ide/6471/4

@deliciouslytyped
Copy link
Contributor

Why does it fail to build the native extension? Is there an error message for that somehow?

@zimbatm zimbatm requested review from manveru and zimbatm March 30, 2020 15:15
@zimbatm
Copy link
Member

zimbatm commented Mar 30, 2020

The issue is that the ruby-debug-ide gem doesn't have an explicit dependency on debase, which means that it doesn't become available at build time. Try patching the dependency tree manually to see if it fixes the error.

@mbarak
Copy link
Author

mbarak commented Mar 30, 2020

Try patching the dependency tree manually to see if it fixes the error.

I tried using a local version of ruby-debug-ide where I explicitely set debase as a dependency in the Gemfile. That didn't work.
Do you have anything else I could try?

Also, it seems like ruby-debug-ide tries to install its dependency twice: once with a Gemfile and once in mkrb_conf.rb here:
https://github.com/ruby-debug/ruby-debug-ide/blob/master/ext/mkrf_conf.rb#L31

This might be part of the issue.

@zimbatm
Copy link
Member

zimbatm commented Mar 30, 2020

Indeed. debase probably needs to be added to the ruby-debug-ide buildInputs. This scenario is not super well supported. Basically you want package debase, then inject it back into the bundlerApp useing the gemConfig attribute.

{ bundlerApp, defaultGemConfig
, debase // Packaged separately.
}:
bundlerApp {
  gemConfig = defaultGemConfig // {
    ruby-debug-ide = attrs: {
      buildInputs = [ debase ];
    };
  };
}

@mbarak
Copy link
Author

mbarak commented Mar 30, 2020 via email

@mbarak
Copy link
Author

mbarak commented Mar 30, 2020

Since I added debase to the default set of gems I tried doing this in pkgs/development/ruby-modules/gem-config/default.nix

  ruby-debug-ide = attrs: {
    buildInputs = [ ruby.gems.debase ];
  };

That still didn't work...

@mbarak
Copy link
Author

mbarak commented Mar 30, 2020

Another question, how do I set an environment variable before the build?

I tried doing this:

bundlerApp { <snipped> } // { NO_EXT=true }

I tried doing this

bundlerApp {
...

  preBuild = ''
    export NO_EXT=1
  '';
  postBuild = ''
    export NO_EXT=1
  '';
...
}

(i added a preBuild step locally just for this)

@deliciouslytyped
Copy link
Contributor

deliciouslytyped commented Mar 30, 2020

Edit: even faster if you can find some documentation I guess.

The fastest way until someone replies might be to start digging down into the source of bundlerApp.

If it's mkDerivation based, then any extra variables you set in the arguments of bundlerApp should be passed as environment variables, and will be there for the entirety of the build process (modulo and mutations that happen inside of course). I guess this might be easier to test empirically than to dig in the source though.

Furthermore, I think function application binds stronger than //, so you're actually merging in the "environment variable" to the result of the function application, which is not what you want. You want it to be merged into the parameters.

You can play in nix repl to see whats going on:

nix-repl> let f = {...}@args: { inherit args; }; in f ({c = 1;} // { d = 2; }) 
{ args = { ... }; }

nix-repl> let f = {...}@args: { inherit args; }; in (f {c = 1;}) // { d = 2; }
{ args = { ... }; d = 2; }

nix-repl> let f = {...}@args: { inherit args; }; in f {c = 1;} // { d = 2; }   
{ args = { ... }; d = 2; }

@mbarak
Copy link
Author

mbarak commented Mar 30, 2020

I've been reading a lot of the internal code to figure things out.
bundlerApp uses runCommand from trivial-builders which uses the stdenv.
Unfortunately, bundlerApp doesn't support passing arbitrary values down to mkDerivation. That's why I tried // on the results of the bundlerApp call.

Thanks for the hint re nix repl. I didn't know that existed!

@deliciouslytyped
Copy link
Contributor

deliciouslytyped commented Mar 30, 2020

Hmm, yeah, as far as I can tell it looks like you're right. I'm not sure why it's like that. Maybe there's another way, or its due for a fix :) or it's not supposed to be used like that for some reason?

@deliciouslytyped
Copy link
Contributor

deliciouslytyped commented Mar 30, 2020

Actually, can you .overrideAttrs the result?

@mbarak
Copy link
Author

mbarak commented Mar 31, 2020

I tried that, no luck.
Is there a way to confirm that the environment variable got applied?
I don't know if NO_EXT will work. I'm trying it because based on reading the code of ruby-debug-ide it might work.

@deliciouslytyped
Copy link
Contributor

Well, you can inspect the resulting derivation with nix show-derivation or you can try printing it with a pre or a post phase or somesuch.

show-derivation will take an output path as an argument, you don't have to figure out the .drv (though you can just get it from nix repl)

  • I think.

@stale
Copy link

stale bot commented Oct 3, 2020

Hello, I'm a bot and I thank you in the name of the community for your contributions.

Nixpkgs is a busy repository, and unfortunately sometimes PRs get left behind for too long. Nevertheless, we'd like to help committers reach the PRs that are still important. This PR has had no activity for 180 days, and so I marked it as stale, but you can rest assured it will never be closed by a non-human.

If this is still important to you and you'd like to remove the stale label, we ask that you leave a comment. Your comment can be as simple as "still important to me". But there's a bit more you can do:

If you received an approval by an unprivileged maintainer and you are just waiting for a merge, you can @ mention someone with merge permissions and ask them to help. You might be able to find someone relevant by using Git blame on the relevant files, or via GitHub's web interface. You can see if someone's a member of the nixpkgs-committers team, by hovering with the mouse over their username on the web interface, or by searching them directly on the list.

If your PR wasn't reviewed at all, it might help to find someone who's perhaps a user of the package or module you are changing, or alternatively, ask once more for a review by the maintainer of the package/module this is about. If you don't know any, you can use Git blame on the relevant files, or GitHub's web interface to find someone who touched the relevant files in the past.

If your PR has had reviews and nevertheless got stale, make sure you've responded to all of the reviewer's requests / questions. Usually when PR authors show responsibility and dedication, reviewers (privileged or not) show dedication as well. If you've pushed a change, it's possible the reviewer wasn't notified about your push via email, so you can always officially request them for a review, or just @ mention them and say you've addressed their comments.

Lastly, you can always ask for help at our Discourse Forum, or more specifically, at this thread or at #nixos' IRC channel.

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Oct 3, 2020
@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jan 18, 2021
@mbarak mbarak closed this Feb 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants