MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / checkInstall

Function checkInstall

source code/utils/nativeInstaller/installer.ts:802–942  ·  view source on GitHub ↗
(
  force: boolean = false,
)

Source from the content-addressed store, hash-verified

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

Callers 3

runFunction · 0.85
_temp2Function · 0.85

Calls 10

isEnvTruthyFunction · 0.85
getGlobalConfigFunction · 0.85
getBaseDirectoriesFunction · 0.85
getPlatformFunction · 0.85
isPossibleClaudeBinaryFunction · 0.85
isENOENTFunction · 0.85
getShellTypeFunction · 0.85
getShellConfigPathsFunction · 0.85
resolveFunction · 0.50

Tested by

no test coverage detected