-
Notifications
You must be signed in to change notification settings - Fork 28
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
Error when installing hasura-cli #116
Comments
I ran into this issue under node 18 as well, my solution was to roll back to the last version (2.36.1). |
Should we be concerned that 2.38 was pushed to npm, but not github? |
I'm not sure how 2.38 was published. Does anyone know about it? |
same error |
Probably related to this failed action - https://github.com/jjangga0214/hasura-cli/actions/runs/8413611293/job/23036098801#step:6:14 |
Same same, the |
same here, someone have a solution? |
@jjangga0214 Some help here? |
The only solution is to roll back to an older version. |
That is probably caused by updating directly via the CLI (hasura update-cli). e.g., npm i -g hasura-cli@2.36.1 |
I find the whole point of the package to be able to pin the exact version of the cli tool to the same as I use for the hasura server. While using the update-cli subcommand may be a workaround to get a newer version of the CLI going, it mostlye defeats the point of the npm package. |
Is this issue still not resolved? |
Unfortunately it's not resolved, I accidentially updated this package and it broke my cli again. |
I'm still having this issue as of July, almost 3 months since this issue was opened. This seems like a straightforward solution, are we still maintaining this package? |
I guess this project is dead. Anyone want to fork it and take on doing new releases? |
I have moved away from using this package but figured I could share what I am doing now. My setup relies on a docker-compose existing to scan for a specific version, or it'll download the latest version if it can determine the version number from the All of my hasura commands call a bash script that's located in a tools directory I've included my download script, and my bash proxy script below. ./tools/download-hasura-cli.mjsimport { argv } from 'node:process';
import {
createWriteStream,
chmodSync,
existsSync,
readFileSync,
mkdirSync,
unlinkSync,
} from 'node:fs';
import { execSync } from 'node:child_process';
import { finished } from 'node:stream/promises';
import { Readable } from 'node:stream';
let tag = argv && argv.length > 2 ? argv[2] : null;
const explicitTag = !!tag;
if (!tag) {
if (existsSync('./docker-compose.yml')) {
const dockerCompose = readFileSync('./docker-compose.yml');
const matches = dockerCompose
.toString()
.match(/image: hasura\/graphql-engine:v\d+\.\d+\.\d+$/im);
if (matches && matches.length > 0) {
tag = String(matches[0].split(':').pop());
}
}
}
if (!tag) {
// Go find latest
const res = await fetch(
'https://github.com/hasura/graphql-engine/releases/latest',
{ redirect: 'manual' },
);
if (res && res.headers && res.headers.get('location')) {
tag = res.headers.get('location').split('/').pop();
}
}
if (!tag) {
console.error('Unable to determine hasura tag');
process.exit(1);
}
tag = String(tag).trim();
const platform = process.platform === 'win32' ? 'windows' : process.platform;
const ext = platform === 'windows' ? '.exe' : '';
const output = `./node_modules/.bin/hasura${ext}`;
if (existsSync(output)) {
// Check version
let v = execSync(`${output} version --skip-update-check`).toString();
try {
v = JSON.parse(vout).version;
} catch (e) {
// Do nothing
}
if (v.includes(tag)) {
if (explicitTag) console.log(`hasura-cli@${tag} is already installed`);
process.exit(0);
}
// Remove old version
console.log(`Removing current version of hasura-cli@${v}`);
unlinkSync(output);
}
const parts = [
'cli',
'hasura',
platform,
process.arch === 'x64' ? 'amd64' : process.arch + ext,
].join('-');
const url = `https://github.com/hasura/graphql-engine/releases/download/${tag}/${parts}`;
console.log(`Downloading hasura-cli@${tag} from ${url}`);
const file = await fetch(url);
if (file.ok) {
mkdirSync(`./node_modules/.bin/`, { recursive: true });
const stream = createWriteStream(output);
Readable.fromWeb(file.body).pipe(stream);
await finished(stream);
if (platform !== 'win32') {
chmodSync(output, 0o777);
}
} This has zero dependencies outside of nodejs itself, and uses the native nodejs fetch to download the cli binary directly. I am on nodejs v20, this script uses root level async/await so you'll need to be on a relatively recent version of node. If you manually run the download script node ./tools/download-hasura-cli.mjs v2.41.0 This would download the version for 2.41.0. ./tools/hasura #!/usr/bin/env bash
if [ ! -f ./node_modules/.bin/hasura ]; then
node ./tools/download-hasura-cli.mjs
fi
./node_modules/.bin/hasura "$@" This bit of bash scripting checks for the hasura cli being installed into the node_modules directory, if it doesn't exist it calls a download script, once we have a cli downloaded it simply calls the CLI with all arguments that were passed to it. Make sure it's executable and then you can simply use To run a migration you can run it like this: ./tools/hasura migrate apply --all-databases Then additionally I added a postinstall script to my package.json package.json{
"name": "project-name",
"scripts": {
"start": "start script",
"postinstall": "node ./tools/download-hasura-cli.mjs",
...
}
} With these 2 scripts and the postinstall, my environment works fairly smooth and has the benefit of not having yet another dependency in the package.json to maintain. The |
Hi guys, I am opening this PR #119 to solve the issue. Feel free to have a look. |
When running
npm install -g hasura-cli
, the errors below are shown and hasura-cli won't be installed.I doubt it is caused by the release at 2:10UTC March 25 (version: 2.28.0).
OS: Linux (GitHub Actions) / Mac
Node version: 20.11.1
The text was updated successfully, but these errors were encountered: