Skip to content

Commit ab2004b

Browse files
fix: move from getos to systeminformation to fix OS distro/release info (#32283)
* fix: move from getos to systeminformation * add changelog entry * remove extraneous package that isn't used * update changelog
1 parent fa0b716 commit ab2004b

File tree

7 files changed

+60
-44
lines changed

7 files changed

+60
-44
lines changed

cli/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ _Released 08/26/2025 (PENDING)_
55

66
**Bugfixes:**
77

8+
- Fixed an issue where OS distributions and releases were sometimes not properly populated for Module API results and Cloud recordings. Fixes [#30533](https://github.com/cypress-io/cypress/issues/30533). Addressed in [#32283](https://github.com/cypress-io/cypress/pull/32283).
89
- Fixed an issue where the open Studio button would incorrectly show for component tests. Addressed in [#32315](https://github.com/cypress-io/cypress/pull/32315).
910
- Fixed an issue where the TypeScript compiler wasn't being resolved correctly when `@cypress/webpack-batteries-included-preprocessor` was used as a standalone package. Fixes [#32338](https://github.com/cypress-io/cypress/issues/32338).
1011

cli/lib/util.js

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const tty = require('tty')
99
const path = require('path')
1010
const isCi = require('ci-info').isCI
1111
const execa = require('execa')
12-
const getos = require('getos')
12+
const si = require('systeminformation')
1313
const chalk = require('chalk')
1414
const Promise = require('bluebird')
1515
const cachedir = require('cachedir')
@@ -26,8 +26,6 @@ const pkg = require(path.join(__dirname, '..', 'package.json'))
2626

2727
const issuesUrl = 'https://github.com/cypress-io/cypress/issues'
2828

29-
const getosAsync = Promise.promisify(getos)
30-
3129
/**
3230
* Returns SHA512 of a file
3331
*/
@@ -411,17 +409,16 @@ const util = {
411409

412410
getOsVersionAsync () {
413411
return Promise.try(() => {
414-
if (isLinux()) {
415-
return getosAsync()
416-
.then((osInfo) => {
417-
return [osInfo.dist, osInfo.release].join(' - ')
418-
})
419-
.catch(() => {
420-
return os.release()
421-
})
422-
}
423-
424-
return os.release()
412+
return si.osInfo()
413+
.then((osInfo) => {
414+
if (osInfo.distro && osInfo.release) {
415+
return `${osInfo.distro} - ${osInfo.release}`
416+
}
417+
418+
return os.release()
419+
}).catch(() => {
420+
return os.release()
421+
})
425422
})
426423
},
427424

cli/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
"extract-zip": "2.0.1",
4646
"figures": "^3.2.0",
4747
"fs-extra": "^9.1.0",
48-
"getos": "^3.2.1",
4948
"hasha": "5.2.2",
5049
"is-installed-globally": "~0.4.0",
5150
"lazy-ass": "^1.6.0",
@@ -60,6 +59,7 @@
6059
"request-progress": "^3.0.0",
6160
"semver": "^7.7.1",
6261
"supports-color": "^8.1.1",
62+
"systeminformation": "5.27.7",
6363
"tmp": "~0.2.4",
6464
"tree-kill": "1.2.2",
6565
"untildify": "^4.0.0",

cli/test/lib/util_spec.js

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -389,28 +389,54 @@ describe('util', () => {
389389

390390
describe('.getOsVersionAsync', () => {
391391
let util
392-
let getos = sinon.stub().resolves(['distro-release'])
392+
let systeminformation = {
393+
osInfo: sinon.stub(),
394+
}
393395

394396
beforeEach(() => {
395-
util = proxyquire(`${lib}/util`, { getos })
397+
util = proxyquire(`${lib}/util`, { systeminformation })
396398
})
397399

398-
it('calls os.release on non-linux', () => {
400+
it('calls os.release when systeminformation fails', () => {
399401
os.platform.returns('darwin')
400402
os.release.returns('some-release')
401-
util.getOsVersionAsync()
403+
systeminformation.osInfo.rejects(new Error('systeminformation failed'))
404+
405+
return util.getOsVersionAsync()
402406
.then(() => {
403407
expect(os.release).to.be.called
404-
expect(getos).to.not.be.called
408+
expect(systeminformation.osInfo).to.be.called
405409
})
406410
})
407411

408-
it('NOT calls os.release on linux', () => {
412+
it('uses systeminformation when it succeeds', () => {
409413
os.platform.returns('linux')
410-
util.getOsVersionAsync()
411-
.then(() => {
414+
systeminformation.osInfo.resolves({
415+
distro: 'Ubuntu',
416+
release: '22.04',
417+
})
418+
419+
return util.getOsVersionAsync()
420+
.then((result) => {
421+
expect(result).to.equal('Ubuntu - 22.04')
422+
expect(systeminformation.osInfo).to.be.called
423+
// os.release should not be called when systeminformation succeeds
412424
expect(os.release).to.not.be.called
413-
expect(getos).to.be.called
425+
})
426+
})
427+
428+
it('falls back to os.release when systeminformation returns incomplete data', () => {
429+
os.platform.returns('linux')
430+
os.release.returns('5.15.0')
431+
systeminformation.osInfo.resolves({
432+
distro: 'Ubuntu',
433+
// missing release property
434+
})
435+
436+
return util.getOsVersionAsync()
437+
.then(() => {
438+
expect(systeminformation.osInfo).to.be.called
439+
expect(os.release).to.be.called
414440
})
415441
})
416442
})

packages/server/lib/util/system.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
const os = require('os')
22
const Promise = require('bluebird')
3-
const getos = Promise.promisify(require('getos'))
3+
const si = require('systeminformation')
44

55
const getOsVersion = () => {
66
return Promise.try(() => {
7-
if (os.platform() === 'linux') {
8-
return getos()
9-
.then((obj) => {
10-
return [obj.dist, obj.release].join(' - ')
11-
}).catch(() => {
12-
return os.release()
13-
})
14-
}
7+
return si.osInfo()
8+
.then((osInfo) => {
9+
if (osInfo.distro && osInfo.release) {
10+
return `${osInfo.distro} - ${osInfo.release}`
11+
}
1512

16-
return os.release()
13+
return os.release()
14+
}).catch(() => {
15+
return os.release()
16+
})
1717
})
1818
}
1919

packages/server/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@
8080
"fs-extra": "9.1.0",
8181
"geckodriver": "5.0.0",
8282
"get-port": "5.1.1",
83-
"getos": "3.2.1",
8483
"glob": "7.1.3",
8584
"graceful-fs": "4.2.9",
8685
"http-proxy": "1.18.1",

yarn.lock

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10760,7 +10760,7 @@ async-settle@^1.0.0:
1076010760
dependencies:
1076110761
async-done "^1.2.2"
1076210762

10763-
async@>=0.2.9, async@^3.2.0, async@^3.2.3, async@^3.2.4:
10763+
async@>=0.2.9, async@^3.2.3, async@^3.2.4:
1076410764
version "3.2.4"
1076510765
resolved "https://registry.yarnpkg.com/async/-/async-3.2.4.tgz#2d22e00f8cddeb5fde5dd33522b56d1cf569a81c"
1076610766
integrity sha512-iAB+JbDEGXhyIUavoDl9WP/Jj106Kz9DEn1DPgYw5ruDn0e3Wgi3sKFm55sASdGBNOQB8F59d9qQ7deqrHA8wQ==
@@ -17738,13 +17738,6 @@ [email protected], getenv@^1.0.0:
1773817738
resolved "https://registry.yarnpkg.com/getenv/-/getenv-1.0.0.tgz#874f2e7544fbca53c7a4738f37de8605c3fcfc31"
1773917739
integrity sha512-7yetJWqbS9sbn0vIfliPsFgoXMKn/YMF+Wuiog97x+urnSRRRZ7xB+uVkwGKzRgq9CDFfMQnE9ruL5DHv9c6Xg==
1774017740

17741-
[email protected], getos@^3.2.1:
17742-
version "3.2.1"
17743-
resolved "https://registry.yarnpkg.com/getos/-/getos-3.2.1.tgz#0134d1f4e00eb46144c5a9c0ac4dc087cbb27dc5"
17744-
integrity sha512-U56CfOK17OKgTVqozZjUKNdkfEv6jk5WISBJ8SHoagjE6L69zOwl3Z+O8myjY9MEW3i2HPWQBt/LTbCgcC973Q==
17745-
dependencies:
17746-
async "^3.2.0"
17747-
1774817741
getpass@^0.1.1:
1774917742
version "0.1.7"
1775017743
resolved "https://registry.yarnpkg.com/getpass/-/getpass-0.1.7.tgz#5eff8e3e684d569ae4cb2b1282604e8ba62149fa"
@@ -30145,7 +30138,7 @@ [email protected]:
3014530138
dependencies:
3014630139
acorn-node "^1.2.0"
3014730140

30148-
systeminformation@^5.27.7:
30141+
systeminformation@5.27.7, systeminformation@^5.27.7:
3014930142
version "5.27.7"
3015030143
resolved "https://registry.yarnpkg.com/systeminformation/-/systeminformation-5.27.7.tgz#4dc9d436419948cd5e5f076779a1298220d19a72"
3015130144
integrity sha512-saaqOoVEEFaux4v0K8Q7caiauRwjXC4XbD2eH60dxHXbpKxQ8kH9Rf7Jh+nryKpOUSEFxtCdBlSUx0/lO6rwRg==

0 commit comments

Comments
 (0)