Skip to content

fix(3384): tailcall CLI command not recognized #3396

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .github/workflows/build_matrix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
# IMPORTANT: in case of changing the structure of this file make sure to test
# the changes against `npm/gen-root.ts` file
setup-matrix:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
outputs:
matrix: ${{ steps.setup-matrix.outputs.matrix }}
steps:
Expand All @@ -33,34 +33,34 @@ jobs:
]
include:
- build: linux-x64-gnu
os: ubuntu-latest
os: ubuntu-22.04
rust: stable
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ubuntu 24 cause libc issues on older distro such as ubuntu 22

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tusharmath see this
image

target: x86_64-unknown-linux-gnu
libc: glibc

- build: linux-x64-musl
os: ubuntu-latest
os: ubuntu-22.04
rust: stable
target: x86_64-unknown-linux-musl
libc: musl
cross: true

- build: linux-arm64-gnu
os: ubuntu-latest
os: ubuntu-22.04
rust: stable
target: aarch64-unknown-linux-gnu
libc: glibc
cross: true

- build: linux-arm64-musl
os: ubuntu-latest
os: ubuntu-22.04
rust: stable
target: aarch64-unknown-linux-musl
libc: musl
cross: true

- build: linux-ia32-gnu
os: ubuntu-latest
os: ubuntu-22.04
rust: stable
target: i686-unknown-linux-gnu
libc: glibc
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ jobs:
needs: [setup_build_matrix, test, draft_release, check_if_build, test_cf, test_wasm]
# TODO: put a condition to separate job that other will depend on to remove duplication?
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && (needs.check_if_build.outputs.check_if_build == 'true')
runs-on: ${{ matrix.os || 'ubuntu-latest' }}
runs-on: ${{ matrix.os || 'ubuntu-22.04' }}
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.setup_build_matrix.outputs.matrix) }}
Expand Down
3 changes: 1 addition & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ opentelemetry-appender-tracing = { version = "0.4.0" }
opentelemetry-prometheus = "0.16.0"
phonenumber = "0.3.4"
chrono = "0.4.38"
async-graphql-extension-apollo-tracing = { version = "3.2.15"}
async-graphql-extension-apollo-tracing = { git = "https://github.com/Anshgrover23/async_graphql_apollo_studio_extension", rev = "d89ea0588552c8eb10b7169c012ff3613970126c" }
headers = { workspace = true }
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have already done a PR upstream to fix the issue async-graphql/async_graphql_apollo_studio_extension#194

http = { workspace = true }
mime = "0.3.17"
Expand Down
43 changes: 43 additions & 0 deletions npm/cli.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/usr/bin/env node

import {familySync, GLIBC, MUSL} from "detect-libc"
import {spawn} from "child_process"
import path from "path"
import {fileURLToPath} from "url"

const filename = fileURLToPath(import.meta.url)
const dirname = path.dirname(filename)
const rootDir = path.resolve(dirname, "..")

const platform = process.platform
const arch = process.arch

const libcFamily = familySync()
let libc
if (platform === "win32") {
libc = "-msvc"
} else {
libc = libcFamily === GLIBC ? "-gnu" : libcFamily === MUSL ? "-musl" : ""
}

const pkg = `@tailcallhq/core-${platform}-${arch}${libc}`
const binaryPath = path.join(rootDir, "node_modules", pkg, "bin", platform === "win32" ? "tailcall.exe" : "tailcall")

try {
const child = spawn(binaryPath, process.argv.slice(2), {
stdio: "inherit",
shell: true,
})

child.on("error", (err) => {
console.error(`Failed to execute tailcall: ${err.message}`)
process.exit(1)
})

child.on("exit", (code) => {
process.exit(code ?? 1)
})
} catch (error) {
console.error(`Failed to execute tailcall: ${error.message}`)
process.exit(1)
}
12 changes: 12 additions & 0 deletions npm/gen-root.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ async function genServerPackage(buildDefinitions: string[]) {
name: name,
type: "module",
version: packageVersion,
bin: {
tailcall: "./cli.js",
},
optionalDependencies,
scarfSettings: {
defaultOptIn: true,
Expand Down Expand Up @@ -90,10 +93,19 @@ async function genServerPackage(buildDefinitions: string[]) {
optionalDependencies,
)};\n${preInstallScript}`

// Write script files
await fs.writeFile(resolve(scriptsPath, "post-install.js"), postInstallScriptContent, "utf8")
await fs.writeFile(resolve(scriptsPath, "pre-install.js"), preInstallScriptContent, "utf8")

// Write package.json
await fs.writeFile(resolve(directoryPath, "./package.json"), JSON.stringify(tailcallPackage, null, 2), "utf8")

// Copy cli.js and set executable permissions
const cliPath = resolve(directoryPath, "cli.js")
await fs.copyFile(resolve(__dirname, "cli.js"), cliPath)
await fs.chmod(cliPath, 0o755) // Make cli.js executable

// Copy README
await fs.copyFile(resolve(__dirname, "../README.md"), resolve(directoryPath, "./README.md"))
}

Expand Down
3 changes: 2 additions & 1 deletion npm/gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ async function genPlatformPackage() {
cpu: [cpu],
}

if (libc) platformPackage.libc = [libc]
// Only set libc for non-Windows platforms
if (libc && os !== "win32") platformPackage.libc = [libc]

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

due to this
image

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tusharmath ,
npm only set libc on non-windows platforms
on windows , libc = undefined

const packagePath = `@tailcallhq/core-${build}`
const binPath = `${packagePath}/bin`
Expand Down
Loading