claude-code icon indicating copy to clipboard operation
claude-code copied to clipboard

Feature: add a /restart option

Open jwr opened this issue 9 months ago • 13 comments

The current update mechanism doesn't work well when running Claude Code in a docker container. The software says "Update installed · Restart to apply", but restarting the entire container rolls back the update, and there seems to be no good way to restart the app within the container.

A /restart option would help as an interim solution.

As a side note, rebuilding the docker container doesn't update the software, because the "RUN npm install -g @anthropic-ai/claude-code" line is cached.

jwr avatar Mar 11 '25 03:03 jwr

I haven't ran claude code in docker yet, but I usually /exit and claude again for a quick restart

Bikz avatar Mar 11 '25 05:03 Bikz

+1 for the OP, I have exactly the same situation and I also looked for a "/restart" cmd

markz889 avatar Mar 11 '25 13:03 markz889

FWIW, I ended up modifyng the Dockerfile to include the exact version number of the npm package. That lets me rebuild the container and use the updated version.

jwr avatar Mar 12 '25 00:03 jwr

Can you ctrl+c and restart? or is claude code literally your entrypoint in the docker container?

8enmann avatar Mar 13 '25 07:03 8enmann

Yes, of course it is, this is how I run claude code interactively in a docker container:

d run -it -e CLAUDE_CONFIG_DIR=/home/node/.claude --volume ~/.config/claude-code:/home/node/.claude --volume .:/workspace jrychter/claude-code claude

This persists the settings/configuration.

jwr avatar Mar 13 '25 08:03 jwr

I see the "Update installed · Restart to apply" message continuously in claude running in a terminal in vscode. There is no /restart command. I tried /exit and then started claude again, and the "Update installed · Restart to apply" message is there again. I checked /doctor and it says everything is healthy. I spent 30 minutes trying to figure out how to do this and no joy.

jmarkmorris avatar Mar 25 '25 20:03 jmarkmorris

I see the "Update installed · Restart to apply" message continuously in claude running in a terminal in vscode. There is no /restart command. I tried /exit and then started claude again, and the "Update installed · Restart to apply" message is there again. I checked /doctor and it says everything is healthy. I spent 30 minutes trying to figure out how to do this and no joy.

I'm experiencing the same. Not sure how to apply the update aside from reinstalling everything.

igagen avatar Mar 26 '25 09:03 igagen

In addition to suggestions above, some further workarounds when using claude-code in a container (eg the supplied devcontainer or your custom variant):

  1. Rebuild the whole container, uncached, every time: docker build --pull --no-cache -t claude-code . This will get you the latest of everything, but is a bit tedious to run several times per day.

  2. Uncache the installation of the claude-code npm package: Add a var in the dockerfile just prior to the npm install, eg: ARG NOCACHE # Install Claude RUN npm install -g @anthropic-ai/claude-code

Then build the image using: docker build --build-arg NOCACHE=$(date +%s%N) -t claude-code . The image will be cached up to the point of the env var, and will be rebuilt from then onwards (eg the npm install will not be cached). If you wrap this up in "claude-run.sh" bash, you can get the latest version of the npm package every time you run the claude-code container, with minimal build-delay.

Note, for a "/restart" option to work within a container, I expect it will have to not completely quit the npm package, as this will end the user container in most cases, so "/restart" is going to need be smarter than that (or maybe wrapped in bash which can handle "/quit" vs "/restart", via exit code?).

markz889 avatar Mar 29 '25 08:03 markz889

I got it to work by doing: npm update -g @anthropic-ai/claude-code

I apparently had a pretty old version. I tried"

  • /exit, then claude
  • closing iTerm, re-opening, claude
  • rebooting

after the npm update I see new commands, like /migrate-installer, and no more update message

lifeinchords avatar Apr 23 '25 08:04 lifeinchords

If you used the /migrate-installer and are now running claude locally instead of from npm packages, I got the message to go away by doing claude update in terminal before running claude again

briandonahue avatar Jun 02 '25 17:06 briandonahue

after /migrate-installer in Claude Code to switch from NPM to local installation...

claude update in terminal works great, thanks @briandonahue

legel avatar Jun 04 '25 21:06 legel

Tried really hard to get claude code to restart itself. It seemed to think it could, but had to Ctrl+C.

https://github.com/user-attachments/assets/66663875-f7c0-4189-835c-9c65cc9ab680

mulka avatar Jun 15 '25 00:06 mulka

@briandonahue thanks so much, claude update works well for the local one

RichardLiu6 avatar Jun 19 '25 06:06 RichardLiu6

This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.

github-actions[bot] avatar Oct 10 '25 10:10 github-actions[bot]

Hi - we've made many reliability improvements to the auto-upgrader so this should be less of an issue now. We've also switched users over to our native installer. Please open a new issue if you are still experiencing issues. Thank you!

catherinewu avatar Nov 30 '25 02:11 catherinewu