5fpro / rails-template

1 stars 1 forks source link

升級 rails 7.1 + ruby 3.2 #512

Closed marsz closed 9 months ago

marsz commented 9 months ago

https://railsdiff.org/6.0.6.1/7.1.2

marsz commented 9 months ago

@phrase5036 test

marsz commented 9 months ago

@phrase5036 test2

marsz commented 9 months ago

先升級 tyr => https://d.pr/v/VZqlJl 發 PR 給我 branch name: rails71

marsz commented 9 months ago

@phrase5036 上面看完後給我一個你打算開始處理這張票的時間點以及 deadline 看能否今天先給我

phrase5036 commented 9 months ago

@marsz 看完,之前有參考 railsdiff 升級過,我知道怎麼升級。

tyr 開 rails71 分支

template 開 rails71 分支

是這樣對吧嗎?

明天就可以開始處理這件事,不過應該是 bznk 那邊下班後再處理,會分幾天做。一天預計花兩小時。 先抓下週五(11/24)升級完好了,升級有很卡的地方我再回報你。

marsz commented 9 months ago

@phrase5036 對,你先抓 tyr 的時間就好,tyr 過了後, rails-template 大概一兩個小時就可以搞定了 tyr 看能不能抓下週二晚上至少能做到跑 rspec 後,把一些比較好修的問題修掉,難的可以留給我禮拜三一早處理

phrase5036 commented 9 months ago

@marsz 好

phrase5036 commented 9 months ago

@marsz 我電腦連 3.2 都裝不起來 = = 你也是遇到這個問題嗎?

Error running '__rvm_make -j12',
please read /Users/phrase5036/.rvm/log/1700252523_ruby-3.2.2/make.log

There has been an error while running make. Halting the installation.

今天沒進展,明日再戰

marsz commented 9 months ago

@phrase5036 我自己是這樣

rvm install 3.2 --with-openssl-dir=$(brew --prefix)/opt/openssl@3

在這之前要先用 rvm 和 brew 確認一些東西

  1. 首先 rvm 要更新到 master
rvm get master
  1. 看看有沒有安裝 openssl@3 image

  2. 沒有的話就裝一下

brew install openssl
  1. 確認一下有沒有裝好
ls -la $(brew --prefix)/opt/openssl@3

不過我的筆電還沒裝成功 我先來試試看筆電

phrase5036 commented 9 months ago

@marsz 我昨天試製過這一整串了🤣 雖然大部分都說跟 openssl 有關,不過還是 not work for me

marsz commented 9 months ago

@phrase5036 rvm 有更新到 master 嗎?

rvm get master

phrase5036 commented 9 months ago

@marsz 我是 rvm get stable

marsz commented 9 months ago

@phrase5036 用 rvm get master 看看 我後來有做這件事情就成功安裝了

phrase5036 commented 9 months ago

@marsz 好哦,感謝

marsz commented 9 months ago

@phrase5036 我的筆電裝成功了

看起來 rvm get master 是關鍵

phrase5036 commented 9 months ago

@marsz rvm install 3.2 --with-openssl-dir=$(brew --prefix)/opt/openssl@3 error report 留在這

+__rvm_make:0> make -j12
    BASERUBY = /Users/phrase5036/.rvm/rubies/ruby-2.3.3/bin/ruby --disable=gems
    CC = gcc
    LD = ld
    LDSHARED = gcc -dynamiclib
    CFLAGS = -O3 -I/usr/local/opt/libyaml/include -I/usr/local/opt/libksba/include -I/usr/local/opt/readline/include -I/usr/local/opt/zlib/include -I/usr/local/opt/openssl@1.1/include -fdeclspec -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wextra-tokens -Wdeprecated-declarations -Wdivision-by-zero -Wdiv-by-zero -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wshorten-64-to-32 -Wwrite-strings -Wold-style-definition -Wmissing-noreturn -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wunused-variable -Wundef  -fno-common -pipe 
    XCFLAGS = -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fstack-protector-strong -fno-strict-overflow -fvisibility=hidden -DRUBY_EXPORT -I. -I.ext/include/x86_64-darwin22 -I./include -I. -I./enc/unicode/15.0.0 
    CPPFLAGS = -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT   
    DLDFLAGS = -L/usr/local/opt/libyaml/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/zlib/lib -L/usr/local/opt/openssl@1.1/lib -install_name /Users/phrase5036/.rvm/rubies/ruby-3.2.2/lib/libruby.3.2.dylib -compatibility_version 3.2 -current_version 3.2.2  -fstack-protector-strong -framework CoreFoundation  -fstack-protector-strong -framework CoreFoundation  
    SOLIBS =  -lgmp -ldl -lobjc -lpthread 
    LANG = zh_TW.UTF-8
    LC_ALL = 
    LC_CTYPE = 
    MFLAGS = - --jobserver-fds=3,4 -j
    RUSTC = no
    YJIT_RUSTC_ARGS = --crate-name=yjit --crate-type=staticlib --edition=2021 -g -C opt-level=3 -C overflow-checks=on '--out-dir=/Users/phrase5036/.rvm/src/ruby-3.2.2/yjit/target/release/' ./yjit/src/lib.rs
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 12.0.0 (clang-1200.0.32.29)
Target: x86_64-apple-darwin22.5.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
compiling ./main.c
compiling dmydln.c
compiling miniinit.c
compiling dmyext.c
translating probes probes.d
compiling ast.c
compiling bignum.c
compiling class.c
compiling compar.c
compiling compile.c
compiling complex.c
compiling cont.c
compiling debug.c
. ./vm_opts.h
compiling debug_counter.c
compiling dir.c
compiling dln_find.c
In file included from debug.c:27:
./vm_callinfo.h:177:9: error: use of undeclared identifier 'RUBY_FUNCTION_NAME_STRING'
        rp(ci);
        ^
./internal.h:94:72: note: expanded from macro 'rp'
#define rp(obj) rb_obj_info_dump_loc((VALUE)(obj), __FILE__, __LINE__, RUBY_FUNCTION_NAME_STRING)
                                                                       ^
compiling encoding.c
compiling enum.c
In file included from debug.c:27:
./vm_callinfo.h:218:16: error: use of undeclared identifier 'RUBY_FUNCTION_NAME_STRING'
    if (debug) rp(ci);
               ^
./internal.h:94:72: note: expanded from macro 'rp'
#define rp(obj) rb_obj_info_dump_loc((VALUE)(obj), __FILE__, __LINE__, RUBY_FUNCTION_NAME_STRING)
                                                                       ^
2 errors generated.
make: *** [debug.o] Error 1
make: *** Waiting for unfinished jobs....
In file included from compile.c:40:
./vm_callinfo.h:177:9: error: use of undeclared identifier 'RUBY_FUNCTION_NAME_STRING'
        rp(ci);
        ^
./internal.h:94:72: note: expanded from macro 'rp'
#define rp(obj) rb_obj_info_dump_loc((VALUE)(obj), __FILE__, __LINE__, RUBY_FUNCTION_NAME_STRING)
                                                                       ^
In file included from compile.c:40:
./vm_callinfo.h:218:16: error: use of undeclared identifier 'RUBY_FUNCTION_NAME_STRING'
    if (debug) rp(ci);
               ^
./internal.h:94:72: note: expanded from macro 'rp'
#define rp(obj) rb_obj_info_dump_loc((VALUE)(obj), __FILE__, __LINE__, RUBY_FUNCTION_NAME_STRING)
                                                                       ^
2 errors generated.
make: *** [compile.o] Error 1
+__rvm_make:0> return 2

最後裝上電腦的做法是 Ref

brew install ruby
rvm mount /usr/local/Cellar/ruby/3.2.2_1
rvm use ext-ruby-3.2.2-re51014f9c0
ruby -v
# ruby 3.2.2 (2023-03-30 revision e51014f9c0) [x86_64-darwin22]
marsz commented 9 months ago

@phrase5036

https://github.com/rbenv/ruby-build/discussions/1938#discussioncomment-2213924 感覺是跟 XCode 有關

phrase5036 commented 9 months ago

@marsz 有可能,但我OSX13已經是最新的xcode。如果要再升要先升 OSX

marsz commented 9 months ago

@phrase5036 好吧 你先繼續走下去 回頭再來處理安裝問題

phrase5036 commented 9 months ago

@marsz 今日回報

bundle install and bundle update 已解決 dependency 的問題,bundle install & update works.

截圖 2023-11-19 上午3 36 03

目前開始跑 rake spec 處理 railsdiff 及修正相關問題了

phrase5036 commented 9 months ago
phrase5036 commented 9 months ago

@marsz 幫我跑看看這個分支 https://github.com/5fpro/tyr/tree/rails71

(tyr) git fetch
(tyr) git checkout rails 71
(tyr) rvm use 3.2.2
(tyr) bundle install
(tyr) bundle exec rake spec 

目前死在 uninitialized constant TyrSetting,還沒有找到解決方法,原因未知。

截圖 2023-11-20 下午3 26 19
marsz commented 9 months ago

https://d.pr/v/cbSXZz

marsz commented 9 months ago

https://d.pr/v/5S37PQ

marsz commented 9 months ago

@phrase5036

https://d.pr/v/BWTBSW

https://blog.niclin.tw/2020/02/24/when-to-use-freeze-in-ruby/ https://www.fastruby.io/blog/ruby-3-i18n-gem-and-beyond.html https://github.com/5fpro/bznk/issues/1005#issuecomment-1151058318 https://github.com/ruby-i18n/i18n/issues/658

走了很多條路,我可能要後天才有空處理 I18n 這個問題 你先解其他 bug

marsz commented 9 months ago

https://github.com/5fpro/tyr/pull/270/files 這是之前升級的 PR ,可以參考部分

phrase5036 commented 9 months ago

@marsz 修復紀錄

factory_bot_rails 需要降版,否則啟動會有錯誤 https://github.com/thoughtbot/factory_bot_rails/issues/433

config.action_controller.raise_on_missing_callback_actions = false https://www.shakacode.com/blog/rails-adds-ability-to-raise-error-on-missing-callback-actions/

Time#to_s -> Time#to_fs https://hayford.dev/this-week-in-rails-wrapped-an-overview-of-rails-7-1-features-part-i/#09-to_fsformat-replaced-to_sformat

測試修正紀錄

rspec spec/requests/tyr/edms_controller_spec.rb:12 https://phrase.d.pr/i/2IE1z0/4VFFHVf47n https://github.com/rails/rails/issues/35051#issuecomment-457745829

rspec spec/values/tappay/invoice_spec.rb:28 https://phrase.d.pr/i/YrtDrv/bsF6xwaet8

rspec spec/requests/tyr/admin/transaction_logs_controller_spec.rb:8 https://phrase.d.pr/i/YN910U/rzU5HLKZpS

rspec spec/requests/tyr/linebots_controller_spec.rb:14 https://phrase.d.pr/i/5DUf2w/MFH2EDpMeC PS. 這條可能不是這樣修,我感覺是沒 follow_redirect!,但沒想通為何先前測試能過。

rspec spec/requests/tyr/users/confirmations_controller_spec.rb:9 https://phrase.d.pr/i/xJ7bkW/YsjMPeUceW rspec spec/models/concerns/tyr/taggable_spec.rb:9 https://phrase.d.pr/i/VTHuKb/K2WsAvs1Pw factoryies/tyr_categories.rb、factoryies/tyr_user.rb,位置不太一樣,手動加入 require 暫時解決問題

phrase5036 commented 9 months ago

@marsz 剩餘19條 error 未修正,總共七大類

測試未修正,這些我有稍微找一下,但感覺特難修。所以列出來跟你討論看看

marsz commented 9 months ago

@phrase5036

linebots_controller => https://d.pr/v/YmL7uK

https://d.pr/v/94WZO7

我還沒推,推完會再跟你說

marsz commented 9 months ago

@phrase5036 已推

https://d.pr/v/WtqGyX

https://d.pr/v/0PbilY

phrase5036 commented 9 months ago

@marsz tyr 補了一個 commit,跑 rails-template 的時候會壞掉

截圖 2023-11-22 下午1 08 10

https://github.com/5fpro/tyr/commit/10689fd74037f114cb9893d9993f1a9ab8ccb4a1

phrase5036 commented 9 months ago

@marsz rails-template PR https://github.com/5fpro/rails-template/pull/516