TL;DR
素直に Dev Container か GitHub Codespace を使いましょう。
はじめに
Azure Open AI Service をサクッと試したい時のサンプルとして以下のリポジトリがあります。
このリポジトリは Azure Developer CLIの azd up
で簡単にリソースを構築できるように構成されています。
発生した問題
README
どおりに azd up
とすすめると以下のエラーが発生しました。
環境は WSL2 の Ubuntu です。
$ azd up
(✓) Done: Downloading Bicep
? Select an Azure Subscription to use: ★選択したサブスクリプション★
(✓) Done: Retrieving locations...
? Select an Azure location to use: 9. (Asia Pacific) Japan East (japaneast)
(✓) Done: Retrieving locations...
Packaging services (azd package)
| | Packaging service backendExecuting prepackage hook => /tmp/azd-prepackage-2315986154.sh
npm WARN cleanup Failed to remove some directories [
npm WARN cleanup [
npm WARN cleanup '\\\\wsl.localhost\\Ubuntu\\home\\toshida\\Projects\\LearningDay\\20230830_AzureSearchOpenAIDemo\\resources\\app\\frontend\\node_modules\\@types',
npm WARN cleanup [Error: EPERM: operation not permitted, rmdir '\\wsl.localhost\Ubuntu\home\toshida\Projects\LearningDay\20230830_AzureSearchOpenAIDemo\resources\app\frontend\node_modules\@types\react\ts5.0'] {
npm WARN cleanup errno: -4048,
npm WARN cleanup code: 'EPERM',
npm WARN cleanup syscall: 'rmdir',
npm WARN cleanup path: '\\\\wsl.localhost\\Ubuntu\\home\\toshida\\Projects\\LearningDay\\20230830_AzureSearchOpenAIDemo\\resources\\app\\frontend\\node_modules\\@types\\react\\ts5.0'
npm WARN cleanup }
npm WARN cleanup ],
npm WARN cleanup [
npm WARN cleanup '\\\\wsl.localhost\\Ubuntu\\home\\toshida\\Projects\\LearningDay\\20230830_AzureSearchOpenAIDemo\\resources\\app\\frontend\\node_modules',
npm WARN cleanup [Error: EPERM: operation not permitted, rmdir '\\wsl.localhost\Ubuntu\home\toshida\Projects\LearningDay\20230830_AzureSearchOpenAIDemo\resources\app\frontend\node_modules\@fluentui\react\lib\components\pickers\PeoplePicker'] {
npm WARN cleanup errno: -4048,
npm WARN cleanup code: 'EPERM',
npm WARN cleanup syscall: 'rmdir',
npm WARN cleanup path: '\\\\wsl.localhost\\Ubuntu\\home\\toshida\\Projects\\LearningDay\\20230830_AzureSearchOpenAIDemo\\resources\\app\\frontend\\node_modules\\@fluentui\\react\\lib\\components\\pickers\\PeoplePicker'
npm WARN cleanup }
npm WARN cleanup ],
npm WARN cleanup [
npm WARN cleanup '\\\\wsl.localhost\\Ubuntu\\home\\toshida\\Projects\\LearningDay\\20230830_AzureSearchOpenAIDemo\\resources\\app\\frontend\\node_modules\\@fluentui',
npm WARN cleanup [Error: EPERM: operation not permitted, rmdir '\\wsl.localhost\Ubuntu\home\toshida\Projects\LearningDay\20230830_AzureSearchOpenAIDemo\resources\app\frontend\node_modules\@fluentui\react\lib-commonjs\components\pickers\PeoplePicker'] {
npm WARN cleanup errno: -4048,
npm WARN cleanup code: 'EPERM',
npm WARN cleanup syscall: 'rmdir',
npm WARN cleanup path: '\\\\wsl.localhost\\Ubuntu\\home\\toshida\\Projects\\LearningDay\\20230830_AzureSearchOpenAIDemo\\resources\\app\\frontend\\node_modules\\@fluentui\\react\\lib-commonjs\\components\\pickers\\PeoplePicker'
npm WARN cleanup }
npm WARN cleanup ],
npm WARN cleanup [
npm WARN cleanup '\\\\wsl.localhost\\Ubuntu\\home\\toshida\\Projects\\LearningDay\\20230830_AzureSearchOpenAIDemo\\resources\\app\\frontend\\node_modules\\@jridgewell',
npm WARN cleanup [Error: EPERM: operation not permitted, rmdir '\\wsl.localhost\Ubuntu\home\toshida\Projects\LearningDay\20230830_AzureSearchOpenAIDemo\resources\app\frontend\node_modules\@jridgewell\trace-mapping'] {
npm WARN cleanup errno: -4048,
npm WARN cleanup code: 'EPERM',
npm WARN cleanup syscall: 'rmdir',
npm WARN cleanup path: '\\\\wsl.localhost\\Ubuntu\\home\\toshida\\Projects\\LearningDay\\20230830_AzureSearchOpenAIDemo\\resources\\app\\frontend\\node_modules\\@jridgewell\\trace-mapping'
npm WARN cleanup }
npm WARN cleanup ]
npm WARN cleanup ]
npm ERR! code 1
npm ERR! path \\wsl.localhost\Ubuntu\home\toshida\Projects\LearningDay\20230830_AzureSearchOpenAIDemo\resources\app\frontend\node_modules\esbuild
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c node install.js
npm ERR! '\\wsl.localhost\Ubuntu\home\toshida\Projects\LearningDay\20230830_AzureSearchOpenAIDemo\resources\app\frontend\node_modules\esbuild'
npm ERR! ��L�̌��݂̃f�B���N�g���� CMD.EXE ���J�n���܂����B
npm ERR! UNC �p�X�̓T�|�[�g����܂���BWindows �f�B���N�g��������Ŏg�p���܂��B
npm ERR! node:internal/modules/cjs/loader:1080
npm ERR! throw err;
npm ERR! ^
npm ERR!
npm ERR! Error: Cannot find module 'C:\Windows\install.js'
npm ERR! at Module._resolveFilename (node:internal/modules/cjs/loader:1077:15)
npm ERR! at Module._load (node:internal/modules/cjs/loader:922:27)
npm ERR! at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
npm ERR! at node:internal/main/run_main_module:23:47 {
npm ERR! code: 'MODULE_NOT_FOUND',
npm ERR! requireStack: []
npm ERR! }
npm ERR!
npm ERR! Node.js v18.17.1
npm ERR! A complete log of this run can be found in: C:\Users\toshida\AppData\Local\npm-cache\_logs\2023-08-30T02_48 | ===| Packaging service backend
(x) Failed: Packaging service backend
ERROR: failed packaging service 'backend': failed invoking event handlers for 'prepackage', 'prepackage' hook failed with exit code: '1', Path: '/tmp/azd-prepackage-2315986154.sh'. : exit code: 1
なにやら node 系のエラーっぽい模様です。
原因
npm
がなぜか Windows 側のバイナリを見てる。なんで?
toshida at toshida-laptop in ~
$ which node
/home/toshida/n/bin/node
toshida at toshida-laptop in ~
$ which npm
/mnt/c/Program Files/nodejs/npm
回避策
どうやら Windows 側のパスが追加されているかららしい。でも node
は wsl側の使ってるのに。。。
$ echo $PATH
/usr/local/bin:/usr/local/sbin:/home/toshida/.cargo/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/wsl/lib:/mnt/c/WINDOWS/system32:/mnt/c/WINDOWS:/mnt/c/WINDOWS/System32/Wbem:/mnt/c/WINDOWS/System32/WindowsPowerShell/v1.0/:/mnt/c/WINDOWS/System32/OpenSSH/:/mnt/c/Program Files/PowerShell/7/:/mnt/c/Program Files/Microsoft SQL Server/Client SDK/ODBC/170/Tools/Binn/:/mnt/c/Program Files/Microsoft SQL Server/150/Tools/Binn/:/Docker/host/bin:/mnt/c/Program Files/dotnet/:/mnt/c/Users/toshida/AppData/Roaming/nvm:/mnt/c/Program Files/nodejs:/mnt/c/Users/toshida/AppData/Local/Microsoft/WindowsApps:/mnt/c/Users/toshida/AppData/Local/Programs/Microsoft VS Code/bin:/mnt/c/Users/toshida/.dotnet/tools:/home/toshida/.local/bin:/home/toshida/.fzf/bin:/home/toshida/n/bin
ググった結果 appendWindowsPath
を設定すると良いそうです。
azd
も Azure Open AI Service も関係ないお話でした。