{"record":{"id":"9d6a5c227eecb8eb","repo":"ruby/rubygems","slug":"dynamic-library-not-found-for-rust-extension-in","errorCode":null,"errorMessage":"Dynamic library not found for Rust extension (in #{dir})\n\nMake sure you set \"crate-type\" in Cargo.toml to \"cdylib\"\n\nFound files:\n#{files}","messagePattern":"Dynamic library not found for Rust extension \\(in #(.+?)\\)\n\nMake sure you set \"crate-type\" in Cargo\\.toml to \"cdylib\"\n\nFound files:\n#(.+?)","errorType":"exception","errorClass":"Gem::Ext::CargoBuilder::DylibNotFoundError","httpStatus":null,"severity":"error","filePath":"lib/rubygems/ext/cargo_builder.rb","lineNumber":43,"sourceCode":"\n    # Where's the Cargo.toml of the crate we're building\n    cargo_toml = File.join(cargo_dir, \"Cargo.toml\")\n    # What's the crate's name\n    crate_name = cargo_crate_name(cargo_dir, cargo_toml, results)\n\n    begin\n      # Create a tmp dir to do the build in\n      tmp_dest = Dir.mktmpdir(\".gem.\", cargo_dir)\n\n      # Run the build\n      cmd = cargo_command(cargo_toml, tmp_dest, args, crate_name)\n      runner.call(cmd, results, \"cargo\", cargo_dir, build_env)\n\n      # Where do we expect Cargo to write the compiled library\n      dylib_path = cargo_dylib_path(tmp_dest, crate_name)\n\n      # Helpful error if we didn't find the compiled library\n      raise DylibNotFoundError, tmp_dest unless File.exist?(dylib_path)\n\n      # Cargo and Ruby differ on how the library should be named, rename from\n      # what Cargo outputs to what Ruby expects\n      dlext_name = \"#{crate_name}.#{makefile_config(\"DLEXT\")}\"\n      dlext_path = File.join(File.dirname(dylib_path), dlext_name)\n      FileUtils.cp(dylib_path, dlext_path)\n\n      nesting = extension_nesting(extension)\n\n      if Gem.install_extension_in_lib && lib_dir\n        nested_lib_dir = File.join(lib_dir, nesting)\n        FileUtils.mkdir_p nested_lib_dir\n        FileUtils.cp_r dlext_path, nested_lib_dir, remove_destination: true\n      end\n\n      # move to final destination\n      nested_dest_path = File.join(dest_path, nesting)\n      FileUtils.mkdir_p nested_dest_path","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/ruby/rubygems/blob/86cbb817a38ce8477b181c17467a703ded3f2be8/lib/rubygems/ext/cargo_builder.rb#L25-L61","documentation":"Error \"Dynamic library not found for Rust extension (in #{dir})\n\nMake sure you set \"crate-type\" in Cargo.toml to \"cdylib\"\n\nFound files:\n#{files}\" thrown in ruby/rubygems.","triggerScenarios":"Thrown at lib/rubygems/ext/cargo_builder.rb:43 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"86cbb817a38ce8477b181c17467a703ded3f2be8","analyzedAt":"2026-08-23T06:27:48.159Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}