Maintenance Ruby 3.3 gets fixes, but no new features. 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-3.3.0/lib/rubygems/ext/cargo_builder.rb, line 195
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, but with the
# --format-version 1 option the output is compatible with YAML, so we can
# avoid the json dependency
metadata = Gem::SafeYAML.safe_load(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.1 · 4.0 · 3.4 · 3.2 · 3.1