Skip to content

Commit

Permalink
fix(cocoapods): add activesupport workaround (#1548)
Browse files Browse the repository at this point in the history
  • Loading branch information
viceice committed Oct 9, 2023
1 parent 80f6e73 commit 33eff6e
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 7 deletions.
44 changes: 44 additions & 0 deletions src/cli/tools/ruby/gem.ts
@@ -1,5 +1,7 @@
import { join } from 'node:path';
import { execa } from 'execa';
import { injectable } from 'inversify';
import { satisfies } from 'semver';
import { InstallRubyBaseService } from './utils';

@injectable()
Expand All @@ -14,4 +16,46 @@ export class InstallCocoapodsService extends InstallRubyBaseService {
override async test(_version: string): Promise<void> {
await execa('pod', ['--version', '--allow-root'], { stdio: 'inherit' });
}

protected override async _postInstall(
gem: string,
version: string,
prefix: string,
env: NodeJS.ProcessEnv,
): Promise<void> {
// https://github.com/containerbase/base/issues/1547
if (!satisfies(version, '1.12.0 - 1.13.0')) {
return;
}

await execa(
gem,
[
'install',
'activesupport',
'--install-dir',
prefix,
'--bindir',
join(prefix, 'bin'),
'--version',
'<7.1.0',
],
{ stdio: ['inherit', 'inherit', 1], env, cwd: this.pathSvc.installDir },
);

await execa(
gem,
[
'uninstall',
'activesupport',
'--install-dir',
prefix,
'--bindir',
join(prefix, 'bin'),
'--version',
'>=7.1.0',
],
{ stdio: ['inherit', 'inherit', 1], env, cwd: this.pathSvc.installDir },
);
}
}
9 changes: 9 additions & 0 deletions src/cli/tools/ruby/utils.ts
Expand Up @@ -58,6 +58,8 @@ export abstract class InstallRubyBaseService extends InstallToolBaseService {
],
{ stdio: ['inherit', 'inherit', 1], env, cwd: this.pathSvc.installDir },
);

await this._postInstall(gem, version, prefix, env);
}

override async isInstalled(version: string): Promise<boolean> {
Expand Down Expand Up @@ -105,6 +107,13 @@ export abstract class InstallRubyBaseService extends InstallToolBaseService {
return (await this.versionSvc.find('ruby')) !== null;
}

protected _postInstall(
_gem: string,
_version: string,
_prefix: string,
_env: NodeJS.ProcessEnv,
): Promise<void> | void {}

private async getRubyGem(): Promise<string> {
const rubyVersion = await this.getRubyVersion();

Expand Down
17 changes: 11 additions & 6 deletions test/ruby/Dockerfile
Expand Up @@ -146,7 +146,7 @@ ENV BUNDLER_VERSION=2.4.20
RUN install-tool bundler

#--------------------------------------
# test: cocoapods
# test: cocoapods (gem install)
#--------------------------------------
FROM build as test-cocoapods-a

Expand All @@ -158,16 +158,22 @@ RUN gem install cocoapods -v 1.9.1

RUN set -ex; \
cd b/Project; \
gem install cocoapods-acknowledgements; \
pod install;

#--------------------------------------
# test: unused
# test: cocoapods v1.11.3 (install-tool)
#--------------------------------------
FROM build3 as test-cocoapods-b

# unused
USER 1000

RUN install-tool cocoapods 1.11.3

RUN pod env

RUN set -ex; \
cd b/Project; \
pod install;

#--------------------------------------
# test: cocoapods (install-tool)
Expand All @@ -183,7 +189,6 @@ RUN pod env

RUN set -ex; \
cd b/Project; \
gem install cocoapods-acknowledgements; \
pod install;

#--------------------------------------
Expand All @@ -209,6 +214,6 @@ COPY --from=test-bundler-b /.dummy /.dummy
COPY --from=test-bundler-c /.dummy /.dummy
COPY --from=test-bundler-d /.dummy /.dummy
COPY --from=test-cocoapods-a /.dummy /.dummy
# COPY --from=test-cocoapods-b /.dummy /.dummy
COPY --from=test-cocoapods-b /.dummy /.dummy
COPY --from=test-cocoapods-c /.dummy /.dummy
COPY --from=test-gem /.dummy /.dummy
2 changes: 1 addition & 1 deletion test/ruby/test/b/Project/Podfile
@@ -1,4 +1,4 @@
plugin 'cocoapods-acknowledgements'
#plugin 'cocoapods-acknowledgements'

target "Demo Project" do
pod "CPDAcknowledgements", :path => "../CPDAcknowledgements.podspec"
Expand Down

0 comments on commit 33eff6e

Please sign in to comment.