gpt4 book ai didi

ruby-on-rails - 如何在 AWS 上卸载捆绑程序(以及本地和系统范围的 gem 之间的区别)

转载 作者:太空宇宙 更新时间:2023-11-03 17:53:02 26 4
gpt4 key购买 nike

当我在我的 AWS 实例上运行 bundle install 时,我在我的 gemfile 上遇到了这个语法错误:

Gemfile syntax error:
/var/www/mheesen.cc/releases/20131206072125/Gemfile:18: syntax error,
unexpected ':', expecting kEND
...tter-bootstrap-rails', github: 'seyhunak/twitter-bootstrap-r...
^

这是一个错误,通常与我安装了 Ruby 1.8 有关,但通过键入 ruby -v 我得到了 ruby 1.9.3

进一步挖掘,我阅读了“error in your Gemfile, and Bundler cannot continue”,并认为这可能是因为我的 bundler 使用的是系统 Ruby 而不是本地的。 (我不太确定它是如何工作的,但是哦,好吧。)

我认为最好的补救措施是卸载 bundler gem 并重新安装它,希望它会选择具有正确 Ruby 版本的正确的 bundler,但是尝试在我的项目目录中卸载会给我这个错误:

path/to/my/project$ gem uninstall bundler
ERROR: While executing gem ... (Gem::InstallError)
bundler is not installed in GEM_HOME, try:
gem uninstall -i /usr/local/rvm/gems/ruby-1.9.3-p484@global bundler

这证实了我的怀疑,它正在使用系统范围的 bundler ,但随后尝试卸载该系统范围的 bundler 给我一个权限错误:

gem uninstall -i /usr/local/rvm/gems/ruby-1.9.3-p484@global bundler
Remove executables:
bundle

in addition to the gem? [Yn] Y
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the
/usr/local/rvm/gems/ruby-1.9.3-p484@global/bin directory.

我尝试更改上述文件夹的权限.. 也没有权限这样做。

尝试在我的项目上更新 bundler 也告诉我一切都是最新的。

我现在该怎么办?我有哪些选择?我的想法用完了。

最佳答案

快速修复:

$ cd /var/www/mheesen.cc/releases/20131206072125
$ sudo gem install bundler # Since "bundler is not installed in GEM_HOME"
$ sudo bundle install

长期修复:

您似乎已将 RVM 安装为系统包,可能是通过 sudo apt-get install rvm 安装的。如果可能的话卸载它并使用 RVM install guide 安装它.不要使用 sudo 安装。

步骤:

# Uninstall system package RVM (in flavor of RVM user install method)
$ sudo apt-get remove rvm

# Don't edit your bashrc. RVM alone will attempt to setup your shell (2013)
$ \curl -sSL https://get.rvm.io | bash
$ source ~/.rvm/scripts/rvm

$ rvm requirements #=> will install gawk, g++, libreadline6-dev, etc...
$ rvm install 1.9.3
$ rvm use --default 2.0.0

您应该在项目目录(提交此更改并再次部署)的 .ruby-version 文件中强制使用 ruby​​ 版本,内容如下:

$ vim .ruby-version
1.9.3

作为奖励,您可以用最新最好的系统完全替换旧系统 ruby​​ 1.8.7:

# Use this to replace old 1.8.7 on your system
$ git clone https://github.com/sstephenson/ruby-build.git
$ cd ruby-build
$ ./install.sh

$ ruby-build 2.0.0-p353 /usr/local

关于 GEM_HOME 及相关的注释:

GEM_PATH provides the locations (there may be several) where gems can be found

GEM_HOME is where gems will be installed (by default)

Therefore GEM_PATH should include GEM_HOME

关于ruby-on-rails - 如何在 AWS 上卸载捆绑程序(以及本地和系统范围的 gem 之间的区别),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20450460/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com