feat(templates): add fixMissing option to aptInstall (#1205)
## Summary - Added `fixMissing` option to `aptInstall()` in JS SDK - Added `fix_missing` parameter to `apt_install()` in Python SDK - Enables `--fix-missing` flag for `apt-get install` command 🤖 Generated with Claude Code <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Low risk: adds an optional flag passthrough to the generated `apt-get install` command in both SDKs, with no behavior change unless explicitly enabled. > > **Overview** > Adds an optional `fixMissing` (JS) / `fix_missing` (Python) parameter to template `apt` install helpers so callers can emit `apt-get install --fix-missing` when builds hit transient package download issues. > > Updates the JS type definitions/docs accordingly and includes a changeset bumping `e2b` and `@e2b/python-sdk` as a minor release. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 4c0b897e192c3ec6b880ab4e3f1695f1b1289d7b. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
db000a20e8
commit
ca856201f5
6
.changeset/apt-fix-missing.md
Normal file
6
.changeset/apt-fix-missing.md
Normal file
@ -0,0 +1,6 @@
|
||||
---
|
||||
"e2b": minor
|
||||
"@e2b/python-sdk": minor
|
||||
---
|
||||
|
||||
Add `fixMissing` / `fix_missing` option to `aptInstall` / `apt_install` to support the `--fix-missing` flag in apt-get install
|
||||
@ -796,14 +796,14 @@ export class TemplateBase
|
||||
|
||||
aptInstall(
|
||||
packages: string | string[],
|
||||
options?: { noInstallRecommends?: boolean }
|
||||
options?: { noInstallRecommends?: boolean; fixMissing?: boolean }
|
||||
): TemplateBuilder {
|
||||
const packageList = Array.isArray(packages) ? packages : [packages]
|
||||
return this.runInNewStackTraceContext(() =>
|
||||
this.runCmd(
|
||||
[
|
||||
'apt-get update',
|
||||
`DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes apt-get install -y ${options?.noInstallRecommends ? '--no-install-recommends ' : ''}${packageList.join(
|
||||
`DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes apt-get install -y ${options?.noInstallRecommends ? '--no-install-recommends ' : ''}${options?.fixMissing ? '--fix-missing ' : ''}${packageList.join(
|
||||
' '
|
||||
)}`,
|
||||
],
|
||||
|
||||
@ -617,11 +617,12 @@ export interface TemplateBuilder {
|
||||
* template.aptInstall('vim')
|
||||
* template.aptInstall(['git', 'curl', 'wget'])
|
||||
* template.aptInstall(['vim'], { noInstallRecommends: true })
|
||||
* template.aptInstall(['vim'], { fixMissing: true })
|
||||
* ```
|
||||
*/
|
||||
aptInstall(
|
||||
packages: string | string[],
|
||||
options?: { noInstallRecommends?: boolean }
|
||||
options?: { noInstallRecommends?: boolean; fixMissing?: boolean }
|
||||
): TemplateBuilder
|
||||
|
||||
/**
|
||||
|
||||
@ -458,13 +458,17 @@ class TemplateBuilder:
|
||||
)
|
||||
|
||||
def apt_install(
|
||||
self, packages: Union[str, List[str]], no_install_recommends: bool = False
|
||||
self,
|
||||
packages: Union[str, List[str]],
|
||||
no_install_recommends: bool = False,
|
||||
fix_missing: bool = False,
|
||||
) -> "TemplateBuilder":
|
||||
"""
|
||||
Install system packages using apt-get.
|
||||
|
||||
:param packages: Package name(s) to install
|
||||
:param no_install_recommends: Whether to install recommended packages
|
||||
:param fix_missing: Whether to fix missing packages
|
||||
|
||||
:return: `TemplateBuilder` class
|
||||
|
||||
@ -472,6 +476,7 @@ class TemplateBuilder:
|
||||
```python
|
||||
template.apt_install('vim')
|
||||
template.apt_install(['git', 'curl', 'wget'])
|
||||
template.apt_install('vim', fix_missing=True)
|
||||
```
|
||||
"""
|
||||
if isinstance(packages, str):
|
||||
@ -481,7 +486,7 @@ class TemplateBuilder:
|
||||
lambda: self.run_cmd(
|
||||
[
|
||||
"apt-get update",
|
||||
f"DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes apt-get install -y {'--no-install-recommends ' if no_install_recommends else ''}{' '.join(packages)}",
|
||||
f"DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes apt-get install -y {'--no-install-recommends ' if no_install_recommends else ''}{'--fix-missing ' if fix_missing else ''}{' '.join(packages)}",
|
||||
],
|
||||
user="root",
|
||||
)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user