MCPcopy Create free account
hub / github.com/Noumena-Network/code / checkInstall

Function checkInstall

src/utils/nativeInstaller/installer.ts:788–928  ·  view source on GitHub ↗
(
  force: boolean = false,
)

Source from the content-addressed store, hash-verified

786}
787
788export async function checkInstall(
789 force: boolean = false,
790): Promise<SetupMessage[]> {
791 // Skip all installation checks if disabled via environment variable
792 if (isEnvTruthy(process.env.DISABLE_INSTALLATION_CHECKS)) {
793 return []
794 }
795
796 // Get the actual installation type and config
797 const installationType = await getCurrentInstallationType()
798
799 // Skip checks for development builds - config.installMethod from a previous
800 // native installation shouldn't trigger warnings when running dev builds
801 if (installationType === 'development') {
802 return []
803 }
804
805 const config = getGlobalConfig()
806
807 // Only show warnings if:
808 // 1. User is actually running from native installation, OR
809 // 2. User has explicitly set installMethod to 'native' in config (they're trying to use native)
810 // 3. force is true (used during installation process)
811 const shouldCheckNative =
812 force || installationType === 'native' || config.installMethod === 'native'
813
814 if (!shouldCheckNative) {
815 return []
816 }
817
818 const dirs = getBaseDirectories()
819 const messages: SetupMessage[] = []
820 const localBinDir = dirname(dirs.executable)
821 const resolvedLocalBinPath = resolve(localBinDir)
822 const platform = getPlatform()
823 const isWindows = platform.startsWith('win32')
824
825 // Check if bin directory exists
826 try {
827 await access(localBinDir)
828 } catch {
829 messages.push({
830 message: `installMethod is native, but directory ${localBinDir} does not exist`,
831 userActionRequired: true,
832 type: 'error',
833 })
834 }
835
836 // Check if ncode executable exists and is valid.
837 // On non-Windows, call readlink directly and route errno — ENOENT means
838 // the executable is missing, EINVAL means it exists but isn't a symlink.
839 // This avoids an access()→readlink() TOCTOU where deletion between the
840 // two calls produces a misleading "Not a symlink" diagnostic.
841 // isPossibleNcodeBinary stats the path internally, so we don't pre-check
842 // with access() — that would be a TOCTOU between access and the stat.
843 if (isWindows) {
844 // On Windows it's a copied executable, not a symlink
845 if (!(await isPossibleNcodeBinary(dirs.executable))) {

Callers 3

runFunction · 0.85
_temp2Function · 0.85

Calls 10

isEnvTruthyFunction · 0.90
getBaseDirectoriesFunction · 0.85
getPlatformFunction · 0.85
isPossibleNcodeBinaryFunction · 0.85
isENOENTFunction · 0.85
getShellTypeFunction · 0.85
getShellConfigPathsFunction · 0.85
getGlobalConfigFunction · 0.50
resolveFunction · 0.50

Tested by

no test coverage detected