0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

proxmox上のubuntu 24.04 LXCにClaude codeをinstallする[備忘録]

Posted at

用意した環境は以下:

proxmox 8.4
Ubuntu 24.04
CTのRAM: 5GB
CTのSwap: 0
CPU: 2 Core

Installation

最新のNode.jsのinstall

以下の記事に従い、nで最新のNode.jsを入れた

Claude codeのinstall

公式のドキュメントに従って npm install -g @anthropic-ai/claude-code とすると、以下のようなエラーが出た。

$ npm install -g @anthropic-ai/claude-code
npm error code EACCES
npm error syscall mkdir
npm error path /usr/local/lib/node_modules/@anthropic-ai
npm error errno -13
npm error Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/@anthropic-ai'
npm error     at async mkdir (node:internal/fs/promises:852:10)
npm error     at async /usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:624:20
npm error     at async Promise.allSettled (index 0)
npm error     at async [reifyPackages] (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:325:11)
npm error     at async Arborist.reify (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:142:5)
npm error     at async Install.exec (/usr/local/lib/node_modules/npm/lib/commands/install.js:150:5)
npm error     at async Npm.exec (/usr/local/lib/node_modules/npm/lib/npm.js:207:9)
npm error     at async module.exports (/usr/local/lib/node_modules/npm/lib/cli/entry.js:74:5) {
npm error   errno: -13,
npm error   code: 'EACCES',
npm error   syscall: 'mkdir',
npm error   path: '/usr/local/lib/node_modules/@anthropic-ai'
npm error }
npm error
npm error The operation was rejected by your operating system.
npm error It is likely you do not have the permissions to access this file as the current user
npm error
npm error If you believe this might be a permissions issue, please double-check the
npm error permissions of the file and its containing directories, or try running
npm error the command again as root/Administrator.

下記に従ってtroubleshootを行う。

最初に今の段階でglobalにinstallされているlibraryをtextに書き出す。今の段階では結果は以下:

$ cat npm-global-packages.txt
/usr/local/lib
├── corepack@0.32.0
├── n@10.2.0
└── npm@10.9.2

global packageのinstall先を変更する

# Create a directory for your global packages
mkdir -p ~/.npm-global

# Configure npm to use the new directory path
npm config set prefix ~/.npm-global

# Note: Replace ~/.bashrc with ~/.zshrc, ~/.profile, or other appropriate file for your shell
echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.bashrc

# Apply the new PATH setting
source ~/.bashrc

これで再度installを試みるとうまく行ったっぽい。

$ npm install -g @anthropic-ai/claude-code

added 3 packages in 2s

2 packages are looking for funding
  run `npm fund` for details

Githubから適当に自分のprojectをcloneして使ってみる

Github CLIを入れる

公式のレポにあるコマンドで入れた。

(type -p wget >/dev/null || (sudo apt update && sudo apt-get install wget -y)) \
	&& sudo mkdir -p -m 755 /etc/apt/keyrings \
        && out=$(mktemp) && wget -nv -O$out https://cli.github.com/packages/githubcli-archive-keyring.gpg \
        && cat $out | sudo tee /etc/apt/keyrings/githubcli-archive-keyring.gpg > /dev/null \
	&& sudo chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg \
	&& sudo mkdir -p -m 755 /etc/apt/sources.list.d \
	&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
	&& sudo apt update \
	&& sudo apt install gh -y

installが終わったらgh auth loginでログインする。CLIで色々と聞かれるので、なすがままに設定を行うと終わる。後は、GitHubのrepositoryで、cloneの所で「GitHub CLI」を選択したら出てくるコマンドを打てばcloneされる。

Claudeに聞いてみる

まずClaudeを立ち上げてみる

claude

Claudeの設定が始まった。
image.png

今回はProプランを購入したので、そのログインもある。LXCにGUI環境はないので、途中で出てくるURLをブラウザにペッしてやる必要がある(CLIの指示に従えば間違えることはない)。
以下のようになれば、使えるっぽい。

image.png

まずは公式にあったsummarize this projectを実行してみることにした。
内容は伏せるが、勝手にファイルを読んで良い感じの出力が出た。

image.png

次に/initを使ってCLAUDE.mdを作り、それをClaude codeにコミットしてもらう。
1分ぐらいでCLAUDE.mdが出来た。

CLAUDE.mdをコミットしてください

と日本語でお願いしてみた。

image.png

いけるっぽい。branchを切らずに雑にinitしたので、ローカルのmainにcommitしちゃったので、

pushしておいてください

と雑にお願いしてみたらちゃんとやってくれた。
image.png

今の所は逐一挙動を確認しているが、勝手にやってくれるようにしたら、どんどんやってくれるんだろうな。

今回はここまでです。
なんかダメな所とかあったら教えてください。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?