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

Example gem structure doesn't seem to work? #397

Open
pwoolcoc opened this issue Jul 11, 2024 · 1 comment
Open

Example gem structure doesn't seem to work? #397

pwoolcoc opened this issue Jul 11, 2024 · 1 comment

Comments

@pwoolcoc
Copy link

I'm trying to start a new rb-sys-based gem, and thought I should use the example structure here: https://github.com/oxidize-rb/rb-sys/tree/main/examples/rust_reverse

However, when structuring my gem that way I get an error because rb_sys appears to expect a Cargo.toml to be found in the top-level directory. I don't mind putting one there, but I'm curious why the example is there without it. Is there something I could do to not need a top-level Cargo.toml?

Here's the current structure:

$ find . -type f
./bin/setup
./bin/console
./sig/my_gem.rbs
./ext/my_gem/Cargo.toml
./ext/my_gem/extconf.rb
./ext/my_gem/src/lib.rs
./README.md
./Rakefile
./.gitignore
./lib/my_gem.rb
./lib/my_gem/version.rb
./Gemfile
./my_gem.gemspec
./Gemfile.lock

When I run rake --tasks, I get this output:

$ rake --tasks
rake aborted!
RbSys::CargoMetadataError: Could not infer Rust crate information using `cargo metadata`.  Original error was:   RuntimeError: exited with non-zero status (pid 39361 exit 101)  Things to check:   - Check that your ext/*/Cargo.toml at is valid   - If you are using a workspace, make sure you are the root Cargo.toml exists   - Make sure `cargo` is installed and in your PATHStderr from `cargo metadata` was:
  error: could not find `Cargo.toml` in `/Users/me/Code/my_gem` or any parent directory
/Users/me/.rvm/gems/ruby-3.1.3/gems/rb_sys-0.9.98/lib/rb_sys/cargo/metadata.rb:154:in `rescue in cargo_metadata'
/Users/me/.rvm/gems/ruby-3.1.3/gems/rb_sys-0.9.98/lib/rb_sys/cargo/metadata.rb:141:in `cargo_metadata'
/Users/me/.rvm/gems/ruby-3.1.3/gems/rb_sys-0.9.98/lib/rb_sys/cargo/metadata.rb:136:in `package_metadata'
/Users/me/.rvm/gems/ruby-3.1.3/gems/rb_sys-0.9.98/lib/rb_sys/cargo/metadata.rb:76:in `manifest_path'
/Users/me/.rvm/gems/ruby-3.1.3/gems/rb_sys-0.9.98/lib/rb_sys/cargo/metadata.rb:48:in `manifest_directory'
/Users/me/.rvm/gems/ruby-3.1.3/gems/rb_sys-0.9.98/lib/rb_sys/extensiontask.rb:33:in `init'
/Users/me/.rvm/gems/ruby-3.1.3/gems/rake-compiler-1.2.7/lib/rake/baseextensiontask.rb:29:in `initialize'
/Users/me/.rvm/gems/ruby-3.1.3/gems/rb_sys-0.9.98/lib/rb_sys/extensiontask.rb:26:in `initialize'
/Users/me/Code/my_gem/Rakefile:7:in `new'
/Users/me/Code/my_gem/Rakefile:7:in `<top (required)>'
/Users/me/.rvm/gems/ruby-3.1.3/gems/rake-13.2.1/exe/rake:27:in `<top (required)>'
/Users/me/.rvm/gems/ruby-3.1.3/bin/ruby_executable_hooks:22:in `eval'
/Users/me/.rvm/gems/ruby-3.1.3/bin/ruby_executable_hooks:22:in `<main>'

Caused by:
exited with non-zero status (pid 39361 exit 101)
/Users/me/.rvm/gems/ruby-3.1.3/gems/rb_sys-0.9.98/lib/rb_sys/cargo/metadata.rb:149:in `cargo_metadata'
/Users/me/.rvm/gems/ruby-3.1.3/gems/rb_sys-0.9.98/lib/rb_sys/cargo/metadata.rb:136:in `package_metadata'
/Users/me/.rvm/gems/ruby-3.1.3/gems/rb_sys-0.9.98/lib/rb_sys/cargo/metadata.rb:76:in `manifest_path'
/Users/me/.rvm/gems/ruby-3.1.3/gems/rb_sys-0.9.98/lib/rb_sys/cargo/metadata.rb:48:in `manifest_directory'
/Users/me/.rvm/gems/ruby-3.1.3/gems/rb_sys-0.9.98/lib/rb_sys/extensiontask.rb:33:in `init'
/Users/me/.rvm/gems/ruby-3.1.3/gems/rake-compiler-1.2.7/lib/rake/baseextensiontask.rb:29:in `initialize'
/Users/me/.rvm/gems/ruby-3.1.3/gems/rb_sys-0.9.98/lib/rb_sys/extensiontask.rb:26:in `initialize'
/Users/me/Code/my_gem/Rakefile:7:in `new'
/Users/me/Code/my_gem/Rakefile:7:in `<top (required)>'
/Users/me/.rvm/gems/ruby-3.1.3/gems/rake-13.2.1/exe/rake:27:in `<top (required)>'
/Users/me/.rvm/gems/ruby-3.1.3/bin/ruby_executable_hooks:22:in `eval'
/Users/me/.rvm/gems/ruby-3.1.3/bin/ruby_executable_hooks:22:in `<main>'
(See full trace by running task with --trace)

Is there something in my gemspec or Rakefile I need to set to tell it where my Cargo.toml is?

@ianks
Copy link
Collaborator

ianks commented Jul 25, 2024

yeah... that example isnt really good for modelling a real gem. it's more of a test fixture honestly. would love to rename the dir. https://github.com/oxidize-rb/oxi-test is better

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

2 participants