问:
Only one version of Ruby works when multiple versions are installed
Edit 1: Another person reported similar issue with asdf.

Edit 2: Another reported similar issue.

Edit 3: I uninstalled rvm, installed rvm, installed ruby and rails, and attempted some activities.

Edit 4: Another person mentioned that it's caused by the line I put into .zshrc (or .bash_profile/.bashrc):
RUBYOPT: "-W:no-deprecated -W:no-experimental".

Problem: I have two projects, one using ruby-2.7.0, the other using ruby-2.6.5.

Every time I installed over two versions of ruby, only one version ends up working (2.7.0). The bundle as well as gem commands on the other will no longer work but give a Traceback....(RuntimeError).

Most Recent Attempt and Console Outputs:
Console output flow is roughly:

Uninstall rvm

Install rvm

Install ruby-2.7.0

Install ruby-2.6.5

For ruby-2.7.0, install rails

For ruby-2.6.5, install rails

Everything working alright so far

Append export PATH="$PATH:$HOME/.rvm/bin" to ~/.zshrc

Still working alright

Did echo "export RUBYOPT='-W:no-deprecated -W:no-experimental'" >> ~/.zshrc; source ~/.zshrc

Started noticing the problem again

ruby-2.6.5 does not work; ruby-2.7.0 still works

```# UNINSTALL RVM
(base) ➜  ~ rvm -v
rvm 1.29.9 (latest) by Michal Papis, Piotr Kuczynski, Wayne E. Seguin [https://rvm.io]
(base) ➜  ~ which ruby
/Users/nahua/.rvm/rubies/ruby-2.6.5/bin/ruby
(base) ➜  ~ which rails
/usr/bin/rails
(base) ➜  ~ rbenv
zsh: command not found: rbenv
(base) ➜  ~

(base) ➜  ~ rvm implode
Are you SURE you wish for rvm to implode?
This will recursively remove /Users/nahua/.rvm and other rvm traces?
(anything other than 'yes' will cancel) > yes
Removing rvm-shipped binaries (rvm-prompt, rvm, rvm-sudo rvm-shell and rvm-auto-ruby)
Removing rvm wrappers in /Users/nahua/.rvm/bin
Hai! Removing /Users/nahua/.rvm
/Users/nahua/.rvm has been removed.

Note you may need to manually remove /etc/rvmrc and ~/.rvmrc if they exist still.
Please check all .bashrc .bash_profile .profile and .zshrc for RVM source lines and delete or comment out if this was a Per-User installation.
Also make sure to remove `rvm` group if this was a system installation.
Finally it might help to relogin / restart if you want to have fresh environment (like for installing RVM again).

(base) ➜  ~ gem uninstall rvm
Traceback (most recent call last):
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby: invalid option -:  (-h will show valid options) (RuntimeError)
(base) ➜  ~ which ruby
/usr/bin/ruby
(base) ➜  ~ rvm -v
cat: /Users/nahua/.rvm/VERSION: No such file or directory
__rvm_initialize:source:4: no such file or directory: /Users/nahua/.rvm/scripts/base
cat: /Users/nahua/.rvm/VERSION: No such file or directory
rvm  () by Michal Papis, Piotr Kuczynski, Wayne E. Seguin [https://rvm.io]

# COMMENT OFF ALL RVM LINES IN THE FOLLOWING FILES
(base) ➜  ~ subl .bashrc
(base) ➜  ~ subl .profile
(base) ➜  ~ subl .zshrc
(base) ➜  ~ subl .bash_profile
(base) ➜  ~ subl .zlogin
(base) ➜  ~ subl /etc/profile # nothing there
(base) ➜  ~ sudo vim /etc/profile # nothing there
Password:
(base) ➜  ~ exit

# RESTART TERMINAL
(base) ➜  ~ ruby -v
ruby 2.6.3p62 (2019-04-16 revision 67580) [universal.x86_64-darwin19]
(base) ➜  ~ which ruby
/usr/bin/ruby
(base) ➜  ~ which gem
/usr/bin/gem
(base) ➜  ~ which bundle
/usr/bin/bundle
(base) ➜  ~ clear
(base) ➜  ~ rvm list
zsh: command not found: rvm
(base) ➜  ~ rbenv versions
zsh: command not found: rbenv

# INSTALL RVM
(base) ➜  ~ gpg --keyserver hkp://pool.sks-keyservers.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
Warning: Failed to set locale category LC_NUMERIC to en_DE.
Warning: Failed to set locale category LC_TIME to en_DE.
Warning: Failed to set locale category LC_COLLATE to en_DE.
Warning: Failed to set locale category LC_MONETARY to en_DE.
Warning: Failed to set locale category LC_MESSAGES to en_DE.
gpg: key 105BD0E739499BDB: "Piotr Kuczynski <piotr.kuczynski@gmail.com>" not changed
gpg: key 3804BB82D39DC0E3: "Michal Papis (RVM signing) <mpapis@gmail.com>" not changed
gpg: Total number processed: 2
gpg:              unchanged: 2
(base) ➜  ~ \curl -sSL https://get.rvm.io | bash -s stable --ruby
Downloading https://github.com/rvm/rvm/archive/1.29.9.tar.gz
Downloading https://github.com/rvm/rvm/releases/download/1.29.9/1.29.9.tar.gz.asc
Warning: Failed to set locale category LC_NUMERIC to en_DE.
Warning: Failed to set locale category LC_TIME to en_DE.
Warning: Failed to set locale category LC_COLLATE to en_DE.
Warning: Failed to set locale category LC_MONETARY to en_DE.
Warning: Failed to set locale category LC_MESSAGES to en_DE.
gpg: Signature made Wed Jul 10 10:31:02 2019 CEST
gpg:                using RSA key 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
gpg: Good signature from "Piotr Kuczynski <piotr.kuczynski@gmail.com>" [unknown]
gpg: WARNING: This key is not certified with a trusted signature!
gpg:          There is no indication that the signature belongs to the owner.
Primary key fingerprint: 7D2B AF1C F37B 13E2 069D  6956 105B D0E7 3949 9BDB
GPG verified '/Users/nahua/.rvm/archives/rvm-1.29.9.tgz'
Installing RVM to /Users/nahua/.rvm/
    RVM PATH line found in /Users/nahua/.mkshrc /Users/nahua/.profile /Users/nahua/.bashrc /Users/nahua/.zshrc.
    RVM sourcing line found in /Users/nahua/.profile /Users/nahua/.bash_profile /Users/nahua/.zlogin.
Installation of RVM in /Users/nahua/.rvm/ is almost complete:

  * To start using RVM you need to run `source /Users/nahua/.rvm/scripts/rvm`
    in all your open shell windows, in rare cases you need to reopen all shell windows.
Thanks for installing RVM
Please consider donating to our open collective to help us maintain RVM.

  Donate: https://opencollective.com/rvm/donate

Ruby enVironment Manager 1.29.9 (latest) (c) 2009-2017 Michal Papis, Piotr Kuczynski, Wayne E. Seguin

Searching for binary rubies, this might take some time.
No binary rubies available for: osx/10.15/x86_64/ruby-2.6.3.
Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies.
Checking requirements for osx.
Certificates bundle '/usr/local/etc/openssl@1.1/cert.pem' is already up to date.
Requirements installation successful.
Installing Ruby from source to: /Users/nahua/.rvm/rubies/ruby-2.6.3, this may take a while depending on your cpu(s)...
ruby-2.6.3 - #downloading ruby-2.6.3, this may take a while depending on your connection...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 13.8M  100 13.8M    0     0  4529k      0  0:00:03  0:00:03 --:--:-- 4529k
ruby-2.6.3 - #extracting ruby-2.6.3 to /Users/nahua/.rvm/src/ruby-2.6.3.....
ruby-2.6.3 - #configuring.......................................................................
ruby-2.6.3 - #post-configuration.
ruby-2.6.3 - #compiling.....................................................................
ruby-2.6.3 - #installing...........
ruby-2.6.3 - #making binaries executable..
ruby-2.6.3 - #downloading rubygems-3.0.6
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  866k  100  866k    0     0  3437k      0 --:--:-- --:--:-- --:--:-- 3437k
No checksum for downloaded archive, recording checksum in user configuration.
ruby-2.6.3 - #extracting rubygems-3.0.6.....
ruby-2.6.3 - #removing old rubygems........
$LANG was empty, setting up LANG=en_US.US-ASCII, if it fails again try setting LANG to something sane and try again.
ruby-2.6.3 - #installing rubygems-3.0.6...............................................
ruby-2.6.3 - #gemset created /Users/nahua/.rvm/gems/ruby-2.6.3@global
ruby-2.6.3 - #importing gemset /Users/nahua/.rvm/gemsets/global.gems......................................................-
ruby-2.6.3 - #generating global wrappers.......
ruby-2.6.3 - #gemset created /Users/nahua/.rvm/gems/ruby-2.6.3
ruby-2.6.3 - #importing gemsetfile /Users/nahua/.rvm/gemsets/default.gems evaluated to empty gem list
ruby-2.6.3 - #generating default wrappers.......
ruby-2.6.3 - #adjusting #shebangs for (gem irb erb ri rdoc testrb rake).
Install of ruby-2.6.3 - #complete
Ruby was built without documentation, to build it run: rvm docs generate-ri
Creating alias default for ruby-2.6.3....

  * To start using RVM you need to run `source /Users/nahua/.rvm/scripts/rvm`
    in all your open shell windows, in rare cases you need to reopen all shell windows.
(base) ➜  ~ source /Users/nahua/.rvm/scripts/rvm
source /Users/nahua/.rvm/scripts/rvm
(base) ➜  ~ rvm
Ruby enVironment Manager 1.29.9 (latest) (c) 2009-2017 Michal Papis, Piotr Kuczynski, Wayne E. Seguin

For additional documentation please visit https://rvm.io

(base) ➜  ~ echo $PATH
/Users/nahua/.rvm/gems/ruby-2.6.3/bin:/Users/nahua/.rvm/gems/ruby-2.6.3@global/bin:/Users/nahua/.rvm/rubies/ruby-2.6.3/bin:/opt/anaconda3/bin:/opt/anaconda3/condabin:/Users/nahua/bin:/usr/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/nahua/.rvm/bin
(base) ➜  ~ rvm -v
rvm 1.29.9 (latest) by Michal Papis, Piotr Kuczynski, Wayne E. Seguin [https://rvm.io]
(base) ➜  ~ rvm list
=* ruby-2.6.3 [ x86_64 ]

# => - current
# =* - current && default
#  * - default

(base) ➜  ~ rvm install 2.7.0
Searching for binary rubies, this might take some time.
No binary rubies available for: osx/10.15/x86_64/ruby-2.7.0.
Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies.
Checking requirements for osx.
Certificates bundle '/usr/local/etc/openssl@1.1/cert.pem' is already up to date.
Requirements installation successful.
Installing Ruby from source to: /Users/nahua/.rvm/rubies/ruby-2.7.0, this may take a while depending on your cpu(s)...
ruby-2.7.0 - #downloading ruby-2.7.0, this may take a while depending on your connection...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 14.0M  100 14.0M    0     0  4616k      0  0:00:03  0:00:03 --:--:-- 4616k
No checksum for downloaded archive, recording checksum in user configuration.
ruby-2.7.0 - #extracting ruby-2.7.0 to /Users/nahua/.rvm/src/ruby-2.7.0 - please wait
ruby-2.7.0 - #configuring - please wait
ruby-2.7.0 - #post-configuration - please wait
ruby-2.7.0 - #compiling - please wait
ruby-2.7.0 - #installing - please wait
ruby-2.7.0 - #making binaries executable - please wait
Installed rubygems 3.1.2 is newer than 3.0.6 provided with installed ruby, skipping installation, use --force to force installation.
ruby-2.7.0 - #gemset created /Users/nahua/.rvm/gems/ruby-2.7.0@global
ruby-2.7.0 - #importing gemset /Users/nahua/.rvm/gemsets/global.gems - please wait
ruby-2.7.0 - #generating global wrappers - please wait
ruby-2.7.0 - #gemset created /Users/nahua/.rvm/gems/ruby-2.7.0
ruby-2.7.0 - #importing gemsetfile /Users/nahua/.rvm/gemsets/default.gems evaluated to empty gem list
ruby-2.7.0 - #generating default wrappers - please wait
ruby-2.7.0 - #adjusting #shebangs for (gem irb erb ri rdoc testrb rake).
Install of ruby-2.7.0 - #complete
Ruby was built without documentation, to build it run: rvm docs generate-ri
(base) ➜  ~ rvm list
 * ruby-2.6.3 [ x86_64 ]
=> ruby-2.7.0 [ x86_64 ]

# => - current
# =* - current && default
#  * - default

(base) ➜  ~ gem -v
3.1.2
(base) ➜  ~ bundle -v
Bundler version 2.1.2
(base) ➜  ~ rvm use 2.6.3
Using /Users/nahua/.rvm/gems/ruby-2.6.3
(base) ➜  ~ ruby -v
ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-darwin19]
(base) ➜  ~ gem -v
3.0.6
(base) ➜  ~ bundle -v
Bundler version 1.17.3
(base) ➜  ~ rvm use 2.7.0
Using /Users/nahua/.rvm/gems/ruby-2.7.0
(base) ➜  ~ ruby -v
ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-darwin19]
(base) ➜  ~ gem -v
3.1.2
(base) ➜  ~ bundle -v
Bundler version 2.1.2
(base) ➜  ~ rvm install 2.6.5
Searching for binary rubies, this might take some time.
No binary rubies available for: osx/10.15/x86_64/ruby-2.6.5.
Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies.
Checking requirements for osx.
Certificates bundle '/usr/local/etc/openssl@1.1/cert.pem' is already up to date.
Requirements installation successful.
Installing Ruby from source to: /Users/nahua/.rvm/rubies/ruby-2.6.5, this may take a while depending on your cpu(s)...
ruby-2.6.5 - #downloading ruby-2.6.5, this may take a while depending on your connection...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 13.4M  100 13.4M    0     0  9377k      0  0:00:01  0:00:01 --:--:-- 9370k
No checksum for downloaded archive, recording checksum in user configuration.
ruby-2.6.5 - #extracting ruby-2.6.5 to /Users/nahua/.rvm/src/ruby-2.6.5 - please wait
ruby-2.6.5 - #configuring - please wait
ruby-2.6.5 - #post-configuration - please wait
ruby-2.6.5 - #compiling - please wait
ruby-2.6.5 - #installing - please wait
ruby-2.6.5 - #making binaries executable - please wait
ruby-2.6.5 - #downloading rubygems-3.0.6
ruby-2.6.5 - #extracting rubygems-3.0.6 - please wait
ruby-2.6.5 - #removing old rubygems - please wait
$LANG was empty, setting up LANG=en_US.US-ASCII, if it fails again try setting LANG to something sane and try again.
ruby-2.6.5 - #installing rubygems-3.0.6 - please wait
ruby-2.6.5 - #gemset created /Users/nahua/.rvm/gems/ruby-2.6.5@global
ruby-2.6.5 - #importing gemset /Users/nahua/.rvm/gemsets/global.gems - please wait
ruby-2.6.5 - #generating global wrappers - please wait
ruby-2.6.5 - #gemset created /Users/nahua/.rvm/gems/ruby-2.6.5
ruby-2.6.5 - #importing gemsetfile /Users/nahua/.rvm/gemsets/default.gems evaluated to empty gem list
ruby-2.6.5 - #generating default wrappers - please wait
ruby-2.6.5 - #adjusting #shebangs for (gem irb erb ri rdoc testrb rake).
Install of ruby-2.6.5 - #complete
Ruby was built without documentation, to build it run: rvm docs generate-ri
(base) ➜  ~ ruby -v
ruby 2.6.5p114 (2019-10-01 revision 67812) [x86_64-darwin19]
(base) ➜  ~ gem -v
3.0.6
(base) ➜  ~ bundle -v
Bundler version 1.17.3
(base) ➜  ~ gem install rails
...
IGNORED DUE TO CHARACTER LIMIT ON STACKOVERFLOW
...
Successfully installed concurrent-ruby-1.1.5

HEADS UP! i18n 1.1 changed fallbacks to exclude default locale.
But that may break your application.

If you are upgrading your Rails application from an older version of Rails:

Please check your Rails app for 'config.i18n.fallbacks = true'.
If you're using I18n (>= 1.1.0) and Rails (< 5.2.2), this should be
'config.i18n.fallbacks = [I18n.default_locale]'.
If not, fallbacks will be broken in your app by I18n 1.1.x.

If you are starting a NEW Rails application, you can ignore this notice.

For more info see:
https://github.com/svenfuchs/i18n/releases/tag/v1.1.0
...
IGNORED DUE TO CHARACTER LIMIT ON STACKOVERFLOW
...
Done installing documentation for concurrent-ruby, i18n, thread_safe, tzinfo, zeitwerk, activesupport, rack, rack-test, mini_portile2, nokogiri, crass, loofah, rails-html-sanitizer, rails-dom-testing, builder, erubi, actionview, actionpack, activemodel, activerecord, globalid, activejob, mini_mime, mail, actionmailer, nio4r, websocket-extensions, websocket-driver, actioncable, mimemagic, marcel, activestorage, actionmailbox, actiontext, thor, method_source, railties, sprockets, sprockets-rails, rails after 39 seconds
40 gems installed
(base) ➜  ~ rails -v
Rails 6.0.2.1
(base) ➜  ~ rvm use 2.6.5
Using /Users/nahua/.rvm/gems/ruby-2.6.5
(base) ➜  ~ ruby -v
ruby 2.6.5p114 (2019-10-01 revision 67812) [x86_64-darwin19]
(base) ➜  ~ gem install rails
...
IGNORED DUE TO CHARACTER LIMIT ON STACKOVERFLOW
...
Successfully installed concurrent-ruby-1.1.5

HEADS UP! i18n 1.1 changed fallbacks to exclude default locale.
But that may break your application.

If you are upgrading your Rails application from an older version of Rails:

Please check your Rails app for 'config.i18n.fallbacks = true'.
If you're using I18n (>= 1.1.0) and Rails (< 5.2.2), this should be
'config.i18n.fallbacks = [I18n.default_locale]'.
If not, fallbacks will be broken in your app by I18n 1.1.x.

If you are starting a NEW Rails application, you can ignore this notice.

For more info see:
https://github.com/svenfuchs/i18n/releases/tag/v1.1.0

...
IGNORED DUE TO CHARACTER LIMIT ON STACKOVERFLOW
...
Done installing documentation for concurrent-ruby, i18n, thread_safe, tzinfo, zeitwerk, activesupport, rack, rack-test, mini_portile2, nokogiri, crass, loofah, rails-html-sanitizer, rails-dom-testing, builder, erubi, actionview, actionpack, activemodel, activerecord, globalid, activejob, mini_mime, mail, actionmailer, nio4r, websocket-extensions, websocket-driver, actioncable, mimemagic, marcel, activestorage, actionmailbox, actiontext, thor, method_source, railties, sprockets, sprockets-rails, rails after 34 seconds
40 gems installed
(base) ➜  ~ ruby -v
ruby 2.6.5p114 (2019-10-01 revision 67812) [x86_64-darwin19]
(base) ➜  ~ rvm list
 * ruby-2.6.3 [ x86_64 ]
=> ruby-2.6.5 [ x86_64 ]
   ruby-2.7.0 [ x86_64 ]

# => - current
# =* - current && default
#  * - default

(base) ➜  ~ rvm use 2.7.0
Using /Users/nahua/.rvm/gems/ruby-2.7.0
(base) ➜  ~ ruby -v
ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-darwin19]
(base) ➜  ~ rvm use 2.6.5
Using /Users/nahua/.rvm/gems/ruby-2.6.5
(base) ➜  ~ ruby -v
ruby 2.6.5p114 (2019-10-01 revision 67812) [x86_64-darwin19]
(base) ➜  ~ cd projects/rails/DevcampPortfolio
(base) ➜  DevcampPortfolio git:(portfolio-feature) ✗ cat .ruby-version
2.7.0
(base) ➜  DevcampPortfolio git:(portfolio-feature) ✗ rvm list
 * ruby-2.6.3 [ x86_64 ]
   ruby-2.6.5 [ x86_64 ]
=> ruby-2.7.0 [ x86_64 ]

# => - current
# =* - current && default
#  * - default

(base) ➜  DevcampPortfolio git:(portfolio-feature) ✗ rails c
Warning: the running version of Bundler (2.1.2) is older than the version that created the lockfile (2.1.4). We suggest you to upgrade to the version that created the lockfile by running `gem install bundler:2.1.4`.
Could not find minitest-5.14.0 in any of the sources
Run `bundle install` to install missing gems.
(base) ➜  DevcampPortfolio git:(portfolio-feature) ✗ clear
(base) ➜  DevcampPortfolio git:(portfolio-feature) ✗ which bundle
/Users/nahua/.rvm/rubies/ruby-2.7.0/bin/bundle
(base) ➜  DevcampPortfolio git:(portfolio-feature) ✗ bundle install
Warning: the running version of Bundler (2.1.2) is older than the version that created the lockfile (2.1.4). We suggest you to upgrade to the version that created the lockfile by running `gem install bundler:2.1.4`.
Fetching gem metadata from https://rubygems.org/............
...
### BUNDLE INSTALL...DELETING DUE TO CHARACTER LIMIT ON STACKOVERFLOW
...
Bundle complete! 15 Gemfile dependencies, 67 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
(base) ➜  DevcampPortfolio git:(portfolio-feature) ✗ gem install bundler:2.1.4
Fetching bundler-2.1.4.gem
Successfully installed bundler-2.1.4
Parsing documentation for bundler-2.1.4
Installing ri documentation for bundler-2.1.4
Done installing documentation for bundler after 2 seconds
1 gem installed
(base) ➜  DevcampPortfolio git:(portfolio-feature) ✗ rvm use 2.6.5
Using /Users/nahua/.rvm/gems/ruby-2.6.5
(base) ➜  DevcampPortfolio git:(portfolio-feature) ✗ ruby -v
ruby 2.6.5p114 (2019-10-01 revision 67812) [x86_64-darwin19]
(base) ➜  DevcampPortfolio git:(portfolio-feature) ✗ rvm use 2.7.0
Using /Users/nahua/.rvm/gems/ruby-2.7.0
(base) ➜  DevcampPortfolio git:(portfolio-feature) ✗ ruby -v
ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-darwin19]
(base) ➜  DevcampPortfolio git:(portfolio-feature) ✗ rails c
Warning: the running version of Bundler (2.1.2) is older than the version that created the lockfile (2.1.4). We suggest you to upgrade to the version that created the lockfile by running `gem install bundler:2.1.4`.
Running via Spring preloader in process 16581
Loading development environment (Rails 6.0.2.1)
2.7.0 :001 > exit
(base) ➜  DevcampPortfolio git:(portfolio-feature) ✗ cd ../../20bn-homepage
(base) ➜  20bn-homepage git:(master) rvm list
 * ruby-2.6.3 [ x86_64 ]
=> ruby-2.6.5 [ x86_64 ]
   ruby-2.7.0 [ x86_64 ]

# => - current
# =* - current && default
#  * - default

(base) ➜  20bn-homepage git:(master) bundle install
You must use Bundler 2 or greater with this lockfile.
(base) ➜  20bn-homepage git:(master) bundle -v
Bundler version 1.17.3
(base) ➜  20bn-homepage git:(master) gem install bundler:2.1.4
Fetching bundler-2.1.4.gem
Successfully installed bundler-2.1.4
Parsing documentation for bundler-2.1.4
Installing ri documentation for bundler-2.1.4
Done installing documentation for bundler after 2 seconds
1 gem installed

(base) ➜  20bn-homepage git:(master) bundle install
You must use Bundler 2 or greater with this lockfile.
(base) ➜  20bn-homepage git:(master) bundle -v
Bundler version 1.17.3
(base) ➜  20bn-homepage git:(master) gem install bundler:2.1.4
Fetching bundler-2.1.4.gem
Successfully installed bundler-2.1.4
Parsing documentation for bundler-2.1.4
Installing ri documentation for bundler-2.1.4
Done installing documentation for bundler after 2 seconds
1 gem installed
(base) ➜  20bn-homepage git:(master) bundle install
...
### BUNDLE INSTALL...DELETING DUE TO CHARACTER LIMIT ON STACKOVERFLOW
...
Bundle complete! 61 Gemfile dependencies, 180 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
Post-install message from postmark:

    ==================
    Thanks for installing the postmark gem. If you don't have an account, please
    sign up at http://postmarkapp.com/.

    Review the README.md for implementation details and examples.
    ==================
  %

(base) ➜  20bn-homepage git:(master) exit
Last login: Wed Jan 22 10:05:43 on ttys001
(base) ➜  ~ rvm list
zsh: command not found: rvm
(base) ➜  ~ echo "source $HOME/.rvm/scripts/rvm" >> ~/.zshrc
(base) ➜  ~ source ~/.zshrc
(base) ➜  ~ rvm list
=* ruby-2.6.3 [ x86_64 ]
   ruby-2.6.5 [ x86_64 ]
   ruby-2.7.0 [ x86_64 ]

# => - current
# =* - current && default
#  * - default

(base) ➜  ~ ruby -v
ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-darwin19]
(base) ➜  ~ cd projects/rails/DevcampPortfolio
(base) ➜  DevcampPortfolio git:(portfolio-feature) ✗ rvm list
 * ruby-2.6.3 [ x86_64 ]
   ruby-2.6.5 [ x86_64 ]
=> ruby-2.7.0 [ x86_64 ]

# => - current
# =* - current && default
#  * - default

(base) ➜  DevcampPortfolio git:(portfolio-feature) ✗ rails c
Warning: the running version of Bundler (2.1.2) is older than the version that created the lockfile (2.1.4). We suggest you to upgrade to the version that created the lockfile by running `gem install bundler:2.1.4`.
Running via Spring preloader in process 26256
Loading development environment (Rails 6.0.2.1)
 :001 > Blog.last
  Blog Load (2.5ms)  SELECT "blogs".* FROM "blogs" ORDER BY "blogs"."id" DESC LIMIT $1  [["LIMIT", 1]]
 => #<Blog id: 12, title: "My great blog title", body: "Lorem ipsum blah blah blah", created_at: "2020-01-21 09:49:26", updated_at: "2020-01-21 09:49:26", slug: "my-great-blog-title">
 :002 > exit
(base) ➜  DevcampPortfolio git:(portfolio-feature) ✗ cd ../../20bn-homepage
(base) ➜  20bn-homepage git:(master) rvm list
 * ruby-2.6.3 [ x86_64 ]
=> ruby-2.6.5 [ x86_64 ]
   ruby-2.7.0 [ x86_64 ]

# => - current
# =* - current && default
#  * - default

(base) ➜  20bn-homepage git:(master) ruby -v
ruby 2.6.5p114 (2019-10-01 revision 67812) [x86_64-darwin19]
(base) ➜  20bn-homepage git:(master) rails c
Loading development environment (Rails 6.0.2.1)
 :001 > exit
(base) ➜  20bn-homepage git:(master) cd ../rails/DevcampPortfolio
(base) ➜  DevcampPortfolio git:(portfolio-feature) ✗ echo "export RUBYOPT='-W:no-deprecated -W:no-experimental'" >> ~/.zshrc
(base) ➜  DevcampPortfolio git:(portfolio-feature) ✗ source ~/.zshrc
(base) ➜  DevcampPortfolio git:(portfolio-feature) ✗ rails c
Warning: the running version of Bundler (2.1.2) is older than the version that created the lockfile (2.1.4). We suggest you to upgrade to the version that created the lockfile by running `gem install bundler:2.1.4`.
Running via Spring preloader in process 26693
Loading development environment (Rails 6.0.2.1)
2.7.0 :001 > exit
(base) ➜  DevcampPortfolio git:(portfolio-feature) ✗ cd ../../20bn-homepage
(base) ➜  20bn-homepage git:(master) ruby -v
Traceback (most recent call last):
ruby: invalid option -:  (-h will show valid options) (RuntimeError)

### COMMENT OFF export RUBYOPT='-W:no-deprecated -W:no-experimental' IN ~/.zshrc AGAIN

(base) ➜  20bn-homepage git:(master) source ~/.zshrc
(base) ➜  20bn-homepage git:(master) ruby -v
Traceback (most recent call last):
ruby: invalid option -:  (-h will show valid options) (RuntimeError)
(base) ➜  20bn-homepage git:(master)
(base) ➜  20bn-homepage git:(master) rvm list
Warning! PATH is not properly set up, /Users/nahua/.rvm/gems/ruby-2.6.5/bin is not at first place.
         Usually this is caused by shell initialization files. Search for PATH=... entries.
         You can also re-add RVM to your profile by running: rvm get stable --auto-dotfiles
         To fix it temporarily in this shell session run: rvm use ruby-2.6.5
         To ignore this error add rvm_silence_path_mismatch_check_flag=1 to your ~/.rvmrc file.
 * ruby-2.6.3 [ x86_64 ]
=> ruby-2.6.5 [ x86_64 ]
   ruby-2.7.0 [ x86_64 ]

# => - current
# =* - current && default
#  * - default

(base) ➜  20bn-homepage git:(master) rvm get stable --auto-dotfiles
...
IGNORED DUE TO STACKOVERFLOW CHARACTER LIMIT
...

RVM reloaded!

(base) ➜  20bn-homepage git:(master) ruby -v
Traceback (most recent call last):
ruby: invalid option -:  (-h will show valid options) (RuntimeError)

(base) ➜  20bn-homepage git:(master) echo $PATH
/Users/nahua/bin:/usr/local/bin:/Users/nahua/.rvm/gems/ruby-2.6.5/bin:/Users/nahua/.rvm/gems/ruby-2.6.5@global/bin:/Users/nahua/.rvm/rubies/ruby-2.6.5/bin:/Users/nahua/.rvm/bin:/Users/nahua/bin:/usr/local/bin:/Users/nahua/bin:/usr/local/bin:/opt/anaconda3/bin:/opt/anaconda3/condabin:/Users/nahua/bin:/usr/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
(base) ➜  20bn-homepage git:(master) rvm reset
Warning! PATH is not properly set up, /Users/nahua/.rvm/gems/ruby-2.6.5/bin is not at first place.
         Usually this is caused by shell initialization files. Search for PATH=... entries.
         You can also re-add RVM to your profile by running: rvm get stable --auto-dotfiles
         To fix it temporarily in this shell session run: rvm use ruby-2.6.5
         To ignore this error add rvm_silence_path_mismatch_check_flag=1 to your ~/.rvmrc file.
(base) ➜  20bn-homepage git:(master) ruby -v
Traceback (most recent call last):
ruby: invalid option -:  (-h will show valid options) (RuntimeError)
(base) ➜  20bn-homepage git:(master) rvm list
 * ruby-2.6.3 [ x86_64 ]
   ruby-2.6.5 [ x86_64 ]
   ruby-2.7.0 [ x86_64 ]

# => - current
# =* - current && default
#  * - default

(base) ➜  20bn-homepage git:(master) source ~/.zshrc
(base) ➜  20bn-homepage git:(master) ruby -v
Traceback (most recent call last):
ruby: invalid option -:  (-h will show valid options) (RuntimeError)
(base) ➜  20bn-homepage git:(master) rvm use ruby-2.6.5
Using /Users/nahua/.rvm/gems/ruby-2.6.5
Traceback (most recent call last):
ruby: invalid option -:  (-h will show valid options) (RuntimeError)
(base) ➜  20bn-homepage git:(master) rvm use 2.7.0
Using /Users/nahua/.rvm/gems/ruby-2.7.0
(base) ➜  20bn-homepage git:(master) ruby -v
ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-darwin19]
```

<p><strong>Original Problem Description:</strong></p>

<p>I have two projects, one using <code>ruby-2.7.0</code>, the other using <code>ruby-2.6.5</code>. </p>

<p>I've just realized there is a weird issue with my Ruby/Rails setup on the latest OS X. Either using <code>rvm</code> or <code>rbenv</code>, every time I installed over two versions of ruby, only one version ends up working (2.7.0). The <code>bundle</code> as well as <code>gem</code> commands on the other will no longer work but give a <code>Traceback....(RuntimeError)</code>.</p>

<p>In the past 6 hours, I have reinstalled <code>rbenv</code>, uninstalled <code>rbenv</code>, installed <code>rvm</code>. I've also tried uninstalling all non-system Ruby versions and Rails as well. Nothing seems to help.</p>

<p>Below is the error shown in my console:</p>

```(base) ➜  ~ rvm list
=* ruby-2.6.5 [ x86_64 ]
   ruby-2.7.0 [ x86_64 ]

# => - current
# =* - current && default
#  * - default

(base) ➜  ~ bundle -v
Traceback (most recent call last):
ruby: invalid option -:  (-h will show valid options) (RuntimeError)
(base) ➜  ~ gem -v
Traceback (most recent call last):
ruby: invalid option -:  (-h will show valid options) (RuntimeError)
(base) ➜  ~ rvm use 2.7.0
Using /Users/nahua/.rvm/gems/ruby-2.7.0
(base) ➜  ~ bundle -v
Bundler version 2.1.4
(base) ➜  ~ rvm use 2.6.5
Using /Users/nahua/.rvm/gems/ruby-2.6.5
Traceback (most recent call last):
ruby: invalid option -:  (-h will show valid options) (RuntimeError)
```

答:
I had the exact same issue, except using rbenv with bash.

The perpetrator seems to be the echo "export RUBYOPT='-W:no-deprecated -W:no-experimental'" line in your .zsh file, I'm not sure if Ruby 2.6.5 understands it.

Remove echo "export RUBYOPT='-W:no-deprecated -W:no-experimental'" from your .zsh / .bashrc / .profile and restart your shell.

Body:
Edit 1: Another person reported similar issue with asdf.

Edit 2: Another reported similar issue.

Edit 3: I uninstalled rvm, installed rvm, installed ruby and rails, and attempted some activities.

Edit 4: Another person mentioned that it's caused by the line I put into .zshrc (or .bash_profile/.bashrc):
RUBYOPT: "-W:no-deprecated -W:no-experimental".

Problem: I have two projects, one using ruby-2.7.0, the other using ruby-2.6.5.

Every time I installed over two versions of ruby, only one version ends up working (2.7.0). The bundle as well as gem commands on the other will no longer work but give a Traceback....(RuntimeError).

Most Recent Attempt and Console Outputs:
Console output flow is roughly:

Uninstall rvm

Install rvm

Install ruby-2.7.0

Install ruby-2.6.5

For ruby-2.7.0, install rails

For ruby-2.6.5, install rails

Everything working alright so far

Append export PATH="$PATH:$HOME/.rvm/bin" to ~/.zshrc

Still working alright

Did echo "export RUBYOPT='-W:no-deprecated -W:no-experimental'" >> ~/.zshrc; source ~/.zshrc

Started noticing the problem again

ruby-2.6.5 does not work; ruby-2.7.0 still works

# UNINSTALL RVM
(base) ➜  ~ rvm -v
rvm 1.29.9 (latest) by Michal Papis, Piotr Kuczynski, Wayne E. Seguin [https://rvm.io]
(base) ➜  ~ which ruby
/Users/nahua/.rvm/rubies/ruby-2.6.5/bin/ruby
(base) ➜  ~ which rails
/usr/bin/rails
(base) ➜  ~ rbenv
zsh: command not found: rbenv
(base) ➜  ~

(base) ➜  ~ rvm implode
Are you SURE you wish for rvm to implode?
This will recursively remove /Users/nahua/.rvm and other rvm traces?
(anything other than 'yes' will cancel) > yes
Removing rvm-shipped binaries (rvm-prompt, rvm, rvm-sudo rvm-shell and rvm-auto-ruby)
Removing rvm wrappers in /Users/nahua/.rvm/bin
Hai! Removing /Users/nahua/.rvm
/Users/nahua/.rvm has been removed.

Note you may need to manually remove /etc/rvmrc and ~/.rvmrc if they exist still.
Please check all .bashrc .bash_profile .profile and .zshrc for RVM source lines and delete or comment out if this was a Per-User installation.
Also make sure to remove `rvm` group if this was a system installation.
Finally it might help to relogin / restart if you want to have fresh environment (like for installing RVM again).

(base) ➜  ~ gem uninstall rvm
Traceback (most recent call last):
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby: invalid option -:  (-h will show valid options) (RuntimeError)
(base) ➜  ~ which ruby
/usr/bin/ruby
(base) ➜  ~ rvm -v
cat: /Users/nahua/.rvm/VERSION: No such file or directory
__rvm_initialize:source:4: no such file or directory: /Users/nahua/.rvm/scripts/base
cat: /Users/nahua/.rvm/VERSION: No such file or directory
rvm  () by Michal Papis, Piotr Kuczynski, Wayne E. Seguin [https://rvm.io]

# COMMENT OFF ALL RVM LINES IN THE FOLLOWING FILES
(base) ➜  ~ subl .bashrc
(base) ➜  ~ subl .profile
(base) ➜  ~ subl .zshrc
(base) ➜  ~ subl .bash_profile
(base) ➜  ~ subl .zlogin
(base) ➜  ~ subl /etc/profile # nothing there
(base) ➜  ~ sudo vim /etc/profile # nothing there
Password:
(base) ➜  ~ exit

# RESTART TERMINAL
(base) ➜  ~ ruby -v
ruby 2.6.3p62 (2019-04-16 revision 67580) [universal.x86_64-darwin19]
(base) ➜  ~ which ruby
/usr/bin/ruby
(base) ➜  ~ which gem
/usr/bin/gem
(base) ➜  ~ which bundle
/usr/bin/bundle
(base) ➜  ~ clear
(base) ➜  ~ rvm list
zsh: command not found: rvm
(base) ➜  ~ rbenv versions
zsh: command not found: rbenv

# INSTALL RVM
(base) ➜  ~ gpg --keyserver hkp://pool.sks-keyservers.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
Warning: Failed to set locale category LC_NUMERIC to en_DE.
Warning: Failed to set locale category LC_TIME to en_DE.
Warning: Failed to set locale category LC_COLLATE to en_DE.
Warning: Failed to set locale category LC_MONETARY to en_DE.
Warning: Failed to set locale category LC_MESSAGES to en_DE.
gpg: key 105BD0E739499BDB: "Piotr Kuczynski <piotr.kuczynski@gmail.com>" not changed
gpg: key 3804BB82D39DC0E3: "Michal Papis (RVM signing) <mpapis@gmail.com>" not changed
gpg: Total number processed: 2
gpg:              unchanged: 2
(base) ➜  ~ \curl -sSL https://get.rvm.io | bash -s stable --ruby
Downloading https://github.com/rvm/rvm/archive/1.29.9.tar.gz
Downloading https://github.com/rvm/rvm/releases/download/1.29.9/1.29.9.tar.gz.asc
Warning: Failed to set locale category LC_NUMERIC to en_DE.
Warning: Failed to set locale category LC_TIME to en_DE.
Warning: Failed to set locale category LC_COLLATE to en_DE.
Warning: Failed to set locale category LC_MONETARY to en_DE.
Warning: Failed to set locale category LC_MESSAGES to en_DE.
gpg: Signature made Wed Jul 10 10:31:02 2019 CEST
gpg:                using RSA key 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
gpg: Good signature from "Piotr Kuczynski <piotr.kuczynski@gmail.com>" [unknown]
gpg: WARNING: This key is not certified with a trusted signature!
gpg:          There is no indication that the signature belongs to the owner.
Primary key fingerprint: 7D2B AF1C F37B 13E2 069D  6956 105B D0E7 3949 9BDB
GPG verified '/Users/nahua/.rvm/archives/rvm-1.29.9.tgz'
Installing RVM to /Users/nahua/.rvm/
    RVM PATH line found in /Users/nahua/.mkshrc /Users/nahua/.profile /Users/nahua/.bashrc /Users/nahua/.zshrc.
    RVM sourcing line found in /Users/nahua/.profile /Users/nahua/.bash_profile /Users/nahua/.zlogin.
Installation of RVM in /Users/nahua/.rvm/ is almost complete:

  * To start using RVM you need to run `source /Users/nahua/.rvm/scripts/rvm`
    in all your open shell windows, in rare cases you need to reopen all shell windows.
Thanks for installing RVM
Please consider donating to our open collective to help us maintain RVM.

  Donate: https://opencollective.com/rvm/donate

Ruby enVironment Manager 1.29.9 (latest) (c) 2009-2017 Michal Papis, Piotr Kuczynski, Wayne E. Seguin

Searching for binary rubies, this might take some time.
No binary rubies available for: osx/10.15/x86_64/ruby-2.6.3.
Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies.
Checking requirements for osx.
Certificates bundle '/usr/local/etc/openssl@1.1/cert.pem' is already up to date.
Requirements installation successful.
Installing Ruby from source to: /Users/nahua/.rvm/rubies/ruby-2.6.3, this may take a while depending on your cpu(s)...
ruby-2.6.3 - #downloading ruby-2.6.3, this may take a while depending on your connection...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 13.8M  100 13.8M    0     0  4529k      0  0:00:03  0:00:03 --:--:-- 4529k
ruby-2.6.3 - #extracting ruby-2.6.3 to /Users/nahua/.rvm/src/ruby-2.6.3.....
ruby-2.6.3 - #configuring.......................................................................
ruby-2.6.3 - #post-configuration.
ruby-2.6.3 - #compiling.....................................................................
ruby-2.6.3 - #installing...........
ruby-2.6.3 - #making binaries executable..
ruby-2.6.3 - #downloading rubygems-3.0.6
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  866k  100  866k    0     0  3437k      0 --:--:-- --:--:-- --:--:-- 3437k
No checksum for downloaded archive, recording checksum in user configuration.
ruby-2.6.3 - #extracting rubygems-3.0.6.....
ruby-2.6.3 - #removing old rubygems........
$LANG was empty, setting up LANG=en_US.US-ASCII, if it fails again try setting LANG to something sane and try again.
ruby-2.6.3 - #installing rubygems-3.0.6...............................................
ruby-2.6.3 - #gemset created /Users/nahua/.rvm/gems/ruby-2.6.3@global
ruby-2.6.3 - #importing gemset /Users/nahua/.rvm/gemsets/global.gems......................................................-
ruby-2.6.3 - #generating global wrappers.......
ruby-2.6.3 - #gemset created /Users/nahua/.rvm/gems/ruby-2.6.3
ruby-2.6.3 - #importing gemsetfile /Users/nahua/.rvm/gemsets/default.gems evaluated to empty gem list
ruby-2.6.3 - #generating default wrappers.......
ruby-2.6.3 - #adjusting #shebangs for (gem irb erb ri rdoc testrb rake).
Install of ruby-2.6.3 - #complete
Ruby was built without documentation, to build it run: rvm docs generate-ri
Creating alias default for ruby-2.6.3....

  * To start using RVM you need to run `source /Users/nahua/.rvm/scripts/rvm`
    in all your open shell windows, in rare cases you need to reopen all shell windows.
(base) ➜  ~ source /Users/nahua/.rvm/scripts/rvm
source /Users/nahua/.rvm/scripts/rvm
(base) ➜  ~ rvm
Ruby enVironment Manager 1.29.9 (latest) (c) 2009-2017 Michal Papis, Piotr Kuczynski, Wayne E. Seguin

For additional documentation please visit https://rvm.io

(base) ➜  ~ echo $PATH
/Users/nahua/.rvm/gems/ruby-2.6.3/bin:/Users/nahua/.rvm/gems/ruby-2.6.3@global/bin:/Users/nahua/.rvm/rubies/ruby-2.6.3/bin:/opt/anaconda3/bin:/opt/anaconda3/condabin:/Users/nahua/bin:/usr/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/nahua/.rvm/bin
(base) ➜  ~ rvm -v
rvm 1.29.9 (latest) by Michal Papis, Piotr Kuczynski, Wayne E. Seguin [https://rvm.io]
(base) ➜  ~ rvm list
=* ruby-2.6.3 [ x86_64 ]

# => - current
# =* - current && default
#  * - default

(base) ➜  ~ rvm install 2.7.0
Searching for binary rubies, this might take some time.
No binary rubies available for: osx/10.15/x86_64/ruby-2.7.0.
Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies.
Checking requirements for osx.
Certificates bundle '/usr/local/etc/openssl@1.1/cert.pem' is already up to date.
Requirements installation successful.
Installing Ruby from source to: /Users/nahua/.rvm/rubies/ruby-2.7.0, this may take a while depending on your cpu(s)...
ruby-2.7.0 - #downloading ruby-2.7.0, this may take a while depending on your connection...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 14.0M  100 14.0M    0     0  4616k      0  0:00:03  0:00:03 --:--:-- 4616k
No checksum for downloaded archive, recording checksum in user configuration.
ruby-2.7.0 - #extracting ruby-2.7.0 to /Users/nahua/.rvm/src/ruby-2.7.0 - please wait
ruby-2.7.0 - #configuring - please wait
ruby-2.7.0 - #post-configuration - please wait
ruby-2.7.0 - #compiling - please wait
ruby-2.7.0 - #installing - please wait
ruby-2.7.0 - #making binaries executable - please wait
Installed rubygems 3.1.2 is newer than 3.0.6 provided with installed ruby, skipping installation, use --force to force installation.
ruby-2.7.0 - #gemset created /Users/nahua/.rvm/gems/ruby-2.7.0@global
ruby-2.7.0 - #importing gemset /Users/nahua/.rvm/gemsets/global.gems - please wait
ruby-2.7.0 - #generating global wrappers - please wait
ruby-2.7.0 - #gemset created /Users/nahua/.rvm/gems/ruby-2.7.0
ruby-2.7.0 - #importing gemsetfile /Users/nahua/.rvm/gemsets/default.gems evaluated to empty gem list
ruby-2.7.0 - #generating default wrappers - please wait
ruby-2.7.0 - #adjusting #shebangs for (gem irb erb ri rdoc testrb rake).
Install of ruby-2.7.0 - #complete
Ruby was built without documentation, to build it run: rvm docs generate-ri
(base) ➜  ~ rvm list
 * ruby-2.6.3 [ x86_64 ]
=> ruby-2.7.0 [ x86_64 ]

# => - current
# =* - current && default
#  * - default

(base) ➜  ~ gem -v
3.1.2
(base) ➜  ~ bundle -v
Bundler version 2.1.2
(base) ➜  ~ rvm use 2.6.3
Using /Users/nahua/.rvm/gems/ruby-2.6.3
(base) ➜  ~ ruby -v
ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-darwin19]
(base) ➜  ~ gem -v
3.0.6
(base) ➜  ~ bundle -v
Bundler version 1.17.3
(base) ➜  ~ rvm use 2.7.0
Using /Users/nahua/.rvm/gems/ruby-2.7.0
(base) ➜  ~ ruby -v
ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-darwin19]
(base) ➜  ~ gem -v
3.1.2
(base) ➜  ~ bundle -v
Bundler version 2.1.2
(base) ➜  ~ rvm install 2.6.5
Searching for binary rubies, this might take some time.
No binary rubies available for: osx/10.15/x86_64/ruby-2.6.5.
Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies.
Checking requirements for osx.
Certificates bundle '/usr/local/etc/openssl@1.1/cert.pem' is already up to date.
Requirements installation successful.
Installing Ruby from source to: /Users/nahua/.rvm/rubies/ruby-2.6.5, this may take a while depending on your cpu(s)...
ruby-2.6.5 - #downloading ruby-2.6.5, this may take a while depending on your connection...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 13.4M  100 13.4M    0     0  9377k      0  0:00:01  0:00:01 --:--:-- 9370k
No checksum for downloaded archive, recording checksum in user configuration.
ruby-2.6.5 - #extracting ruby-2.6.5 to /Users/nahua/.rvm/src/ruby-2.6.5 - please wait
ruby-2.6.5 - #configuring - please wait
ruby-2.6.5 - #post-configuration - please wait
ruby-2.6.5 - #compiling - please wait
ruby-2.6.5 - #installing - please wait
ruby-2.6.5 - #making binaries executable - please wait
ruby-2.6.5 - #downloading rubygems-3.0.6
ruby-2.6.5 - #extracting rubygems-3.0.6 - please wait
ruby-2.6.5 - #removing old rubygems - please wait
$LANG was empty, setting up LANG=en_US.US-ASCII, if it fails again try setting LANG to something sane and try again.
ruby-2.6.5 - #installing rubygems-3.0.6 - please wait
ruby-2.6.5 - #gemset created /Users/nahua/.rvm/gems/ruby-2.6.5@global
ruby-2.6.5 - #importing gemset /Users/nahua/.rvm/gemsets/global.gems - please wait
ruby-2.6.5 - #generating global wrappers - please wait
ruby-2.6.5 - #gemset created /Users/nahua/.rvm/gems/ruby-2.6.5
ruby-2.6.5 - #importing gemsetfile /Users/nahua/.rvm/gemsets/default.gems evaluated to empty gem list
ruby-2.6.5 - #generating default wrappers - please wait
ruby-2.6.5 - #adjusting #shebangs for (gem irb erb ri rdoc testrb rake).
Install of ruby-2.6.5 - #complete
Ruby was built without documentation, to build it run: rvm docs generate-ri
(base) ➜  ~ ruby -v
ruby 2.6.5p114 (2019-10-01 revision 67812) [x86_64-darwin19]
(base) ➜  ~ gem -v
3.0.6
(base) ➜  ~ bundle -v
Bundler version 1.17.3
(base) ➜  ~ gem install rails
...
IGNORED DUE TO CHARACTER LIMIT ON STACKOVERFLOW
...
Successfully installed concurrent-ruby-1.1.5

HEADS UP! i18n 1.1 changed fallbacks to exclude default locale.
But that may break your application.

If you are upgrading your Rails application from an older version of Rails:

Please check your Rails app for 'config.i18n.fallbacks = true'.
If you're using I18n (>= 1.1.0) and Rails (< 5.2.2), this should be
'config.i18n.fallbacks = [I18n.default_locale]'.
If not, fallbacks will be broken in your app by I18n 1.1.x.

If you are starting a NEW Rails application, you can ignore this notice.

For more info see:
https://github.com/svenfuchs/i18n/releases/tag/v1.1.0
...
IGNORED DUE TO CHARACTER LIMIT ON STACKOVERFLOW
...
Done installing documentation for concurrent-ruby, i18n, thread_safe, tzinfo, zeitwerk, activesupport, rack, rack-test, mini_portile2, nokogiri, crass, loofah, rails-html-sanitizer, rails-dom-testing, builder, erubi, actionview, actionpack, activemodel, activerecord, globalid, activejob, mini_mime, mail, actionmailer, nio4r, websocket-extensions, websocket-driver, actioncable, mimemagic, marcel, activestorage, actionmailbox, actiontext, thor, method_source, railties, sprockets, sprockets-rails, rails after 39 seconds
40 gems installed
(base) ➜  ~ rails -v
Rails 6.0.2.1
(base) ➜  ~ rvm use 2.6.5
Using /Users/nahua/.rvm/gems/ruby-2.6.5
(base) ➜  ~ ruby -v
ruby 2.6.5p114 (2019-10-01 revision 67812) [x86_64-darwin19]
(base) ➜  ~ gem install rails
...
IGNORED DUE TO CHARACTER LIMIT ON STACKOVERFLOW
...
Successfully installed concurrent-ruby-1.1.5

HEADS UP! i18n 1.1 changed fallbacks to exclude default locale.
But that may break your application.

If you are upgrading your Rails application from an older version of Rails:

Please check your Rails app for 'config.i18n.fallbacks = true'.
If you're using I18n (>= 1.1.0) and Rails (< 5.2.2), this should be
'config.i18n.fallbacks = [I18n.default_locale]'.
If not, fallbacks will be broken in your app by I18n 1.1.x.

If you are starting a NEW Rails application, you can ignore this notice.

For more info see:
https://github.com/svenfuchs/i18n/releases/tag/v1.1.0

...
IGNORED DUE TO CHARACTER LIMIT ON STACKOVERFLOW
...
Done installing documentation for concurrent-ruby, i18n, thread_safe, tzinfo, zeitwerk, activesupport, rack, rack-test, mini_portile2, nokogiri, crass, loofah, rails-html-sanitizer, rails-dom-testing, builder, erubi, actionview, actionpack, activemodel, activerecord, globalid, activejob, mini_mime, mail, actionmailer, nio4r, websocket-extensions, websocket-driver, actioncable, mimemagic, marcel, activestorage, actionmailbox, actiontext, thor, method_source, railties, sprockets, sprockets-rails, rails after 34 seconds
40 gems installed
(base) ➜  ~ ruby -v
ruby 2.6.5p114 (2019-10-01 revision 67812) [x86_64-darwin19]
(base) ➜  ~ rvm list
 * ruby-2.6.3 [ x86_64 ]
=> ruby-2.6.5 [ x86_64 ]
   ruby-2.7.0 [ x86_64 ]

# => - current
# =* - current && default
#  * - default

(base) ➜  ~ rvm use 2.7.0
Using /Users/nahua/.rvm/gems/ruby-2.7.0
(base) ➜  ~ ruby -v
ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-darwin19]
(base) ➜  ~ rvm use 2.6.5
Using /Users/nahua/.rvm/gems/ruby-2.6.5
(base) ➜  ~ ruby -v
ruby 2.6.5p114 (2019-10-01 revision 67812) [x86_64-darwin19]
(base) ➜  ~ cd projects/rails/DevcampPortfolio
(base) ➜  DevcampPortfolio git:(portfolio-feature) ✗ cat .ruby-version
2.7.0
(base) ➜  DevcampPortfolio git:(portfolio-feature) ✗ rvm list
 * ruby-2.6.3 [ x86_64 ]
   ruby-2.6.5 [ x86_64 ]
=> ruby-2.7.0 [ x86_64 ]

# => - current
# =* - current && default
#  * - default

(base) ➜  DevcampPortfolio git:(portfolio-feature) ✗ rails c
Warning: the running version of Bundler (2.1.2) is older than the version that created the lockfile (2.1.4). We suggest you to upgrade to the version that created the lockfile by running `gem install bundler:2.1.4`.
Could not find minitest-5.14.0 in any of the sources
Run `bundle install` to install missing gems.
(base) ➜  DevcampPortfolio git:(portfolio-feature) ✗ clear
(base) ➜  DevcampPortfolio git:(portfolio-feature) ✗ which bundle
/Users/nahua/.rvm/rubies/ruby-2.7.0/bin/bundle
(base) ➜  DevcampPortfolio git:(portfolio-feature) ✗ bundle install
Warning: the running version of Bundler (2.1.2) is older than the version that created the lockfile (2.1.4). We suggest you to upgrade to the version that created the lockfile by running `gem install bundler:2.1.4`.
Fetching gem metadata from https://rubygems.org/............
...
### BUNDLE INSTALL...DELETING DUE TO CHARACTER LIMIT ON STACKOVERFLOW
...
Bundle complete! 15 Gemfile dependencies, 67 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
(base) ➜  DevcampPortfolio git:(portfolio-feature) ✗ gem install bundler:2.1.4
Fetching bundler-2.1.4.gem
Successfully installed bundler-2.1.4
Parsing documentation for bundler-2.1.4
Installing ri documentation for bundler-2.1.4
Done installing documentation for bundler after 2 seconds
1 gem installed
(base) ➜  DevcampPortfolio git:(portfolio-feature) ✗ rvm use 2.6.5
Using /Users/nahua/.rvm/gems/ruby-2.6.5
(base) ➜  DevcampPortfolio git:(portfolio-feature) ✗ ruby -v
ruby 2.6.5p114 (2019-10-01 revision 67812) [x86_64-darwin19]
(base) ➜  DevcampPortfolio git:(portfolio-feature) ✗ rvm use 2.7.0
Using /Users/nahua/.rvm/gems/ruby-2.7.0
(base) ➜  DevcampPortfolio git:(portfolio-feature) ✗ ruby -v
ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-darwin19]
(base) ➜  DevcampPortfolio git:(portfolio-feature) ✗ rails c
Warning: the running version of Bundler (2.1.2) is older than the version that created the lockfile (2.1.4). We suggest you to upgrade to the version that created the lockfile by running `gem install bundler:2.1.4`.
Running via Spring preloader in process 16581
Loading development environment (Rails 6.0.2.1)
2.7.0 :001 > exit
(base) ➜  DevcampPortfolio git:(portfolio-feature) ✗ cd ../../20bn-homepage
(base) ➜  20bn-homepage git:(master) rvm list
 * ruby-2.6.3 [ x86_64 ]
=> ruby-2.6.5 [ x86_64 ]
   ruby-2.7.0 [ x86_64 ]

# => - current
# =* - current && default
#  * - default

(base) ➜  20bn-homepage git:(master) bundle install
You must use Bundler 2 or greater with this lockfile.
(base) ➜  20bn-homepage git:(master) bundle -v
Bundler version 1.17.3
(base) ➜  20bn-homepage git:(master) gem install bundler:2.1.4
Fetching bundler-2.1.4.gem
Successfully installed bundler-2.1.4
Parsing documentation for bundler-2.1.4
Installing ri documentation for bundler-2.1.4
Done installing documentation for bundler after 2 seconds
1 gem installed

(base) ➜  20bn-homepage git:(master) bundle install
You must use Bundler 2 or greater with this lockfile.
(base) ➜  20bn-homepage git:(master) bundle -v
Bundler version 1.17.3
(base) ➜  20bn-homepage git:(master) gem install bundler:2.1.4
Fetching bundler-2.1.4.gem
Successfully installed bundler-2.1.4
Parsing documentation for bundler-2.1.4
Installing ri documentation for bundler-2.1.4
Done installing documentation for bundler after 2 seconds
1 gem installed
(base) ➜  20bn-homepage git:(master) bundle install
...
### BUNDLE INSTALL...DELETING DUE TO CHARACTER LIMIT ON STACKOVERFLOW
...
Bundle complete! 61 Gemfile dependencies, 180 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
Post-install message from postmark:

    ==================
    Thanks for installing the postmark gem. If you don't have an account, please
    sign up at http://postmarkapp.com/.

    Review the README.md for implementation details and examples.
    ==================
  %

(base) ➜  20bn-homepage git:(master) exit
Last login: Wed Jan 22 10:05:43 on ttys001
(base) ➜  ~ rvm list
zsh: command not found: rvm
(base) ➜  ~ echo "source $HOME/.rvm/scripts/rvm" >> ~/.zshrc
(base) ➜  ~ source ~/.zshrc
(base) ➜  ~ rvm list
=* ruby-2.6.3 [ x86_64 ]
   ruby-2.6.5 [ x86_64 ]
   ruby-2.7.0 [ x86_64 ]

# => - current
# =* - current && default
#  * - default

(base) ➜  ~ ruby -v
ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-darwin19]
(base) ➜  ~ cd projects/rails/DevcampPortfolio
(base) ➜  DevcampPortfolio git:(portfolio-feature) ✗ rvm list
 * ruby-2.6.3 [ x86_64 ]
   ruby-2.6.5 [ x86_64 ]
=> ruby-2.7.0 [ x86_64 ]

# => - current
# =* - current && default
#  * - default

(base) ➜  DevcampPortfolio git:(portfolio-feature) ✗ rails c
Warning: the running version of Bundler (2.1.2) is older than the version that created the lockfile (2.1.4). We suggest you to upgrade to the version that created the lockfile by running `gem install bundler:2.1.4`.
Running via Spring preloader in process 26256
Loading development environment (Rails 6.0.2.1)
 :001 > Blog.last
  Blog Load (2.5ms)  SELECT "blogs".* FROM "blogs" ORDER BY "blogs"."id" DESC LIMIT $1  [["LIMIT", 1]]
 => #<Blog id: 12, title: "My great blog title", body: "Lorem ipsum blah blah blah", created_at: "2020-01-21 09:49:26", updated_at: "2020-01-21 09:49:26", slug: "my-great-blog-title">
 :002 > exit
(base) ➜  DevcampPortfolio git:(portfolio-feature) ✗ cd ../../20bn-homepage
(base) ➜  20bn-homepage git:(master) rvm list
 * ruby-2.6.3 [ x86_64 ]
=> ruby-2.6.5 [ x86_64 ]
   ruby-2.7.0 [ x86_64 ]

# => - current
# =* - current && default
#  * - default

(base) ➜  20bn-homepage git:(master) ruby -v
ruby 2.6.5p114 (2019-10-01 revision 67812) [x86_64-darwin19]
(base) ➜  20bn-homepage git:(master) rails c
Loading development environment (Rails 6.0.2.1)
 :001 > exit
(base) ➜  20bn-homepage git:(master) cd ../rails/DevcampPortfolio
(base) ➜  DevcampPortfolio git:(portfolio-feature) ✗ echo "export RUBYOPT='-W:no-deprecated -W:no-experimental'" >> ~/.zshrc
(base) ➜  DevcampPortfolio git:(portfolio-feature) ✗ source ~/.zshrc
(base) ➜  DevcampPortfolio git:(portfolio-feature) ✗ rails c
Warning: the running version of Bundler (2.1.2) is older than the version that created the lockfile (2.1.4). We suggest you to upgrade to the version that created the lockfile by running `gem install bundler:2.1.4`.
Running via Spring preloader in process 26693
Loading development environment (Rails 6.0.2.1)
2.7.0 :001 > exit
(base) ➜  DevcampPortfolio git:(portfolio-feature) ✗ cd ../../20bn-homepage
(base) ➜  20bn-homepage git:(master) ruby -v
Traceback (most recent call last):
ruby: invalid option -:  (-h will show valid options) (RuntimeError)

### COMMENT OFF export RUBYOPT='-W:no-deprecated -W:no-experimental' IN ~/.zshrc AGAIN

(base) ➜  20bn-homepage git:(master) source ~/.zshrc
(base) ➜  20bn-homepage git:(master) ruby -v
Traceback (most recent call last):
ruby: invalid option -:  (-h will show valid options) (RuntimeError)
(base) ➜  20bn-homepage git:(master)
(base) ➜  20bn-homepage git:(master) rvm list
Warning! PATH is not properly set up, /Users/nahua/.rvm/gems/ruby-2.6.5/bin is not at first place.
         Usually this is caused by shell initialization files. Search for PATH=... entries.
         You can also re-add RVM to your profile by running: rvm get stable --auto-dotfiles
         To fix it temporarily in this shell session run: rvm use ruby-2.6.5
         To ignore this error add rvm_silence_path_mismatch_check_flag=1 to your ~/.rvmrc file.
 * ruby-2.6.3 [ x86_64 ]
=> ruby-2.6.5 [ x86_64 ]
   ruby-2.7.0 [ x86_64 ]

# => - current
# =* - current && default
#  * - default

(base) ➜  20bn-homepage git:(master) rvm get stable --auto-dotfiles
...
IGNORED DUE TO STACKOVERFLOW CHARACTER LIMIT
...

RVM reloaded!

(base) ➜  20bn-homepage git:(master) ruby -v
Traceback (most recent call last):
ruby: invalid option -:  (-h will show valid options) (RuntimeError)

(base) ➜  20bn-homepage git:(master) echo $PATH
/Users/nahua/bin:/usr/local/bin:/Users/nahua/.rvm/gems/ruby-2.6.5/bin:/Users/nahua/.rvm/gems/ruby-2.6.5@global/bin:/Users/nahua/.rvm/rubies/ruby-2.6.5/bin:/Users/nahua/.rvm/bin:/Users/nahua/bin:/usr/local/bin:/Users/nahua/bin:/usr/local/bin:/opt/anaconda3/bin:/opt/anaconda3/condabin:/Users/nahua/bin:/usr/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
(base) ➜  20bn-homepage git:(master) rvm reset
Warning! PATH is not properly set up, /Users/nahua/.rvm/gems/ruby-2.6.5/bin is not at first place.
         Usually this is caused by shell initialization files. Search for PATH=... entries.
         You can also re-add RVM to your profile by running: rvm get stable --auto-dotfiles
         To fix it temporarily in this shell session run: rvm use ruby-2.6.5
         To ignore this error add rvm_silence_path_mismatch_check_flag=1 to your ~/.rvmrc file.
(base) ➜  20bn-homepage git:(master) ruby -v
Traceback (most recent call last):
ruby: invalid option -:  (-h will show valid options) (RuntimeError)
(base) ➜  20bn-homepage git:(master) rvm list
 * ruby-2.6.3 [ x86_64 ]
   ruby-2.6.5 [ x86_64 ]
   ruby-2.7.0 [ x86_64 ]

# => - current
# =* - current && default
#  * - default

(base) ➜  20bn-homepage git:(master) source ~/.zshrc
(base) ➜  20bn-homepage git:(master) ruby -v
Traceback (most recent call last):
ruby: invalid option -:  (-h will show valid options) (RuntimeError)
(base) ➜  20bn-homepage git:(master) rvm use ruby-2.6.5
Using /Users/nahua/.rvm/gems/ruby-2.6.5
Traceback (most recent call last):
ruby: invalid option -:  (-h will show valid options) (RuntimeError)
(base) ➜  20bn-homepage git:(master) rvm use 2.7.0
Using /Users/nahua/.rvm/gems/ruby-2.7.0
(base) ➜  20bn-homepage git:(master) ruby -v
ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-darwin19]

Original Problem Description:

I have two projects, one using ruby-2.7.0, the other using ruby-2.6.5.

I've just realized there is a weird issue with my Ruby/Rails setup on the latest OS X. Either using rvm or rbenv, every time I installed over two versions of ruby, only one version ends up working (2.7.0). The bundle as well as gem commands on the other will no longer work but give a Traceback....(RuntimeError).

In the past 6 hours, I have reinstalled rbenv, uninstalled rbenv, installed rvm. I've also tried uninstalling all non-system Ruby versions and Rails as well. Nothing seems to help.

Below is the error shown in my console:

(base) ➜  ~ rvm list
=* ruby-2.6.5 [ x86_64 ]
   ruby-2.7.0 [ x86_64 ]

# => - current
# =* - current && default
#  * - default

(base) ➜  ~ bundle -v
Traceback (most recent call last):
ruby: invalid option -:  (-h will show valid options) (RuntimeError)
(base) ➜  ~ gem -v
Traceback (most recent call last):
ruby: invalid option -:  (-h will show valid options) (RuntimeError)
(base) ➜  ~ rvm use 2.7.0
Using /Users/nahua/.rvm/gems/ruby-2.7.0
(base) ➜  ~ bundle -v
Bundler version 2.1.4
(base) ➜  ~ rvm use 2.6.5
Using /Users/nahua/.rvm/gems/ruby-2.6.5
Traceback (most recent call last):
ruby: invalid option -:  (-h will show valid options) (RuntimeError)


来源: stackexchange

问:
Regex to replace first lowercase character in a line into uppercase
I have a very large file containing thousands of sentences. In all of them, the first word of each sentence begins with lowercase, but I need them to begin with uppercase.

I looked through the site trying to find a regex to do this but I was unable to. I learned a lot about regex in the process, which is always a plus for my job, but I was unable to find specifically what I am looking for.

I tried to find a way of compiling the code from several answers, including the following:

Convert first lowercase to uppercase and uppercase to lowercase (regex?)

how to change first two uppercase character to lowercase character on each line in vim

Regex, two uppercase characters in a string

Convert a char to upper case using regular expressions (EditPad Pro)

But for different reasons none of them served my purpose.

I am working with a translation-specific application which accepts regex.

Do you think this is possible at all? It would save me hours of tedious work.

答:
Taking Ildar's answer and combining both of his patterns should work with no compromises.
(?<=[\.!?]\s)([a-z])|^([a-z])
This is basically saying, if first pattern OR second pattern. But because you're now technically extracting 2 groups instead of one, you'll have to refer to group 2 as $2. Which should be fine because only one of the patterns should be matched.
So your substitution pattern would then be as follows...
\U$1$2

Here's a working example, again based on Ildar's answer...
https://regex101.com/r/hqwK26/13

ContentLicense: CC BY-SA 4.0


问:
Cypress login command with cy.request causes subsequent cy.visit to fail
I'm trying to make a programmatic login with Cypress before each test. My tokens are persisted in localStorage. If I alter it synchronously, i.e. simpy doing localStorage.setItem without involving cy.request it works fine. However, I would like to use my auth server (http://localhost:3004/login below) to generate tokens.

The token is fetched correctly from the server, but as soon as I use the command below along with cy.visit('/') I get "Failed to visit localhost:8080 - We attempted to make an http request to this URL but the request failed without a response" (see full log below).

As far as I can tell, this is the correct approach when using an auth server for headless authentication. What did I miss?

commands.js

```<code>Cypress.Commands.add('login', () => {
  cy.request({
    method: 'POST',
    url: `http://localhost:3004/login`,
    body: {
      username: 'foo@bar.com',
      password: '123'
    }
  }).its('body').then((body) => {
    const vuexData = { user: { authenticationData: { token: body.token } } }
    window.localStorage.setItem('vuex', JSON.stringify(vuexData))
  })
})
</code>```

test.js

```<code>describe('A test', () => {
  beforeEach(() => {
    cy.login()
  })

  it('works', () => {
    cy.visit('/')
    cy.get('h1').contains('All Books')
  })
})
</code>```

CypressError: cy.visit() failed trying to load:

http://localhost:8080/

We attempted to make an http request to this URL but the request
  failed without a response.

We received this error at the network level:

Error: connect ECONNREFUSED ::1:8080

Common situations why this would fail:
    - you don't have internet access
    - you forgot to run / boot your web server
    - your web server isn't accessible
    - you have weird network configuration settings on your computer

The stack trace for this error is:

Error: connect ECONNREFUSED ::1:8080
      at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1056:14)

答:
A couple of things.
I've never used cypress but any network calls are going to be async. None of your functions above are returning the promises generated from your functions. So where you create your login command. You need to return the promise from that function and you need to await it in your beforeEach function. Might be the cause of your problem, maybe not.

Is it possible you have a bug in you application where you are timing out because you have an unauthenticated request to the service running on port 8080. Looking at the code as it stands, you are going to call visit (your test) before your beforeEach has completed. It is very likely that the data is not in local storage by the time you hit your test.

Having a quick read through the documentation on cypress, it looks like cypress tries to figure out where your service is located. The other thing which it looks like is that it appends the url defined in the request to the baseUrl configured. Do you actually see the auth request come in on your auth service?

Body:
I'm trying to make a programmatic login with Cypress before each test. My tokens are persisted in localStorage. If I alter it synchronously, i.e. simpy doing localStorage.setItem without involving cy.request it works fine. However, I would like to use my auth server (http://localhost:3004/login below) to generate tokens.

The token is fetched correctly from the server, but as soon as I use the command below along with cy.visit('/') I get "Failed to visit localhost:8080 - We attempted to make an http request to this URL but the request failed without a response" (see full log below).

As far as I can tell, this is the correct approach when using an auth server for headless authentication. What did I miss?

commands.js

Cypress.Commands.add('login', () => {
  cy.request({
    method: 'POST',
    url: `http://localhost:3004/login`,
    body: {
      username: 'foo@bar.com',
      password: '123'
    }
  }).its('body').then((body) => {
    const vuexData = { user: { authenticationData: { token: body.token } } }
    window.localStorage.setItem('vuex', JSON.stringify(vuexData))
  })
})

test.js

describe('A test', () => {
  beforeEach(() => {
    cy.login()
  })

  it('works', () => {
    cy.visit('/')
    cy.get('h1').contains('All Books')
  })
})

CypressError: cy.visit() failed trying to load:

http://localhost:8080/

We attempted to make an http request to this URL but the request
  failed without a response.

We received this error at the network level:

Error: connect ECONNREFUSED ::1:8080

Common situations why this would fail:
    - you don't have internet access
    - you forgot to run / boot your web server
    - your web server isn't accessible
    - you have weird network configuration settings on your computer

The stack trace for this error is:

Error: connect ECONNREFUSED ::1:8080
      at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1056:14)


问:
JupyterHub singleuser not able to use tensorflow gpu support using systemdspawner
(this is a crossposting to SO, the jupyterhub issue tracker and the jupyterhub/systemdspawner issue tracker)

I have a private JupyterHub Setup using a SystemdSpawner where I try to run tensorflow with gpu support.

I followed the tensorflow instructions and alternatively tried a already provisioned AWS AMI (Deep Learning Base AMI (Ubuntu 18.04) Version 21.0) with NDVIDIA, both on AWS EC2 g4 instances.

On both setups I'm able to use tensorflow with gpu support in an (i)python 3.6 shell

```<code>>>> import tensorflow as tf
>>> tf.config.list_physical_devices('GPU')
2020-02-12 10:57:13.670937: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcuda.so.1
2020-02-12 10:57:13.698230: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:981] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2020-02-12 10:57:13.699066: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1555] Found device 0 with properties:
pciBusID: 0000:00:1e.0 name: Tesla T4 computeCapability: 7.5
coreClock: 1.59GHz coreCount: 40 deviceMemorySize: 14.73GiB deviceMemoryBandwidth: 298.08GiB/s
2020-02-12 10:57:13.699286: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcudart.so.10.1
2020-02-12 10:57:13.700918: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcublas.so.10
2020-02-12 10:57:13.702512: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcufft.so.10
2020-02-12 10:57:13.702814: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcurand.so.10
2020-02-12 10:57:13.704561: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcusolver.so.10
2020-02-12 10:57:13.705586: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcusparse.so.10
2020-02-12 10:57:13.709171: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcudnn.so.7
2020-02-12 10:57:13.709278: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:981] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2020-02-12 10:57:13.710120: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:981] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2020-02-12 10:57:13.710893: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1697] Adding visible gpu devices: 0
[PhysicalDevice(name='/physical_device:GPU:0', device_type='GPU')]
</code>```

(some warnings about NUMA node, but the gpu is found)

Also using nvidia-smi and deviceQuery shows the gpu:

```<code>$ nvidia-smi
Wed Feb 12 10:39:44 2020
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 418.87.01    Driver Version: 418.87.01    CUDA Version: 10.1     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  Tesla T4            On   | 00000000:00:1E.0 Off |                    0 |
| N/A   33C    P8     9W /  70W |      0MiB / 15079MiB |      0%      Default |
+-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID   Type   Process name                             Usage      |
|=============================================================================|
|  No running processes found                                                 |
+-----------------------------------------------------------------------------+
</code>```

```<code>$ /usr/local/cuda/extras/demo_suite/deviceQuery
/usr/local/cuda/extras/demo_suite/deviceQuery Starting...

 CUDA Device Query (Runtime API) version (CUDART static linking)

Detected 1 CUDA Capable device(s)

Device 0: "Tesla T4"
  CUDA Driver Version / Runtime Version          10.1 / 10.0
  CUDA Capability Major/Minor version number:    7.5
  Total amount of global memory:                 15080 MBytes (15812263936 bytes)
  (40) Multiprocessors, ( 64) CUDA Cores/MP:     2560 CUDA Cores
  GPU Max Clock rate:                            1590 MHz (1.59 GHz)
  Memory Clock rate:                             5001 Mhz
  Memory Bus Width:                              256-bit
  L2 Cache Size:                                 4194304 bytes
  Maximum Texture Dimension Size (x,y,z)         1D=(131072), 2D=(131072, 65536), 3D=(16384, 16384, 16384)
  Maximum Layered 1D Texture Size, (num) layers  1D=(32768), 2048 layers
  Maximum Layered 2D Texture Size, (num) layers  2D=(32768, 32768), 2048 layers
  Total amount of constant memory:               65536 bytes
  Total amount of shared memory per block:       49152 bytes
  Total number of registers available per block: 65536
  Warp size:                                     32
  Maximum number of threads per multiprocessor:  1024
  Maximum number of threads per block:           1024
  Max dimension size of a thread block (x,y,z): (1024, 1024, 64)
  Max dimension size of a grid size    (x,y,z): (2147483647, 65535, 65535)
  Maximum memory pitch:                          2147483647 bytes
  Texture alignment:                             512 bytes
  Concurrent copy and kernel execution:          Yes with 3 copy engine(s)
  Run time limit on kernels:                     No
  Integrated GPU sharing Host Memory:            No
  Support host page-locked memory mapping:       Yes
  Alignment requirement for Surfaces:            Yes
  Device has ECC support:                        Enabled
  Device supports Unified Addressing (UVA):      Yes
  Device supports Compute Preemption:            Yes
  Supports Cooperative Kernel Launch:            Yes
  Supports MultiDevice Co-op Kernel Launch:      Yes
  Device PCI Domain ID / Bus ID / location ID:   0 / 0 / 30
  Compute Mode:
     < Default (multiple host threads can use ::cudaSetDevice() with device simultaneously) >

deviceQuery, CUDA Driver = CUDART, CUDA Driver Version = 10.1, CUDA Runtime Version = 10.0, NumDevs = 1, Device0 = Tesla T4
Result = PASS
</code>```

Now I start the JupyterHub, login, and open a terminal, there I get:

```<code>$ nvidia-smi
NVIDIA-SMI has failed because it couldn't communicate with the NVIDIA driver. Make sure that the latest NVIDIA driver is installed and running.
</code>```

and

```<code>$ /usr/local/cuda/extras/demo_suite/deviceQuery
cuda/extras/demo_suite/deviceQuery Starting...

 CUDA Device Query (Runtime API) version (CUDART static linking)

cudaGetDeviceCount returned 38
-> no CUDA-capable device is detected
Result = FAIL
</code>```

and also

I suspect some kind of "sandbox", missing ENV vars, etc. due to that the gpu drivers are not found inside the singleuser environment and subsequently the tensorflow gpu support does not work.

Any ideas on this? Probably it is either a small configuration tweak or due to the architecture not solvable at all ;)

答:
Set c.SystemdSpawner.isolate_devices = False in your jupyterhub_config.py.

Here is an excerpt from the documentation:

Setting this to true provides a separate, private /dev for each user. This prevents the user from directly accessing hardware devices, which could be a potential source of security issues. /dev/null, /dev/zero, /dev/random and the ttyp pseudo-devices will be mounted already, so most users should see no change when this is enabled.

```<code>c.SystemdSpawner.isolate_devices = True
</code>```

This requires systemd version > 227. If you enable this in earlier versions, spawning will fail.

Nvidia makes use of devices (i.e., files in/dev). Please refer to their documentation for more information. There should be files in there named /dev/nvidia*. Isolating devices with SystemdSpawner will prevent access to those Nvidia devices.

Is there a way to still isolate the devices and enable GPU support?

I am not sure... but I can provide pointers to documentation. Setting c.SystemdSpawner.isolate_devices = True sets PrivateDevices=yes in the eventual systemd-run call (source). Refer to the systemd documentation for more information on the PrivateDevices option.

You might be able to keep isolate_devices = True and then explicitly mount the nvidia devices. Though I don't know how to do this...

Body:
(this is a crossposting to SO, the jupyterhub issue tracker and the jupyterhub/systemdspawner issue tracker)

I have a private JupyterHub Setup using a SystemdSpawner where I try to run tensorflow with gpu support.

I followed the tensorflow instructions and alternatively tried a already provisioned AWS AMI (Deep Learning Base AMI (Ubuntu 18.04) Version 21.0) with NDVIDIA, both on AWS EC2 g4 instances.

On both setups I'm able to use tensorflow with gpu support in an (i)python 3.6 shell

>>> import tensorflow as tf
>>> tf.config.list_physical_devices('GPU')
2020-02-12 10:57:13.670937: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcuda.so.1
2020-02-12 10:57:13.698230: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:981] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2020-02-12 10:57:13.699066: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1555] Found device 0 with properties:
pciBusID: 0000:00:1e.0 name: Tesla T4 computeCapability: 7.5
coreClock: 1.59GHz coreCount: 40 deviceMemorySize: 14.73GiB deviceMemoryBandwidth: 298.08GiB/s
2020-02-12 10:57:13.699286: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcudart.so.10.1
2020-02-12 10:57:13.700918: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcublas.so.10
2020-02-12 10:57:13.702512: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcufft.so.10
2020-02-12 10:57:13.702814: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcurand.so.10
2020-02-12 10:57:13.704561: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcusolver.so.10
2020-02-12 10:57:13.705586: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcusparse.so.10
2020-02-12 10:57:13.709171: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcudnn.so.7
2020-02-12 10:57:13.709278: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:981] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2020-02-12 10:57:13.710120: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:981] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2020-02-12 10:57:13.710893: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1697] Adding visible gpu devices: 0
[PhysicalDevice(name='/physical_device:GPU:0', device_type='GPU')]

(some warnings about NUMA node, but the gpu is found)

Also using nvidia-smi and deviceQuery shows the gpu:

$ nvidia-smi
Wed Feb 12 10:39:44 2020
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 418.87.01    Driver Version: 418.87.01    CUDA Version: 10.1     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  Tesla T4            On   | 00000000:00:1E.0 Off |                    0 |
| N/A   33C    P8     9W /  70W |      0MiB / 15079MiB |      0%      Default |
+-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID   Type   Process name                             Usage      |
|=============================================================================|
|  No running processes found                                                 |
+-----------------------------------------------------------------------------+

$ /usr/local/cuda/extras/demo_suite/deviceQuery
/usr/local/cuda/extras/demo_suite/deviceQuery Starting...

 CUDA Device Query (Runtime API) version (CUDART static linking)

Detected 1 CUDA Capable device(s)

Device 0: "Tesla T4"
  CUDA Driver Version / Runtime Version          10.1 / 10.0
  CUDA Capability Major/Minor version number:    7.5
  Total amount of global memory:                 15080 MBytes (15812263936 bytes)
  (40) Multiprocessors, ( 64) CUDA Cores/MP:     2560 CUDA Cores
  GPU Max Clock rate:                            1590 MHz (1.59 GHz)
  Memory Clock rate:                             5001 Mhz
  Memory Bus Width:                              256-bit
  L2 Cache Size:                                 4194304 bytes
  Maximum Texture Dimension Size (x,y,z)         1D=(131072), 2D=(131072, 65536), 3D=(16384, 16384, 16384)
  Maximum Layered 1D Texture Size, (num) layers  1D=(32768), 2048 layers
  Maximum Layered 2D Texture Size, (num) layers  2D=(32768, 32768), 2048 layers
  Total amount of constant memory:               65536 bytes
  Total amount of shared memory per block:       49152 bytes
  Total number of registers available per block: 65536
  Warp size:                                     32
  Maximum number of threads per multiprocessor:  1024
  Maximum number of threads per block:           1024
  Max dimension size of a thread block (x,y,z): (1024, 1024, 64)
  Max dimension size of a grid size    (x,y,z): (2147483647, 65535, 65535)
  Maximum memory pitch:                          2147483647 bytes
  Texture alignment:                             512 bytes
  Concurrent copy and kernel execution:          Yes with 3 copy engine(s)
  Run time limit on kernels:                     No
  Integrated GPU sharing Host Memory:            No
  Support host page-locked memory mapping:       Yes
  Alignment requirement for Surfaces:            Yes
  Device has ECC support:                        Enabled
  Device supports Unified Addressing (UVA):      Yes
  Device supports Compute Preemption:            Yes
  Supports Cooperative Kernel Launch:            Yes
  Supports MultiDevice Co-op Kernel Launch:      Yes
  Device PCI Domain ID / Bus ID / location ID:   0 / 0 / 30
  Compute Mode:
     < Default (multiple host threads can use ::cudaSetDevice() with device simultaneously) >

deviceQuery, CUDA Driver = CUDART, CUDA Driver Version = 10.1, CUDA Runtime Version = 10.0, NumDevs = 1, Device0 = Tesla T4
Result = PASS

Now I start the JupyterHub, login, and open a terminal, there I get:

$ nvidia-smi
NVIDIA-SMI has failed because it couldn't communicate with the NVIDIA driver. Make sure that the latest NVIDIA driver is installed and running.

and

$ /usr/local/cuda/extras/demo_suite/deviceQuery
cuda/extras/demo_suite/deviceQuery Starting...

 CUDA Device Query (Runtime API) version (CUDART static linking)

cudaGetDeviceCount returned 38
-> no CUDA-capable device is detected
Result = FAIL

and also

I suspect some kind of "sandbox", missing ENV vars, etc. due to that the gpu drivers are not found inside the singleuser environment and subsequently the tensorflow gpu support does not work.

Any ideas on this? Probably it is either a small configuration tweak or due to the architecture not solvable at all ;)

Body:
Set c.SystemdSpawner.isolate_devices = False in your jupyterhub_config.py.

Here is an excerpt from the documentation:

Setting this to true provides a separate, private /dev for each user. This prevents the user from directly accessing hardware devices, which could be a potential source of security issues. /dev/null, /dev/zero, /dev/random and the ttyp pseudo-devices will be mounted already, so most users should see no change when this is enabled.

c.SystemdSpawner.isolate_devices = True

This requires systemd version > 227. If you enable this in earlier versions, spawning will fail.

Nvidia makes use of devices (i.e., files in/dev). Please refer to their documentation for more information. There should be files in there named /dev/nvidia*. Isolating devices with SystemdSpawner will prevent access to those Nvidia devices.

Is there a way to still isolate the devices and enable GPU support?

I am not sure... but I can provide pointers to documentation. Setting c.SystemdSpawner.isolate_devices = True sets PrivateDevices=yes in the eventual systemd-run call (source). Refer to the systemd documentation for more information on the PrivateDevices option.

You might be able to keep isolate_devices = True and then explicitly mount the nvidia devices. Though I don't know how to do this...


问:
Multiple commas Javascript when printing an array
This is probably really basic but I keep getting strange output when printing an array, it keeps putting double commas in between values in the arrays. I know it's something simple but I've been at this for a couple of hours now and no joy. You can see at the end I've tried a couple of things but end up with a weird double comma.</p>

```<code><!DOCTYPE html>
<html>
<body>

<p>Click the button to run the digit checker.</p> <!--Text telling the user to hit the button-->

<button onclick="myDigitChecker()" >Submit</button> <!--button that runs my function once they hit-->

<p id="demo"></p>
<p id="demo2"></p>

<script>
function myDigitChecker() {
    var input = prompt("Please enter two positive digits, decimals will be rounded");
    var digits = Math.round(input); //take the inoput and convert it to a whole number

    var evenNumbers = [];
    var oddNumbers = [];

    while (isNaN(digits)|| digits < 10 || digits >99) {//isNaN is a method for checking if something isn't a number
    var digits = prompt("Please enter two positive digits, decimals will be rounded")}

    for (x = 0; x <= digits ;x++){
        if(x % 2 === 0){
            evenNumbers[x] = x;
            console.log(evenNumbers);
        }else{
            oddNumbers[x] = x;
            console.log(oddNumbers);
        }
    }

    document.getElementById("demo").innerHTML = (evenNumbers.join(","));
    var str1 = oddNumbers.toString;
    document.getElementById("demo2").innerHTML = oddNumbers;

}
</script>

</body>
</html>
</code>```

答:
You create a sparse array with holes by using indices which are not consecutive.

Just replace

```<code>evenNumbers[x] = x;
// or
oddNumbers[x] = x;
</code>```

with

```<code>evenNumbers.push(x);
// or
oddNumbers.push(x);
</code>```

By usingArray#push, you avoid holes, because every element is filled with a value.

function myDigitChecker() {
    var input = prompt("Please enter two positive digits, decimals will be rounded"),
        digits = Math.round(input), //take the inoput and convert it to a whole number
        evenNumbers = [],
        oddNumbers = [],
        x;

    while (isNaN(digits) || digits < 10 || digits > 99) { //isNaN is a method for checking if something isn't a number
        digits = prompt("Please enter two positive digits, decimals will be rounded");
    }

    for (var x = 0; x <= digits; x++) {
        if (x % 2 === 0) {
            evenNumbers.push(x);
        } else {
            oddNumbers.push(x);
        }
    }

    document.getElementById("demo").innerHTML = evenNumbers.join(",");
    document.getElementById("demo2").innerHTML = oddNumbers.join(",");
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><p>Click the button to run the digit checker.</p>
<!--Text telling the user to hit the button-->

<button onclick="myDigitChecker()">Submit</button>
<!--button that runs my function once they hit-->

<p id="demo"></p>
<p id="demo2"></p></code>```

Body:
This is probably really basic but I keep getting strange output when printing an array, it keeps putting double commas in between values in the arrays. I know it's something simple but I've been at this for a couple of hours now and no joy. You can see at the end I've tried a couple of things but end up with a weird double comma.

<!DOCTYPE html>

Click the button to run the digit checker.

<button onclick="myDigitChecker()" >Submit</button>

Body:
You create a sparse array with holes by using indices which are not consecutive.

Just replace

evenNumbers[x] = x;
// or
oddNumbers[x] = x;

with

evenNumbers.push(x);
// or
oddNumbers.push(x);

By usingArray#push, you avoid holes, because every element is filled with a value.

function myDigitChecker() {
    var input = prompt("Please enter two positive digits, decimals will be rounded"),
        digits = Math.round(input), //take the inoput and convert it to a whole number
        evenNumbers = [],
        oddNumbers = [],
        x;

    while (isNaN(digits) || digits < 10 || digits > 99) { //isNaN is a method for checking if something isn't a number
        digits = prompt("Please enter two positive digits, decimals will be rounded");
    }

    for (var x = 0; x <= digits; x++) {
        if (x % 2 === 0) {
            evenNumbers.push(x);
        } else {
            oddNumbers.push(x);
        }
    }

    document.getElementById("demo").innerHTML = evenNumbers.join(",");
    document.getElementById("demo2").innerHTML = oddNumbers.join(",");
}

<p>Click the button to run the digit checker.</p>
<!--Text telling the user to hit the button-->

<button onclick="myDigitChecker()">Submit</button>
<!--button that runs my function once they hit-->

<p id="demo"></p>
<p id="demo2"></p>


问:
C++ static initialization of stateless class
Suppose I have a class T where

T has no virtual functions.

T instances have no state.

T has static member instances of itself.

T itself has no other state.

Can the C++ static initialization fiasco ruin my program? I don't think so because even if one of the static instances is not initialized before use, that should not matter because T objects are stateless.

I'm interested in doing this for enum-like classes like so:

```<code>// Switch.h

class Switch {
public:
    static Switch const ON;
    static Switch const OFF;
    bool operator== (Switch const &s) const;
    bool operator!= (Switch const &s) const;
private:
    Switch () {}
    Switch (Switch const &); // no implementation
    Switch & operator= (Switch const &); // no implementation
};
</code>```

```<code>// Switch.cpp

Switch const Switch::ON;
Switch const Switch::OFF;

bool Switch::operator== (Switch const &s) const {
    return this == &s;
}

bool Switch::operator!= (Switch const &s) const {
    return this != &s;
}
</code>```

答:
I am interested in what are the advantages that you see from, say, an enum wrapped in either a namespace or a class:

```<code>namespace Switch {
   enum Switch {
      ON,
      OFF
   };
}
</code>```

It will be simpler to use in most cases (in your implementation you require users to employ either references or pointers, as the objects are non-copyable), it requires less code (no need to disable the constructors, and create the operators)...

As a matter of fact, in the upcoming standard you almost get that for free without even the use of the namespace:

```<code>enum Switch {
   ON,
   OFF
};
// bad, it allows this (as in the current standard):
Switch s = ON;
// good, it does also allow explicit qualification:
Switch s = Switch::ON;
</code>```

ContentLicense: CC BY-SA 3.0

Body:
Suppose I have a class T where

T has no virtual functions.

T instances have no state.

T has static member instances of itself.

T itself has no other state.

Can the C++ static initialization fiasco ruin my program? I don't think so because even if one of the static instances is not initialized before use, that should not matter because T objects are stateless.

I'm interested in doing this for enum-like classes like so:

// Switch.h

class Switch {
public:
    static Switch const ON;
    static Switch const OFF;
    bool operator== (Switch const &s) const;
    bool operator!= (Switch const &s) const;
private:
    Switch () {}
    Switch (Switch const &); // no implementation
    Switch & operator= (Switch const &); // no implementation
};

// Switch.cpp

Switch const Switch::ON;
Switch const Switch::OFF;

bool Switch::operator== (Switch const &s) const {
    return this == &s;
}

bool Switch::operator!= (Switch const &s) const {
    return this != &s;
}

Body:
I am interested in what are the advantages that you see from, say, an enum wrapped in either a namespace or a class:

namespace Switch {
   enum Switch {
      ON,
      OFF
   };
}

It will be simpler to use in most cases (in your implementation you require users to employ either references or pointers, as the objects are non-copyable), it requires less code (no need to disable the constructors, and create the operators)...

As a matter of fact, in the upcoming standard you almost get that for free without even the use of the namespace:

enum Switch {
   ON,
   OFF
};
// bad, it allows this (as in the current standard):
Switch s = ON;
// good, it does also allow explicit qualification:
Switch s = Switch::ON;


问:
Identify Font File Used in Microsoft Word 2010
I know that the font files used by Microsoft Word is located at

C:\Windows\Fonts

I am particularly concern about the font OCR A Std. I want to locate the font files for the OCR A Std regular font, bold font, italic font and bold italic font. Below are the sample fonts:

Regular

Bold

Italics

Bold Italics

Now, I want to locate the four corresponding font files for the said font. But when, I look at C:\Windows\Fonts, only 2 font file with the name OCRAStd.otf (OCR A Std Regular)and OCRAEXT.TTF (OCR A Extended) is found. Unlike with other fonts like Times New Roman,its corresponding four font versions are found, namely: Times New Roman Regular, Times New Roman Bold, Times New Roman Italics and Times New Roman Bold Italics. My questions are :

Is C:\Windows\Fonts, the right location where I can find the font files for Microsoft Word 2010? If no, then where? If yes, what are the font file names corresponding to the four versions of OCR A? How can I determine it by myself?

If it is not  in my computer, where can I download it? I already searched the web but only found OCR-A Std Regular and Bold, no Italics and Bold Italics.

Thanks.

答:
There are no files for OCR-A Std Italic or Bold Italic. These are what is known as synthesized fonts. They are:

[...] supplied in regular and bold styles only, meaning italic characters are synthesized by slanting the upright styles.

This happens for many fonts, not just OCR-A (please review the linked article for other examples).


问:
Return resolved promise value
```<code>  const displayCharacters =  async () => {
    if(filteredCharacters !== 'default'){
      const a = filteredCharacters.map(e => e.name);
      const options = {
        method: "POST",
        headers: { "Content-Type": "application/json" },
        body: JSON.stringify({ 'data' : a })
      };

      const b = await fetch("/image",options).then(res => res.json())
      return b;

    }else{
      return "yikes";
    }
  }

  console.log(displayCharacters());
</code>```

I have this fetch request but when I log the results this is what i see :

```<code>Promise {<resolved>: "yikes"}
__proto__: Promise
[[PromiseStatus]]: "resolved"
[[PromiseValue]]: "yikes"
</code>```

I just want the promiseValue and not this whole thing around it. How do i do this?

答:
The best way that i know to use fetch goes something like this:

```<code>const displayCharacters =  async () => {
  if(filteredCharacters !== 'default'){
    const a = filteredCharacters.map(e => e.name);
    const options = {
      method: "POST",
      headers: { "Content-Type": "application/json" },
      body: JSON.stringify({ 'data' : a })
    };

    const b = await fetch("/image",options)
      .then(res => {
        // Handle API Errors
        if (!res.ok) {
          throw Error(res.statusText);
        }
        // Return if no errors
        return res.json();
      })
      // this is the data you want
      .then(data => data)
      // it will only reject on network failure or if anything prevented the request from completing
      .catch(error => {
        console.log(error.message)
      });

    return b;

  }else{
    return "yikes";
  }
}
</code>```

Basically you chain two thens and a catch to completely understand the response
- the first then checks for api level errors
- second then gets you the data
- catch is invoked in case when it is not able to reach the api itself like connection issues

Title: Return resolved promise value

Body:
  const displayCharacters =  async () => {
    if(filteredCharacters !== 'default'){
      const a = filteredCharacters.map(e => e.name);
      const options = {
        method: "POST",
        headers: { "Content-Type": "application/json" },
        body: JSON.stringify({ 'data' : a })
      };

      const b = await fetch("/image",options).then(res => res.json())
      return b;

    }else{
      return "yikes";
    }
  }

  console.log(displayCharacters());

I have this fetch request but when I log the results this is what i see :

Promise {<resolved>: "yikes"}
__proto__: Promise
[[PromiseStatus]]: "resolved"
[[PromiseValue]]: "yikes"

I just want the promiseValue and not this whole thing around it. How do i do this?

Body:
The best way that i know to use fetch goes something like this:

const displayCharacters =  async () => {
  if(filteredCharacters !== 'default'){
    const a = filteredCharacters.map(e => e.name);
    const options = {
      method: "POST",
      headers: { "Content-Type": "application/json" },
      body: JSON.stringify({ 'data' : a })
    };

    const b = await fetch("/image",options)
      .then(res => {
        // Handle API Errors
        if (!res.ok) {
          throw Error(res.statusText);
        }
        // Return if no errors
        return res.json();
      })
      // this is the data you want
      .then(data => data)
      // it will only reject on network failure or if anything prevented the request from completing
      .catch(error => {
        console.log(error.message)
      });

    return b;

  }else{
    return "yikes";
  }
}

Basically you chain two thens and a catch to completely understand the response
- the first then checks for api level errors
- second then gets you the data
- catch is invoked in case when it is not able to reach the api itself like connection issues


问:
./odoo-bin --config=' /etc/odoo.conf' ODOO 11
Traceback (most recent call last):
  File "./odoo-bin", line 5, in <module>
    import odoo
  File "/opt/odoo/odoo/odoo/__init__.py", line 88, in <module>
    from . import service
  File "/opt/odoo/odoo/odoo/service/__init__.py", line 7, in <module>
    from . import wsgi_server
  File "/opt/odoo/odoo/odoo/service/wsgi_server.py", line 25, in <module>
    import werkzeug.contrib.fixers
ModuleNotFoundError: No module named 'werkzeug.contrib'

答:
I ran into the same issue when trying to use Proxyfix in werkzeug==1.0.0

Since that Werkzeug 1.0.0 has removed deprecated code from werkzeug.contrib, ProxyFix was relocated to werkzeug.middleware.proxy_fix

To fix the ModuleNotFoundError: No module named 'werkzeug.contrib' Error:

You should import ProxyFix with the following code:

```<code>from werkzeug.middleware.proxy_fix import ProxyFix
</code>```

I hope this helps and fix your issues

Body:
I ran into the same issue when trying to use Proxyfix in werkzeug==1.0.0

Since that Werkzeug 1.0.0 has removed deprecated code from werkzeug.contrib, ProxyFix was relocated to werkzeug.middleware.proxy_fix

To fix the ModuleNotFoundError: No module named 'werkzeug.contrib' Error:

You should import ProxyFix with the following code:

from werkzeug.middleware.proxy_fix import ProxyFix

I hope this helps and fix your issues


问:
Spark structured streaming: why java code uses DataSet and scala uses DataFrame type?
Hi I'm just reading offical document of spark structured streaming: https://spark.apache.org/docs/latest/structured-streaming-programming-guide.html#quick-example

Its sample code of java uses DataFrame and introduces DataFrame as the basic type for structured streaming, but meanwhile the sibling java code uses Dataset as data type. I'm just wondering, as long as spark/scala is running on jvm, shouldn't both scala and java use the same data type to represent?

Or DataFrame is in fact a kind of Dataset, somehow?

Hope to get your explanations of this question, thank you.

答: A DataFrame is, indeed, a special case of DataSet - DataSet[Row], where Row is a mostly generic type defined here. DataFrame as a term and a type predates the DataSet API, and its usage as an alias for DataSet[Row] is more or less a compatibility feature in Scala Spark. A full explanation of the differences, such as they are, is availabe here.


问:
Fastest way to code this fitness function?
I have the equation listed below in 1. We are trying to code this in R in an attempt to then have it called by a genetic algorithm. The weights (wi, wj) are unknown and will be decided by the algorithm.

What is the fastest way to code this equation in R:

(Sum i=1 (mu i wi))/ (sum i=1 sum j=1 (sigma i j wi wj))

Image of the equation below 1

答:
```<code>mu <- c(4,7)
w <- c(2,3)
# numerator:
c(crossprod(mu,w))
# denominator
Sigma <- matrix(rpois(4, 10), ncol=2) # matrix of the sigma_{ij}
c(t(w) %*% Sigma %*% w)
</code>```

If you want this quantity as a function of w:

```<code>f <- function(w, mu, Sigma){
  c(crossprod(mu,w)) / c(t(w) %*% Sigma %*% w)
}
</code>```

Body:
mu <- c(4,7)
w <- c(2,3)
# numerator:
c(crossprod(mu,w))
# denominator
Sigma <- matrix(rpois(4, 10), ncol=2) # matrix of the sigma_{ij}
c(t(w) %*% Sigma %*% w)

If you want this quantity as a function of w:

f <- function(w, mu, Sigma){
  c(crossprod(mu,w)) / c(t(w) %*% Sigma %*% w)
}