提示:为什么标题限定Mac M1上,因为再加入前团队说是没法正确配置,而我也是第一次做
最近由于一些原因换了工作,需要接触Ruby语言及框架,以及Cypress用于前端End-to-End和接口测试。记录以备后面的人用或者遇到相同情况的人参考
uname -a
Darwin EFVCDXLC5 21.5.0 Darwin Kernel Version 21.5.0: Tue Apr 26 21:08:37 PDT 2022; root:xnu-8020.121.3~4/RELEASE_ARM64_T6000 arm64
Hardware Overview:
Model Name: MacBook Pro
Model Identifier: MacBookPro18,2
Chip: Apple M1 Max
Total Number of Cores: 10 (8 performance and 2 efficiency)
Memory: 32 GB
System Firmware Version: 7459.121.3
OS Loader Version: 7459.121.3
Hardware UUID: 8220F119-E329-5FAB-84E2-95D9D3DA1111
Provisioning UDID: 00006001-001A51483CEB999E
Activation Lock Status: Disabled
kielin@EFVCDXLC5 project1 % gem -v
3.1.6
kielin@EFVCDXLC5 project1 % bundle -v
Bundler version 1.17.3
kielin@EFVCDXLC5 project1 % ruby -v
ruby 2.7.6p219 (2022-04-12 revision c9c2245c0a) [arm64-darwin21]
kielin@EFVCDXLC5 project1 % openssl version
OpenSSL 1.1.1q 5 Jul 2022
# Install rbenv
brew install rbenv
# Initialise rbenv
rbenv init
#then verify rbenv
curl -fsSL https://github.com/rbenv/rbenv-installer/raw/main/bin/rbenv-doctor|bash
# Install openssl 1.1
brew install openssl@1.1
# Verify it
openssl version
# check installed path
which openssl
/opt/homebrew/opt/openssl@1.1/bin/openssl
add environment $PATH in file ~/.zshrc or profile if you are using bash
export PATH=/opt/homebrew/bin:$PATH
export PATH="/opt/homebrew/opt/openssl@1.1/bin:$PATH"
export PATH="/opt/homebrew/sbin:$PATH"
eval "$(rbenv init - zsh)"
export PATH=~/Desktop/Works/project1/lib/config/driver:$PATH
!!! 需要注意的是这步骤
RUBY_CONFIGURE_OPTS="--with-openssl-dir=/opt/homebrew/opt/openssl@1.1" rbenv install 2.7.6
gem install bundler:1.17.3
# Install packages
bundle install
# original is 2.3.7
2.7.6
<directory>/project1/lib/config/driver
Download super-TEST-CREDENTIALS-V2.yml and copy it into project1/lib/config
Download Chrome webdriver which match your local chrome version from http://chromedriver.storage.googleapis.com/index.html and copy it into project1/lib/config/driver
Run ‘rspec’ and click allow in the popup window
Go to System Preference - Security&Privacy - General, click ‘Allow Anyway’ for “chromedriver”
/Users/kielin/.rvm/src/ruby-2.7.6/lib/rubygems/core_ext/kernel_require.rb:83:in `require': cannot load such file -- openssl (LoadError)
from /Users/kielin/.rvm/src/ruby-2.7.6/lib/rubygems/core_ext/kernel_require.rb:83:in `require'
from /Users/kielin/.rvm/src/ruby-2.7.6/lib/rubygems/specification.rb:2430:in `to_ruby'
from ./tool/rbinstall.rb:846:in `block (2 levels) in install_default_gem'
from ./tool/rbinstall.rb:279:in `open_for_install'
from ./tool/rbinstall.rb:845:in `block in install_default_gem'
from ./tool/rbinstall.rb:835:in `each'
from ./tool/rbinstall.rb:835:in `install_default_gem'
from ./tool/rbinstall.rb:799:in `block in <main>'
from ./tool/rbinstall.rb:950:in `block in <main>'
from ./tool/rbinstall.rb:947:in `each'
from ./tool/rbinstall.rb:947:in `<main>'
make: *** [do-install-nodoc] Error 1
+__rvm_make:0> return 2
net-http-persistent-3.0.0 requires ruby version ~> 2.1, which is incompatible with the current version, ruby 3.0.4p208
!!!还不能正常在VS Code中debug, 有可以运行的可以留言
我试了以下配置都不能正确的直接F5调试Ruby项目:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
// {
// "name": "RSpec - all",
// "type": "Ruby",
// "request": "launch",
// "cwd": "${workspaceRoot}",
// "program": "${workspaceRoot}/bin/rspec",
// "args": [
// "-I",
// "${workspaceRoot}"
// ]
// },
{
"name": "RSpec",
"type": "Ruby",
"request": "launch",
"cwd": "${workspaceRoot}",
"program": "${workspaceRoot}/bin/bundle",
"args": [
"exec",
"rspec",
"${file}"
]
},
]
}
https://github.com/rubyide/vscode-ruby/blob/main/docs/debugger.md
In this extension, we implement ruby debug ide protocol to allow VS Code to communicate with ruby debug, it requires ruby-debug-ide
to be installed on your machine. This is also how RubyMine/NetBeans does by default.
jruby
, ruby_18
, mingw_18
), run gem install ruby-debug-ide
.ruby_19
, mingw_19
), run gem install ruby-debug-ide
. Make sure ruby-debug-base19x
is installed together with ruby-debug-ide
.gem install ruby-debug-ide
gem install debase
(or gem install byebug
)https://github.com/rubyide/vscode-ruby/wiki/5.-Example-configurations#rails