Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

升級 rails 7.1 + ruby 3.2 #512

Closed
marsz opened this issue Nov 15, 2023 · 32 comments
Closed

升級 rails 7.1 + ruby 3.2 #512

marsz opened this issue Nov 15, 2023 · 32 comments

Comments

@marsz
Copy link
Member

marsz commented Nov 15, 2023

https://railsdiff.org/6.0.6.1/7.1.2

@marsz
Copy link
Member Author

marsz commented Nov 15, 2023

@phrase5036 test

@marsz
Copy link
Member Author

marsz commented Nov 15, 2023

@phrase5036 test2

@marsz
Copy link
Member Author

marsz commented Nov 16, 2023

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

@marsz
Copy link
Member Author

marsz commented Nov 16, 2023

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

@phrase5036
Copy link

phrase5036 commented Nov 16, 2023

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

tyr 開 rails71 分支

  • ruby-version 3.2
  • gemspec 7.1
  • bundle update
  • rake spec

template 開 rails71 分支

  • update tyr commit from tyr/rails71
  • ruby-version 3.2
  • gemfile 7.1
  • bundle update
  • rake spec

是這樣對吧嗎?

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

@marsz
Copy link
Member Author

marsz commented Nov 16, 2023

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

@phrase5036
Copy link

@marsz

@phrase5036
Copy link

@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
Copy link
Member Author

marsz commented Nov 18, 2023

@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
Copy link

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

@marsz
Copy link
Member Author

marsz commented Nov 18, 2023

@phrase5036 rvm 有更新到 master 嗎?

rvm get master

@phrase5036
Copy link

@marsz 我是 rvm get stable

@marsz
Copy link
Member Author

marsz commented Nov 18, 2023

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

@phrase5036
Copy link

@marsz 好哦,感謝

@marsz
Copy link
Member Author

marsz commented Nov 18, 2023

@phrase5036 我的筆電裝成功了

看起來 rvm get master 是關鍵

@phrase5036
Copy link

phrase5036 commented Nov 18, 2023

@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
Copy link
Member Author

marsz commented Nov 18, 2023

@phrase5036

rbenv/ruby-build#1938 (comment)
感覺是跟 XCode 有關

@phrase5036
Copy link

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

@marsz
Copy link
Member Author

marsz commented Nov 18, 2023

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

@phrase5036
Copy link

phrase5036 commented Nov 18, 2023

@marsz 今日回報

bundle install and bundle update 已解決 dependency 的問題,bundle install & update works.
截圖 2023-11-19 上午3 36 03

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

@phrase5036
Copy link

@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
Copy link
Member Author

marsz commented Nov 20, 2023

https://d.pr/v/cbSXZz

@marsz
Copy link
Member Author

marsz commented Nov 20, 2023

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

@marsz
Copy link
Member Author

marsz commented Nov 20, 2023

@marsz
Copy link
Member Author

marsz commented Nov 20, 2023

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

@phrase5036
Copy link

@marsz 修復紀錄

factory_bot_rails 需要降版,否則啟動會有錯誤
thoughtbot/factory_bot_rails#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
rails/rails#35051 (comment)

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
Copy link

phrase5036 commented Nov 20, 2023

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

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

  • Tyr::Notification object_id 跟 ActiveRecord 衝突
    https://phrase.d.pr/i/aluOqC/kLXxR2ViZ9
    rspec spec/contexts/tyr/notifications/read_context_spec.rb:7
    rspec spec/contexts/tyr/notifications/read_all_context_spec.rb:9
    rspec spec/requests/tyr/admin/amoebas_controller_spec.rb:7
    rspec spec/requests/tyr/admin/line_items_controller_spec.rb:35
    rspec spec/requests/tyr/admin/line_items_controller_spec.rb:6
    rspec spec/models/concerns/tyr/notifications_concern_spec.rb:11
    rspec spec/models/tyr/notification_spec.rb:25
    rspec spec/models/tyr/notification_spec.rb:29
    rspec spec/contexts/tyr/notifications/notify_context_spec.rb:8

  • attr_json :test_attr_datetime, 沒被定義成功
    https://phrase.d.pr/i/iONnr0/qXvaTxXpUJ
    rspec spec/models/concerns/tyr/attr_json_concern_spec.rb:5

  • new_tyr_comment_form_for 底下的 f.input :commenter_name 錯誤
    https://phrase.d.pr/i/a73Klx/TuNzszytLm
    rspec spec/requests/categories_controller_spec.rb:13

  • 錯誤在 Tyr::DeliverFilterConcern#mail
    https://phrase.d.pr/i/KiKb5V/rdehVoVZ1x
    rspec spec/mailers/tyr/devise_base_mailer_spec.rb:12
    rspec spec/mailers/tyr/devise_base_mailer_spec.rb:18
    rspec spec/mailers/tyr/devise_base_mailer_spec.rb:24
    rspec spec/mailers/tyr/devise_base_mailer_spec.rb:6
    rspec spec/mailers/tyr/devise_base_mailer_spec.rb:30

  • 已經確定有加 authorizable_ransackable_attributes,但還是噴 ransackable_attributes 相關的錯誤
    https://phrase.d.pr/i/AqSOl7/aCRLbLxKkN
    rspec spec/requests/tyr/admin/revisions_controller_spec.rb:9

  • Category 不知道為什麼跟欄位 types 有關
    https://phrase.d.pr/i/9o473X/6jRK33p1V2
    rspec spec/models/concerns/tyr/ransackable_concern_spec.rb:76

  • 看不到實際發生 log,不太確定這裡應該會是什麼情況
    https://phrase.d.pr/i/tGJFuy/3K6iaT7VeA
    rspec spec/requests/tyr/linebots_controller_spec.rb:14

@marsz
Copy link
Member Author

marsz commented Nov 21, 2023

@phrase5036

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

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

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

@marsz
Copy link
Member Author

marsz commented Nov 21, 2023

@phrase5036
Copy link

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

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

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

@phrase5036
Copy link

@marsz rails-template PR #516

@marsz marsz closed this as completed Nov 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants