【问题标题】:Why is Ruby not updating after updating with Ruby Installer?为什么使用 Ruby Installer 更新后 Ruby 不更新?
【发布时间】:2018-07-28 18:04:13
【问题描述】:

我目前在我的 Windows 10 机器上安装了 Ruby 版本 2.2.6,但需要更新订单才能使用 shopify_app gem。我下载了没有 devkit 的 Ruby 2.5.1-2 (x64),正如 Ruby Installer 网站上所说的那样,并按照提示进行操作。我似乎完成了安装,但在命令行中输入ruby -v 告诉我我仍在使用版本 2.2.6。我也试过bundle update,它给出了以下内容:

C:\Sites\postgresapp>bundle update
The dependency byebug (>= 0) will be unused by any of the platforms Bundler is installing for. Bundler is installing for x86-mingw32 but the dependency is only for ruby. To add those platforms to the bundle, run `bundle lock --add-platform ruby`.
Fetching gem metadata from https://rubygems.org/...........
Fetching gem metadata from https://rubygems.org/..
Resolving dependencies........
Using rake 12.3.1
Using concurrent-ruby 1.0.5
Using i18n 1.0.1
Using minitest 5.11.3
Using thread_safe 0.3.6
Using tzinfo 1.2.5
Using activesupport 5.0.7
Using builder 3.2.3
Using erubis 2.7.0
Using mini_portile2 2.3.0
Using nokogiri 1.8.4 (x86-mingw32)
Using rails-dom-testing 2.0.3
Using crass 1.0.4
Using loofah 2.2.2
Using rails-html-sanitizer 1.0.4
Using actionview 5.0.7
Using rack 2.0.5
Using rack-test 0.6.3
Using actionpack 5.0.7
Using nio4r 2.3.1
Using websocket-extensions 0.1.3
Using websocket-driver 0.6.5
Using actioncable 5.0.7
Using globalid 0.4.1
Using activejob 5.0.7
Using mini_mime 1.0.0
Using mail 2.7.0
Using actionmailer 5.0.7
Using activemodel 5.0.7
Using activemodel-serializers-xml 1.0.2
Using arel 7.1.4
Using activerecord 5.0.7
Using activeresource 5.0.0
Using bindex 0.5.0
Using bundler 1.16.2
Using coffee-script-source 1.12.2
Using execjs 2.7.0
Using coffee-script 2.4.1
Using method_source 0.9.0
Using thor 0.20.0
Using railties 5.0.7
Using coffee-rails 4.2.2
Using multipart-post 2.0.0
Using faraday 0.12.2
Using ffi 1.9.25 (x86-mingw32)
Using graphql 1.8.5
Using graphql-client 0.13.0
Using hashie 3.5.7
Using multi_json 1.13.1
Using jbuilder 2.7.0
Using jquery-rails 4.3.3
Using jwt 1.5.6
Using multi_xml 0.6.0
Using oauth2 1.4.0
Using omniauth 1.8.1
Using omniauth-oauth2 1.5.0
Using omniauth-shopify-oauth2 1.2.1
Using pg 0.21.0 (x86-mingw32)
Using puma 3.12.0
Using sprockets 3.7.2
Using sprockets-rails 3.2.1
Using rails 5.0.7
Using rb-fsevent 0.10.3
Using rb-inotify 0.9.10
Using sass-listen 4.0.0
Using sass 3.5.7
Using tilt 2.0.8
Using sass-rails 5.0.7
Using shopify_api 4.12.0
Fetching shopify_app 8.2.6
Installing shopify_app 8.2.6
Gem::InstallError: shopify_app requires Ruby version >= 2.3.1.
An error occurred while installing shopify_app (8.2.6), and Bundler cannot
continue.
Make sure that `gem install shopify_app -v '8.2.6' --source
'https://rubygems.org/'` succeeds before bundling.

In Gemfile:
  shopify_app

编辑:添加 GEMFILE

source 'https://rubygems.org'

git_source(:github) do |repo_name|
  repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
  "https://github.com/#{repo_name}.git"
end

gem 'shopify_app', '~> 8.2.6'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.0.6'
# Use postgresql as the database for Active Record
gem 'pg', '~> 0.18'
# Use Puma as the app server
gem 'puma', '~> 3.0'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.2'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby

# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.5'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 3.0'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
gem 'simple_form'


group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug', platform: :mri
end

group :development do
  # Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
  gem 'web-console', '>= 3.3.0'
end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
"gem 'shopify_app'"

如何才能完成最新版 Ruby 的安装?

【问题讨论】:

  • 如果可以的话,发布您定义的所有环境变量(请参阅下面的说明),这将比不相关的 gemspec 文件更有意义。这在技术上是一个“Windows”问题,而不是 Ruby。如果列表中有您的姓名或您不想在线显示的任何其他内容,甚至只是屏幕截图,请务必编辑该列表。

标签: ruby-on-rails ruby shopify-app railsinstaller-windows


【解决方案1】:

您需要更新您的PATH 环境变量,它仍然指向旧安装。如果我没记错的话,安装程序确实有一个复选框可以选中以设置PATH 变量。一次只能在您的PATH 中安装一个。

请参阅this answer 了解更改变量的快速方法。它将遵循与以下相同的语法。

打开cmd.exe 并输入:

set PATH=%PATH%;C:\Ruby250\bin

您的安装位置可能不同,进入前请确认。您也可以通过MyComputer 的属性窗口或他们现在所称的任何名称来执行此操作。我发现终端更简单,因为它需要大约 6 个窗口深度才能通过 GUI 进行更改。

一步一步:

  • 找到安装 ruby​​ 的目录,通常是 C:\Ruby250\bin(版本可能不同)
  • 打开命令提示符、终端、cmd.exe 或任何您喜欢的名称 更喜欢这样称呼它。
  • 输入set PATH=%PATH%;C:\Ruby250\bin(如果是您的,请更改文件夹名称 不同)
  • Enter按钮
  • 在新的cmd.exe 中,键入ruby -v
  • 享受

另一个编辑

  • 点击“开始”按钮(可能在屏幕的左下角)
  • 开始输入“环境”一词,直到看到选项 Edit the system environment variables 出现
  • 点击那个
  • 将打开一个小窗口,左下方是一个按钮 阅读Environment Variables
  • 点击那个按钮
  • 会有两个部分,一个用于用户(即当前帐户 仅),另一个是“系统”,这是默认设置和 系统范围的变量
  • 在每个(只是为了确定)中,突出显示具有 变量名称的“路径”
  • 在您刚刚单击的列表下找到显示为 Edit...
  • 点击它
  • 看列表,每个人都不一样,看不懂 你。找到它是 Ruby 安装位置的那个, 我的读 C:\Ruby24\bin 因为我使用的是 Ruby 2.4.4
  • 您需要确保文件夹路径是您安装的位置 红宝石。这不能为你做,只有你知道。默认情况下 C:\RUBY***\bin,其中*** 是您的版本号。你必须 打开资源管理器并简单地查看。
  • 如果变量是 Ruby 2.5 的安装位置,很好,它 不需要更改,但请查看列表以确保存在 没有通往其他 Ruby 版本的其他途径。如果有,突出显示 并单击删除按钮将其删除。
  • 在您可能进行过编辑的每个窗口上单击OK,而不是 Cancel,而不是窗外的 X。
  • 要确认它是否有效,打开一个新的命令窗口,如果已经 打开,更改将不会在其中更新。

【讨论】:

  • 我已阅读此答案,但我不明白。它省略了步骤。我在安装中没有看到有关路径变量的任何内容。这是什么路径?
  • 我一步一步加了。如果失败,谷歌change PATH environment variable,网上会有成千上万的说明,有图片。有多种改变方式。
  • STEP 1:你的意思是旧版本安装到哪里还是我刚刚下载的新版本安装到哪里?我如何找到目录?第 3 步:当您说“更改文件夹名称”时,我要更改“set PATH=%PATH%;C:\Ruby250\bin”的哪一部分?如果您能填写这些空白,我将尝试按照步骤操作,谢谢。
  • 系统必须知道在哪里可以找到 Ruby。路径就是这样做的。第 1 步:是的,您新安装的 Ruby。第 3 步:只需更改您在第 1 步中找到的路径(C:...)。或者,您可以通过 Windows 环境访问路径:java.com/en/download/help/path.xml(不要搞砸了,只需添加 Ruby 路径并删除旧的,如果您删除了应该存在的路径,您的系统可能无法找到某些程序)
  • 我已经在 Windows 上编写 Ruby 代码大约一年了。这非常耗时。新安装需要很多时间。有些 gem 很难安装(例如,curb)。一些窗口“标志”出现在您的 gemfile.lock 中。除其他问题外。如果您有足够的信心尝试切换到 Linux (Ubuntu)。学习需要时间,但您会在 Ruby 编码中节省相当多的时间。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2013-11-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多