@@ -32,6 +32,8 @@ pub enum Error {
3232 } ,
3333 #[ error( transparent) ]
3434 UrlError ( #[ from] url:: ParseError ) ,
35+ #[ error( "Could not read install directory from Bundler" ) ]
36+ BadBundlePath ,
3537}
3638
3739type Result < T > = std:: result:: Result < T , Error > ;
@@ -54,17 +56,25 @@ async fn ci_inner(
5456 let lockfile_contents = std:: fs:: read_to_string ( lockfile_path) ?;
5557 let lockfile = rv_lockfile:: parse ( & lockfile_contents) ?;
5658 let gems = download_gems ( lockfile, cache, max_concurrent_requests) . await ?;
57- install_gems ( gems) ;
59+ install_gems ( gems) ? ;
5860 Ok ( ( ) )
5961}
6062
63+ fn find_bundle_path ( ) -> Result < Utf8PathBuf > {
64+ let bundle_path = std:: process:: Command :: new ( "ruby" )
65+ . args ( [ "-rbundler" , "-e" , "'puts Bundler.bundle_path'" ] )
66+ . spawn ( ) ?
67+ . wait_with_output ( )
68+ . map ( |out| out. stdout ) ?;
69+ String :: from_utf8 ( bundle_path)
70+ . map_err ( |_| Error :: BadBundlePath )
71+ . map ( Utf8PathBuf :: from)
72+ }
73+
6174fn install_gems ( gems : Vec < Vec < Downloaded > > ) -> Result < ( ) > {
6275 // 1. Get the path where we want to put the gems from Bundler
6376 // ruby -rbundler -e 'puts Bundler.bundle_path'
64- // 2. Unpack all the tarballs into DIR/gems/
65- // each inner tarball inside a .gem goes into a directory that uses
66- // the gem's name tuple of NAME-VERSION(-PLATFORM), like this:
67- // nokogiri-1.18.10-arm64-darwin racc-1.8.1 rack-3.2.3 rake-13.3.0
77+ let bundle_path = find_bundle_path ( ) ?;
6878 // 3. Generate binstubs into DIR/bin/
6979 // 4. Handle compiling native extensions for gems with native extensions
7080 // 5. Copy the .gem files and the .gemspec files into cache and specificatiosn?
0 commit comments