Closed11
Qni

build
環境
Mac mini 2023 Apple M2
macOS Ventura
xcode-select version 2397
Homebrew 4.0.21
build方法
依存関係
brew install node #JavaScript runtime environment
brew install postgresql #postgresql@14: an open-source relational database management system
brew install libpq # a C library that enables PostgreSQL database access
npm i yarn # a package manager for node
#Ruby environment (tools used to manage Ruby versions)
brew install rbenv ruby-build # Ruby=2.7.4(?)
eval "$(rbenv init - zsh)"
# rbenv install 2.7.4 #failed
# https://github.com/rbenv/ruby-build/issues/1691#issuecomment-994463697
# arch -arm64 rbenv install 2.7.4 #failed
# https://oyubab.com/it/m1mac-rbenv-fail-install/
# succeeded
RUBY_CFLAGS="-Wno-error=implicit-function-declaration" arch -x86_64 rbenv install 2.7.4
# WARNING: ruby-2.7.4 is past its end of life and is now unsupported.
rbenv local 2.7.4
build実行
git clone https://github.com/qniapp/qni.git && cd qni
yarn #必要なnpmのinstall
yarn build

yarn
yarn install v1.22.19
[1/4] 🔍 Resolving packages...
[2/4] 🚚 Fetching packages...
[3/4] 🔗 Linking dependencies...
[4/4] 🔨 Building fresh packages...
$ husky install
husky - Git hooks installed
✨ Done in 26.81s.
yarn build
yarn run v1.22.19
$ lerna run build
lerna notice cli v6.4.1
✔ @qni/common:build (7s)
✔ @qni/elements:build (9s)
✔ @qni/simulator:build (8s)
✔ @qni/elements-example:build (3s)
✔ @qni/tutorial:build (4s)
✔ @qni/www:build (4s)
——————————————————————————————————————————————————————————————————————————————————
> Lerna (powered by Nx) Successfully ran target build for 6 projects (27s)
✨ Done in 29.89s.

cd apps/www
#Installs the required Ruby gems (dependencies) specified in the project's Gemfile.
bundle # failed
結果
Fetching gem metadata from https://rubygems.org/.........
Fetching rake 13.0.6
Installing rake 13.0.6
# ...
# 省略
# ...
Fetching pg 1.2.3
Installing pg 1.2.3 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /Users/USER_NAME/.rbenv/versions/2.7.4/lib/ruby/gems/2.7.0/gems/pg-1.2.3/ext
/Users/USER_NAME/.rbenv/versions/2.7.4/bin/ruby -I /Users/USER_NAME/.rbenv/versions/2.7.4/lib/ruby/2.7.0 -r ./siteconf20230611-95779-13g4v34.rb extconf.rb
checking for pg_config... yes
Using config values from /Users/USER_NAME/.pyenv/versions/anaconda3-2022.10/bin/pg_config
checking for libpq-fe.h... yes
checking for libpq/libpq-fs.h... yes
checking for pg_config_manual.h... yes
checking for PQconnectdb() in -lpq... no
checking for PQconnectdb() in -llibpq... no
checking for PQconnectdb() in -lms/libpq... no
Can't find the PostgreSQL client library (libpq)
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.
Provided configuration options:
#省略
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/Users/USER_NAME/.rbenv/versions/2.7.4/lib/ruby/gems/2.7.0/extensions/x86_64-darwin-22/2.7.0/pg-1.2.3/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in /UsersUSER_NAME/.rbenv/versions/2.7.4/lib/ruby/gems/2.7.0/gems/pg-1.2.3 for inspection.
Results logged to /Users/USER_NAME/.rbenv/versions/2.7.4/lib/ruby/gems/2.7.0/extensions/x86_64-darwin-22/2.7.0/pg-1.2.3/gem_make.out
An error occurred while installing pg (1.2.3), and Bundler cannot continue.
Make sure that `gem install pg -v '1.2.3' --source 'https://rubygems.org/'` succeeds before bundling.
In Gemfile:
pg
失敗理由
Can't find the PostgreSQL client library (libpq)
が原因っぽい.
入れたはずじゃが...
https://stackoverflow.com/questions/6209797/cant-find-the-postgresql-client-library-libpq
env ARCHFLAGS="-arch x86_64" gem install pg -v '1.2.3' #failed
上のcommentによるとrubyとPostgreSQLのbuildしたアーキの違いが原因らしい?
rbenv which ruby | xargs lipo -info # x86_64
which postgres | xargs lipo -info # x86_64
ここが根本原因ではない↓

こっちが原因だった...
Using config values from /Users/USER_NAME/.pyenv/versions/anaconda3-2022.10/bin/pg_config
なんでanaconda呼んでるんだ...?と嫌な予感はしていたけどconda deactivate
したら通った...
conda deactivate
bundle # succeeded

# conda deactivate
git clone https://github.com/qniapp/qni.git && cd qni
eval "$(rbenv init - zsh)"
rbenv local 2.7.4
yarn && yarn build
cd app/www
bundle

rake db:create
でコケたのでやり直し
brew services start postgresql@14
# Creates the PostgreSQL database specified for the project.
rake db:create # succeeded
# Runs database migrations, which sets up the database schema and prepares it for use.
rake db:migrate
yarn dev
でserver起動localhost:3000
にbrowserでaccessすると見られる

別環境でテスト
Mac Studio 2022 Apple M1 Ultra
macOS Ventura
xcode-select version 2397
Homebrew 4.0.22
-
rbenv install 2.7.4
でerror発生せず -
npm -i yarn
でinstallしてもyarn
がpathに追加されてなかった-
npm install -g install
でやり直したら追加された
-

APIのdocはrootでyarn docs
でqni/packages/xxxxx/docs/index.html
ができるのでこれをbrowserで開くと良い.
ここでxxxxx
はcommon
, simulator
, elements
がある

TypeScriptで書かれている

使用されているtool
- Tailwind CSS: CSS framework
- PostCSS: a tool for transforming CSS with JavaScript plugins
- Husky: linterの自動化?
- ESlint: a JavaScript linter that helps identify and report coding patterns that may have errors or lead to bugs
- Prettier: a code formatter that helps maintain consistent code style
- Rollup: a module bundler for JavaScript to bundle and build the JavaScript and TypeScript code
- Lerna: a tool for managing JavaScript projects with multiple packages
- Karma: a test runner for JavaScript that executes tests in multiple real browsers or browser emulators

libpq
libpq is keg-only, which means it was not symlinked into /opt/homebrew,
because conflicts with postgres formula.
If you need to have libpq first in your PATH, run:
echo 'export PATH="/opt/homebrew/opt/libpq/bin:$PATH"' >> ~/.zshrc
For compilers to find libpq you may need to set:
export LDFLAGS="-L/opt/homebrew/opt/libpq/lib"
export CPPFLAGS="-I/opt/homebrew/opt/libpq/include"
このスクラップは2023/12/02にクローズされました