Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
instance method
Gem::Ext::CargoBuilder#cargo_crate_name
cargo_crate_name(cargo_dir, manifest_path, results)
lib/rubygems/ext/cargo_builder.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.1.0-preview1/lib/rubygems/ext/cargo_builder.rb, line 202
def cargo_crate_name(cargo_dir, manifest_path, results)
require "open3"
Gem.load_yaml
output, status =
begin
Open3.capture2e(cargo, "metadata", "--no-deps", "--format-version", "1", chdir: cargo_dir)
rescue StandardError => error
raise Gem::InstallError, "cargo metadata failed #{error.message}"
end
unless status.success?
if Gem.configuration.really_verbose
puts output
else
results << output
end
exit_reason =
if status.exited?
", exit code #{status.exitstatus}"
elsif status.signaled?
", uncaught signal #{status.termsig}"
end
raise Gem::InstallError, "cargo metadata failed#{exit_reason}"
end
# cargo metadata output is specified as json
require "json"
metadata = JSON.parse(output)
package = metadata["packages"].find {|pkg| normalize_path(pkg["manifest_path"]) == manifest_path }
unless package
found = metadata["packages"].map {|md| "#{md["name"]} at #{md["manifest_path"]}" }
raise Gem::InstallError, <<-EOF
failed to determine cargo package name
looking for: #{manifest_path}
found:
#{found.join("\n")}
EOF
end
package["name"].tr("-", "_")
end
No documentation available
See also
#cargo_command
#cargo_dylib_path
#cargo
#cargo_rustc_args
also in
4.0 · 3.4 · 3.3 · 3.2 · 3.1