Только одна версия Ruby работает, когда установлено несколько версий - PullRequest
3 голосов
/ 22 января 2020

Редактировать 1: Другой человек сообщил аналогичная проблема с asdf.

Редактировать 2: Другой сообщил аналогичная проблема .

Редактировать 3: Я удалил rvm, установил rvm, установил ruby и rails и попытался выполнить некоторые действия.

Edit 4: Другой человек упомянул , что это вызвано строкой, которую я вставил в .zshrc (или .bash_profile/.bashrc): RUBYOPT: "-W:no-deprecated -W:no-experimental".

Проблема: у меня есть два проекта, один с использованием ruby-2.7.0, другой с использованием ruby-2.6.5.

Каждый раз, когда я устанавливал более двух версий ruby, работала только одна версия (2.7.0). Команды bundle, а также gem на другой больше не будут работать, но выдают Traceback....(RuntimeError).

Самые последние попытки и выходные данные консоли: Поток вывода на консоль примерно равен:

  1. Удаление rvm
  2. Установка rvm
  3. Установка ruby-2.7.0
  4. Установка ruby-2.6.5
  5. Для ruby-2.7.0, установить rails
  6. Для ruby-2.6.5 установить rails
  7. Пока все работает нормально
  8. Добавить export PATH="$PATH:$HOME/.rvm/bin" в ~ / .zshr c
  9. все еще в порядке
  10. Did echo "export RUBYOPT='-W:no-deprecated -W:no-experimental'" >> ~/.zshrc; source ~/.zshrc
  11. Начал замечать проблему снова
  12. ruby-2.6.5 не работает; ruby-2.7.0 все еще работает
# 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]

Оригинальное описание проблемы:

У меня есть два проекта, один с использованием ruby-2.7.0, другой с использованием ruby-2.6.5 ,

Я только что понял, что есть странная проблема с моей установкой Ruby / Rails на последней OS X. Либо с использованием rvm или rbenv, каждый раз, когда я устанавливал более двух версий ruby, работает только одна версия (2.7.0). Команды bundle и gem на других больше не будут работать, но выдают Traceback....(RuntimeError).

За последние 6 часов я переустановил rbenv, удалил rbenv, установил rvm. Я также попытался удалить все несистемные версии Ruby и Rails. Кажется, ничего не помогает.

Ниже приведена ошибка, отображаемая в моей консоли:

(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)

1 Ответ

4 голосов
/ 15 февраля 2020

У меня возникла точно такая же проблема, за исключением использования rbenv с bash.

Похоже, что виновником является эхо "export RUBYOPT = '- W: без устаревших -W: без экспериментальных'" в вашем файле. zsh, я не уверен, что Ruby 2.6.5 его понимает.

Remove echo "export RUBYOPT = '- W: no-deprecated -W: no-экспериментальный' "из вашего. zsh / .bashr c / .profile и перезапустите вашу оболочку.

...