MCPcopy
hub / github.com/codeaashu/claude-code / run

Function run

src/commands/install.tsx:98–207  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

96 });
97 useEffect(() => {
98 async function run() {
99 try {
100 logForDebugging(`Install: Starting installation process (force=${force}, target=${target})`);
101
102 // Install native build first
103 const channelOrVersion = target || getInitialSettings()?.autoUpdatesChannel || 'latest';
104 setState({
105 type: 'installing',
106 version: channelOrVersion
107 });
108
109 // Pass force flag to trigger reinstall even if up to date
110 logForDebugging(`Install: Calling installLatest(channelOrVersion=${channelOrVersion}, forceReinstall=${force})`);
111 const result = await installLatest(channelOrVersion, force);
112 logForDebugging(`Install: installLatest returned version=${result.latestVersion}, wasUpdated=${result.wasUpdated}, lockFailed=${result.lockFailed}`);
113
114 // Check specifically for lock failure
115 if (result.lockFailed) {
116 throw new Error('Could not install - another process is currently installing Claude. Please try again in a moment.');
117 }
118
119 // If we couldn't get the version, there might be an issue
120 if (!result.latestVersion) {
121 logForDebugging('Install: Failed to retrieve version information during install', {
122 level: 'error'
123 });
124 }
125 if (!result.wasUpdated) {
126 logForDebugging('Install: Already up to date');
127 }
128
129 // Set up launcher and shell integration
130 setState({
131 type: 'setting-up'
132 });
133 const setupMessages = await checkInstall(true);
134 logForDebugging(`Install: Setup launcher completed with ${setupMessages.length} messages`);
135 if (setupMessages.length > 0) {
136 setupMessages.forEach(msg => logForDebugging(`Install: Setup message: ${msg.message}`));
137 }
138
139 // Now that native installation succeeded, clean up old npm installations
140 logForDebugging('Install: Cleaning up npm installations after successful install');
141 const {
142 removed,
143 errors,
144 warnings
145 } = await cleanupNpmInstallations();
146 if (removed > 0) {
147 logForDebugging(`Cleaned up ${removed} npm installation(s)`);
148 }
149 if (errors.length > 0) {
150 logForDebugging(`Cleanup errors: ${errors.join(', ')}`);
151 // Continue despite cleanup errors - native install already succeeded
152 }
153
154 // Clean up old shell aliases
155 const aliasMessages = await cleanupShellAliases();

Callers 1

InstallFunction · 0.70

Calls 10

logForDebuggingFunction · 0.85
getInitialSettingsFunction · 0.85
installLatestFunction · 0.85
checkInstallFunction · 0.85
cleanupNpmInstallationsFunction · 0.85
cleanupShellAliasesFunction · 0.85
logEventFunction · 0.85
updateSettingsForSourceFunction · 0.85
forEachMethod · 0.80
errorMessageFunction · 0.50

Tested by

no test coverage detected